-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathruns.ts
More file actions
224 lines (186 loc) · 5.46 KB
/
runs.ts
File metadata and controls
224 lines (186 loc) · 5.46 KB
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../core/resource';
import * as MessagesAPI from '../agents/messages';
import { RunsArrayPage } from '../agents/messages';
import * as RunsMessagesAPI from './messages';
import { MessageListParams, MessageStreamParams, MessageStreamResponse, Messages } from './messages';
import * as StepsAPI from './steps';
import { StepListParams, Steps } from './steps';
import * as TraceAPI from './trace';
import { Trace, TraceRetrieveParams, TraceRetrieveResponse } from './trace';
import * as UsageAPI from './usage';
import { Usage, UsageRetrieveResponse } from './usage';
import { APIPromise } from '../../core/api-promise';
import { ArrayPage, type ArrayPageParams, PagePromise } from '../../core/pagination';
import { RequestOptions } from '../../internal/request-options';
import { path } from '../../internal/utils/path';
export class Runs extends APIResource {
messages: RunsMessagesAPI.Messages = new RunsMessagesAPI.Messages(this._client);
usage: UsageAPI.Usage = new UsageAPI.Usage(this._client);
steps: StepsAPI.Steps = new StepsAPI.Steps(this._client);
trace: TraceAPI.Trace = new TraceAPI.Trace(this._client);
/**
* Get the status of a run.
*/
retrieve(runID: string, options?: RequestOptions): APIPromise<MessagesAPI.Run> {
return this._client.get(path`/v1/runs/${runID}`, options);
}
/**
* List all runs.
*/
list(
query: RunListParams | null | undefined = {},
options?: RequestOptions,
): PagePromise<RunsArrayPage, MessagesAPI.Run> {
return this._client.getAPIList('/v1/runs/', ArrayPage<MessagesAPI.Run>, { query, ...options });
}
}
/**
* Representation of offline jobs, used for tracking status of data loading tasks
* (involving parsing and embedding files).
*/
export interface Job {
/**
* The human-friendly ID of the Job
*/
id?: string;
/**
* The agent associated with this job/run.
*/
agent_id?: string | null;
/**
* Whether the job was created in background mode.
*/
background?: boolean | null;
/**
* Optional error message from attempting to POST the callback endpoint.
*/
callback_error?: string | null;
/**
* Timestamp when the callback was last attempted.
*/
callback_sent_at?: string | null;
/**
* HTTP status code returned by the callback endpoint.
*/
callback_status_code?: number | null;
/**
* If set, POST to this URL when the job completes.
*/
callback_url?: string | null;
/**
* The unix timestamp of when the job was completed.
*/
completed_at?: string | null;
/**
* The unix timestamp of when the job was created.
*/
created_at?: string;
/**
* The id of the user that made this object.
*/
created_by_id?: string | null;
/**
* The type of the job.
*/
job_type?: MessagesAPI.JobType;
/**
* The id of the user that made this object.
*/
last_updated_by_id?: string | null;
/**
* The metadata of the job.
*/
metadata?: { [key: string]: unknown } | null;
/**
* The status of the job.
*/
status?: MessagesAPI.JobStatus;
/**
* The reason why the job was stopped.
*/
stop_reason?: StopReasonType | null;
/**
* Total run duration in nanoseconds
*/
total_duration_ns?: number | null;
/**
* Time to first token for a run in nanoseconds
*/
ttft_ns?: number | null;
/**
* The timestamp when the object was last updated.
*/
updated_at?: string | null;
}
export type StopReasonType =
| 'end_turn'
| 'error'
| 'llm_api_error'
| 'invalid_llm_response'
| 'invalid_tool_call'
| 'max_steps'
| 'max_tokens_exceeded'
| 'no_tool_call'
| 'tool_rule'
| 'cancelled'
| 'insufficient_credits'
| 'requires_approval'
| 'context_window_overflow_in_system_prompt';
export interface RunListParams extends ArrayPageParams {
/**
* Filter for active runs.
*/
active?: boolean;
/**
* The unique identifier of the agent associated with the run.
*/
agent_id?: string | null;
/**
* @deprecated The unique identifiers of the agents associated with the run.
* Deprecated in favor of agent_id field.
*/
agent_ids?: Array<string> | null;
/**
* @deprecated Whether to sort agents oldest to newest (True) or newest to oldest
* (False, default). Deprecated in favor of order field.
*/
ascending?: boolean;
/**
* If True, filters for runs that were created in background mode.
*/
background?: boolean | null;
/**
* Filter runs by conversation ID.
*/
conversation_id?: string | null;
/**
* Filter runs by status. Can specify multiple statuses.
*/
statuses?: Array<string> | null;
/**
* Filter runs by stop reason.
*/
stop_reason?: StopReasonType | null;
}
Runs.Messages = Messages;
Runs.Usage = Usage;
Runs.Steps = Steps;
Runs.Trace = Trace;
export declare namespace Runs {
export { type Job as Job, type StopReasonType as StopReasonType, type RunListParams as RunListParams };
export {
Messages as Messages,
type MessageStreamResponse as MessageStreamResponse,
type MessageListParams as MessageListParams,
type MessageStreamParams as MessageStreamParams,
};
export { Usage as Usage, type UsageRetrieveResponse as UsageRetrieveResponse };
export { Steps as Steps, type StepListParams as StepListParams };
export {
Trace as Trace,
type TraceRetrieveResponse as TraceRetrieveResponse,
type TraceRetrieveParams as TraceRetrieveParams,
};
}
export { type RunsArrayPage };