You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These events allow you to subscribe to the creation, delta and completion of a RunStep.
59
+
60
+
For more information on how Runs and RunSteps work see the documentation [Runs and RunSteps](https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps)
@@ -69,9 +203,7 @@ See an example of automated function calls in action in
69
203
70
204
Note, `runFunctions` was also previously available, but has been deprecated in favor of `runTools`.
71
205
72
-
## Runner API
73
-
74
-
### Events
206
+
### Chat Events
75
207
76
208
#### `.on('connect', () => …)`
77
209
@@ -148,7 +280,7 @@ The event fired at the end, returning the total usage of the call.
148
280
149
281
The last event fired in the stream.
150
282
151
-
### Methods
283
+
### Chat Methods
152
284
153
285
#### `.abort()`
154
286
@@ -190,7 +322,7 @@ A promise which resolves with the last message with a `role: "function"`. Throws
190
322
191
323
A promise which resolves with the total usage.
192
324
193
-
### Fields
325
+
### Chat Fields
194
326
195
327
#### `.messages`
196
328
@@ -200,9 +332,9 @@ A mutable array of all messages in the conversation.
200
332
201
333
The underlying `AbortController` for the runner.
202
334
203
-
## Examples
335
+
### Chat Examples
204
336
205
-
### Abort on a function call
337
+
#### Abort on a function call
206
338
207
339
If you have a function call flow which you intend to _end_ with a certain function call, then you can use the second
208
340
argument `runner` given to the function to either mutate `runner.messages` or call `runner.abort()`.
@@ -238,7 +370,7 @@ async function main() {
238
370
main();
239
371
```
240
372
241
-
### Integrate with `zod`
373
+
#### Integrate with `zod`
242
374
243
375
[`zod`](https://www.npmjs.com/package/zod) is a schema validation library which can help with validating the
244
376
assistant's response to make sure it conforms to a schema. Paired with [`zod-to-json-schema`](https://www.npmjs.com/package/zod-to-json-schema), the validation schema also acts as the `parameters` JSON Schema passed to the API.
@@ -287,10 +419,10 @@ main();
287
419
288
420
See a more fully-fledged example in [`examples/function-call-helpers-zod.ts`](examples/function-call-helpers-zod.ts).
289
421
290
-
### Integrate with Next.JS
422
+
#### Integrate with Next.JS
291
423
292
424
See an example of a Next.JS integration here [`examples/stream-to-client-next.ts`](examples/stream-to-client-next.ts).
293
425
294
-
### Proxy Streaming to a Browser
426
+
#### Proxy Streaming to a Browser
295
427
296
428
See an example of using express to stream to a browser here [`examples/stream-to-client-express.ts`](examples/stream-to-client-express.ts).
0 commit comments