Spaces:
Build error
Build error
File size: 6,177 Bytes
c211499 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
export interface TracerSession {
tenant_id: string;
id: string;
start_time: number;
name?: string;
}
export interface TracerSessionResult extends TracerSession {
run_count?: number;
latency_p50?: number;
latency_p99?: number;
total_tokens?: number;
prompt_tokens?: number;
completion_tokens?: number;
last_run_start_time?: number;
feedback_stats?: Record<string, unknown>;
reference_dataset_ids?: string[];
run_facets?: KVMap[];
}
export type KVMap = Record<string, any>;
export type RunType = "llm" | "chain" | "tool" | "retriever" | "embedding" | "prompt" | "parser";
export type ScoreType = number | boolean | null;
export type ValueType = number | boolean | string | object | null;
export type DataType = "kv" | "llm" | "chat";
export interface BaseExample {
dataset_id: string;
inputs: KVMap;
outputs?: KVMap;
}
/**
* A run can represent either a trace (root run)
* or a child run (~span).
*/
export interface BaseRun {
/** Optionally, a unique identifier for the run. */
id?: string;
/** A human-readable name for the run. */
name: string;
/** Defines the sequence in which the run was executed. */
execution_order?: number;
/** The epoch time at which the run started, if available. */
start_time?: number;
/** Specifies the type of run (tool, chain, llm, etc.). */
run_type: string;
/** The epoch time at which the run ended, if applicable. */
end_time?: number;
/** Any additional metadata or settings for the run. */
extra?: KVMap;
/** Error message, captured if the run faces any issues. */
error?: string;
/** Serialized state of the run for potential future use. */
serialized?: object;
/** Events like 'start', 'end' linked to the run. */
events?: KVMap[];
/** Inputs that were used to initiate the run. */
inputs: KVMap;
/** Outputs produced by the run, if any. */
outputs?: KVMap;
/** ID of an example that might be related to this run. */
reference_example_id?: string;
/** ID of a parent run, if this run is part of a larger operation. */
parent_run_id?: string;
/** Tags for further categorizing or annotating the run. */
tags?: string[];
}
/**
* Describes properties of a run when loaded from the database.
* Extends the BaseRun interface.
*/
export interface Run extends BaseRun {
/** A unique identifier for the run, mandatory when loaded from DB. */
id: string;
/** Defines the sequence in which the run was executed. */
execution_order: number;
/** The ID of the project that owns this run. */
session_id?: string;
/** IDs of any child runs spawned by this run. */
child_run_ids?: string[];
/** Child runs, loaded explicitly via a heavier query. */
child_runs?: Run[];
/** Stats capturing feedback for this run. */
feedback_stats?: KVMap;
/** The URL path where this run is accessible within the app. */
app_path?: string;
/** The manifest ID that correlates with this run. */
manifest_id?: string;
/** The current status of the run, such as 'success'. */
status?: string;
/** Number of tokens used in the prompt. */
prompt_tokens?: number;
/** Number of tokens generated in the completion. */
completion_tokens?: number;
/** Total token count, combining prompt and completion. */
total_tokens?: number;
/** Time when the first token was processed. */
first_token_time?: number;
/** IDs of parent runs, if multiple exist. */
parent_run_ids?: string[];
/**Unique ID assigned to every run within this nested trace.**/
trace_id?: string;
/**
* The dotted order for the run.
*
* This is a string composed of {time}{run-uuid}.* so that a trace can be
* sorted in the order it was executed.
*
* Example:
* - Parent: 20230914T223155647Z1b64098b-4ab7-43f6-afee-992304f198d8
* - Children:
* - 20230914T223155647Z1b64098b-4ab7-43f6-afee-992304f198d8.20230914T223155649Z809ed3a2-0172-4f4d-8a02-a64e9b7a0f8a
* - 20230915T223155647Z1b64098b-4ab7-43f6-afee-992304f198d8.20230914T223155650Zc8d9f4c5-6c5a-4b2d-9b1c-3d9d7a7c5c7c
*/
dotted_order?: string;
}
export interface RunCreate extends BaseRun {
child_runs?: this[];
session_name?: string;
}
export interface RunUpdate {
end_time?: number;
extra?: KVMap;
error?: string;
inputs?: KVMap;
outputs?: KVMap;
parent_run_id?: string;
reference_example_id?: string;
events?: KVMap[];
session_id?: string;
}
export interface ExampleCreate extends BaseExample {
id?: string;
created_at: string;
}
export interface Example extends BaseExample {
id: string;
created_at: string;
modified_at: string;
runs: Run[];
}
export interface ExampleUpdate {
dataset_id?: string;
inputs?: KVMap;
outputs?: KVMap;
}
export interface BaseDataset {
name: string;
description: string;
tenant_id: string;
data_type?: DataType;
}
export interface Dataset extends BaseDataset {
id: string;
created_at: string;
modified_at: string;
example_count?: number;
session_count?: number;
last_session_start_time?: number;
}
export interface DatasetShareSchema {
dataset_id: string;
share_token: string;
url: string;
}
export interface FeedbackSourceBase {
type: string;
metadata?: KVMap;
}
export interface APIFeedbackSource extends FeedbackSourceBase {
type: "api";
}
export interface ModelFeedbackSource extends FeedbackSourceBase {
type: "model";
}
export interface FeedbackBase {
created_at: string;
modified_at: string;
run_id: string;
key: string;
score: ScoreType;
value: ValueType;
comment: string | null;
correction: string | object | null;
feedback_source: APIFeedbackSource | ModelFeedbackSource | KVMap | null;
}
export interface FeedbackCreate extends FeedbackBase {
id: string;
}
export interface Feedback extends FeedbackBase {
id: string;
}
export interface LangChainBaseMessage {
_getType: () => string;
content: string;
additional_kwargs?: KVMap;
}
|