@convex-dev/agent 0.1.18 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/createTool.d.ts +30 -11
- package/dist/client/createTool.d.ts.map +1 -1
- package/dist/client/createTool.js +24 -10
- package/dist/client/createTool.js.map +1 -1
- package/dist/client/defaultComponent.d.ts +11 -0
- package/dist/client/defaultComponent.d.ts.map +1 -0
- package/dist/client/defaultComponent.js +7 -0
- package/dist/client/defaultComponent.js.map +1 -0
- package/dist/client/definePlaygroundAPI.d.ts +68 -23
- package/dist/client/definePlaygroundAPI.d.ts.map +1 -1
- package/dist/client/definePlaygroundAPI.js +7 -20
- package/dist/client/definePlaygroundAPI.js.map +1 -1
- package/dist/client/files.d.ts +14 -4
- package/dist/client/files.d.ts.map +1 -1
- package/dist/client/files.js +66 -11
- package/dist/client/files.js.map +1 -1
- package/dist/client/index.d.ts +323 -780
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +445 -543
- package/dist/client/index.js.map +1 -1
- package/dist/client/messages.d.ts +256 -0
- package/dist/client/messages.d.ts.map +1 -0
- package/dist/client/messages.js +97 -0
- package/dist/client/messages.js.map +1 -0
- package/dist/client/search.d.ts +35 -12
- package/dist/client/search.d.ts.map +1 -1
- package/dist/client/search.js +21 -4
- package/dist/client/search.js.map +1 -1
- package/dist/client/streaming.d.ts +21 -21
- package/dist/client/streaming.d.ts.map +1 -1
- package/dist/client/streaming.js +35 -40
- package/dist/client/streaming.js.map +1 -1
- package/dist/client/threads.d.ts +46 -0
- package/dist/client/threads.d.ts.map +1 -0
- package/dist/client/threads.js +49 -0
- package/dist/client/threads.js.map +1 -0
- package/dist/client/types.d.ts +159 -75
- package/dist/client/types.d.ts.map +1 -1
- package/dist/component/_generated/api.d.ts +261 -209
- package/dist/component/messages.d.ts +314 -105
- package/dist/component/messages.d.ts.map +1 -1
- package/dist/component/messages.js +141 -83
- package/dist/component/messages.js.map +1 -1
- package/dist/component/schema.d.ts +631 -870
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/component/schema.js +11 -16
- package/dist/component/schema.js.map +1 -1
- package/dist/component/streams.d.ts +29 -149
- package/dist/component/streams.d.ts.map +1 -1
- package/dist/component/streams.js +104 -60
- package/dist/component/streams.js.map +1 -1
- package/dist/component/threads.d.ts +4 -4
- package/dist/component/users.d.ts +3 -3
- package/dist/mapping.d.ts +15 -16
- package/dist/mapping.d.ts.map +1 -1
- package/dist/mapping.js +208 -62
- package/dist/mapping.js.map +1 -1
- package/dist/parts.d.ts +3 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +34 -0
- package/dist/parts.js.map +1 -0
- package/dist/react/SmoothText.d.ts +5 -0
- package/dist/react/SmoothText.d.ts.map +1 -0
- package/dist/react/SmoothText.js +6 -0
- package/dist/react/SmoothText.js.map +1 -0
- package/dist/react/deltas.d.ts +3 -5
- package/dist/react/deltas.d.ts.map +1 -1
- package/dist/react/deltas.js +89 -53
- package/dist/react/deltas.js.map +1 -1
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +31 -11
- package/dist/react/index.js.map +1 -1
- package/dist/react/optimisticallySendMessage.d.ts.map +1 -1
- package/dist/react/optimisticallySendMessage.js +2 -8
- package/dist/react/optimisticallySendMessage.js.map +1 -1
- package/dist/react/toUIMessages.d.ts +5 -4
- package/dist/react/toUIMessages.d.ts.map +1 -1
- package/dist/react/toUIMessages.js +103 -40
- package/dist/react/toUIMessages.js.map +1 -1
- package/dist/react/useSmoothText.d.ts +13 -12
- package/dist/react/useSmoothText.d.ts.map +1 -1
- package/dist/react/useSmoothText.js +1 -1
- package/dist/react/useSmoothText.js.map +1 -1
- package/dist/validators.d.ts +751 -1464
- package/dist/validators.d.ts.map +1 -1
- package/dist/validators.js +39 -80
- package/dist/validators.js.map +1 -1
- package/package.json +34 -30
- package/src/client/createTool.ts +66 -40
- package/src/client/defaultComponent.ts +17 -0
- package/src/client/definePlaygroundAPI.ts +17 -31
- package/src/client/files.ts +94 -17
- package/src/client/index.test.ts +28 -38
- package/src/client/index.ts +785 -977
- package/src/client/messages.ts +205 -0
- package/src/client/search.ts +37 -10
- package/src/client/streaming.ts +53 -56
- package/src/client/threads.ts +78 -0
- package/src/client/types.ts +239 -131
- package/src/component/_generated/api.d.ts +261 -209
- package/src/component/messages.test.ts +182 -40
- package/src/component/messages.ts +165 -108
- package/src/component/schema.ts +11 -17
- package/src/component/streams.ts +180 -69
- package/src/mapping.ts +253 -96
- package/src/parts.ts +39 -0
- package/src/react/SmoothText.tsx +9 -0
- package/src/react/deltas.test.ts +38 -42
- package/src/react/deltas.ts +116 -65
- package/src/react/index.ts +35 -13
- package/src/react/optimisticallySendMessage.ts +2 -8
- package/src/react/toUIMessages.test.ts +154 -36
- package/src/react/toUIMessages.ts +136 -57
- package/src/react/useSmoothText.ts +14 -15
- package/src/validators.test.ts +1 -117
- package/src/validators.ts +57 -107
- package/dist/client/listMessages.d.ts +0 -22
- package/dist/client/listMessages.d.ts.map +0 -1
- package/dist/client/listMessages.js +0 -25
- package/dist/client/listMessages.js.map +0 -1
- package/src/client/listMessages.ts +0 -38
package/dist/client/types.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { InferSchema, ProviderOptions, Schema } from "@ai-sdk/provider-utils";
|
|
2
|
+
import type { JSONValue } from "@ai-sdk/provider";
|
|
3
|
+
import type { GenerateObjectResult, generateText, GenerateTextResult, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, LanguageModel, streamObject, streamText, StreamTextResult, ToolChoice, ToolSet, RepairTextFunction, TelemetrySettings, CallSettings, Prompt } from "ai";
|
|
4
|
+
import type { Auth, Expand, FunctionArgs, FunctionReference, FunctionReturnType, GenericActionCtx, GenericDataModel, StorageActionWriter, StorageReader, WithoutSystemFields } from "convex/server";
|
|
3
5
|
import type { GenericId } from "convex/values";
|
|
4
|
-
import type { Schema } from "zod";
|
|
5
6
|
import type { Mounts } from "../component/_generated/api.js";
|
|
6
|
-
import type { ThreadDoc } from "../component/schema.js";
|
|
7
|
-
import type {
|
|
7
|
+
import type { MessageDoc, ThreadDoc } from "../component/schema.js";
|
|
8
|
+
import type { ProviderMetadata, StreamDelta, StreamMessage } from "../validators.js";
|
|
8
9
|
import type { StreamingOptions } from "./streaming.js";
|
|
10
|
+
import type * as z3 from "zod/v3";
|
|
11
|
+
import type * as z4 from "zod/v4";
|
|
9
12
|
/**
|
|
10
13
|
* Options to configure what messages are fetched as context,
|
|
11
14
|
* automatically with thread.generateText, or directly via search.
|
|
@@ -78,14 +81,32 @@ export type StorageOptions = {
|
|
|
78
81
|
saveMessages?: "all" | "none" | "promptAndOutput";
|
|
79
82
|
};
|
|
80
83
|
export type GenerationOutputMetadata = {
|
|
81
|
-
|
|
84
|
+
/**
|
|
85
|
+
* The ID of the prompt message for the generation.
|
|
86
|
+
*/
|
|
87
|
+
promptMessageId?: string;
|
|
88
|
+
/**
|
|
89
|
+
* The order of the prompt message and responses for the generation.
|
|
90
|
+
* Each order starts with a user message, then followed by agent responses.
|
|
91
|
+
* If a promptMessageId is provided, that dictates the order.
|
|
92
|
+
*/
|
|
82
93
|
order?: number;
|
|
94
|
+
/**
|
|
95
|
+
* The messages saved for the generation - both saved input and output.
|
|
96
|
+
* If you passed promptMessageId, it will not include that message.
|
|
97
|
+
*/
|
|
98
|
+
savedMessages?: MessageDoc[];
|
|
99
|
+
/**
|
|
100
|
+
* @deprecated Use promptMessageId instead.
|
|
101
|
+
* The ID of the prompt message for the generation.
|
|
102
|
+
*/
|
|
103
|
+
messageId?: string;
|
|
83
104
|
};
|
|
84
105
|
export type UsageHandler = (ctx: RunActionCtx, args: {
|
|
85
106
|
userId: string | undefined;
|
|
86
107
|
threadId: string | undefined;
|
|
87
108
|
agentName: string | undefined;
|
|
88
|
-
usage:
|
|
109
|
+
usage: LanguageModelUsage;
|
|
89
110
|
providerMetadata: ProviderMetadata | undefined;
|
|
90
111
|
model: string;
|
|
91
112
|
provider: string;
|
|
@@ -110,7 +131,7 @@ export type TextArgs<AgentTools extends ToolSet, TOOLS extends ToolSet | undefin
|
|
|
110
131
|
* The model to use for the LLM calls. This will override the model specified
|
|
111
132
|
* in the Agent constructor.
|
|
112
133
|
*/
|
|
113
|
-
model?:
|
|
134
|
+
model?: LanguageModel;
|
|
114
135
|
/**
|
|
115
136
|
* The tools to use for the tool calls. This will override tools specified
|
|
116
137
|
* in the Agent constructor or createThread / continueThread.
|
|
@@ -134,7 +155,7 @@ export type StreamingTextArgs<AgentTools extends ToolSet, TOOLS extends ToolSet
|
|
|
134
155
|
* The model to use for the tool calls. This will override the model specified
|
|
135
156
|
* in the Agent constructor.
|
|
136
157
|
*/
|
|
137
|
-
model?:
|
|
158
|
+
model?: LanguageModel;
|
|
138
159
|
/**
|
|
139
160
|
* The tools to use for the tool calls. This will override tools specified
|
|
140
161
|
* in the Agent constructor or createThread / continueThread.
|
|
@@ -146,67 +167,106 @@ export type StreamingTextArgs<AgentTools extends ToolSet, TOOLS extends ToolSet
|
|
|
146
167
|
*/
|
|
147
168
|
toolChoice?: ToolChoice<TOOLS extends undefined ? AgentTools : TOOLS>;
|
|
148
169
|
};
|
|
149
|
-
type
|
|
170
|
+
export type ObjectMode = "object" | "array" | "enum" | "no-schema";
|
|
171
|
+
export type ObjectSchema = z3.Schema | z4.core.$ZodType | Schema;
|
|
172
|
+
export type DefaultObjectSchema = z4.core.$ZodType<JSONValue>;
|
|
173
|
+
/**
|
|
174
|
+
* Due to some issues with the type inference of the ai sdk, we need to
|
|
175
|
+
* manually type the arguments for the generateObject function.
|
|
176
|
+
* This is a workaround to allow the model to be optional.
|
|
177
|
+
*/
|
|
178
|
+
export type GenerateObjectArgs<SCHEMA extends ObjectSchema = DefaultObjectSchema, OUTPUT extends ObjectMode = InferSchema<SCHEMA> extends string ? "enum" : "object", RESULT = OUTPUT extends "array" ? Array<InferSchema<SCHEMA>> : InferSchema<SCHEMA>> = Omit<CallSettings, "stopSequences"> & Prompt & (OUTPUT extends "enum" ? {
|
|
150
179
|
/**
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
180
|
+
The enum values that the model should use.
|
|
181
|
+
*/
|
|
182
|
+
enum: Array<RESULT>;
|
|
183
|
+
mode?: "json";
|
|
184
|
+
output: "enum";
|
|
185
|
+
} : OUTPUT extends "no-schema" ? {} : {
|
|
155
186
|
/**
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
system?: string;
|
|
187
|
+
The schema of the object that the model should generate.
|
|
188
|
+
*/
|
|
189
|
+
schema: SCHEMA;
|
|
160
190
|
/**
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
191
|
+
Optional name of the output that should be generated.
|
|
192
|
+
Used by some providers for additional LLM guidance, e.g.
|
|
193
|
+
via tool or schema name.
|
|
194
|
+
*/
|
|
195
|
+
schemaName?: string;
|
|
165
196
|
/**
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
197
|
+
Optional description of the output that should be generated.
|
|
198
|
+
Used by some providers for additional LLM guidance, e.g.
|
|
199
|
+
via tool or schema description.
|
|
200
|
+
*/
|
|
201
|
+
schemaDescription?: string;
|
|
171
202
|
/**
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
203
|
+
The mode to use for object generation.
|
|
204
|
+
|
|
205
|
+
The schema is converted into a JSON schema and used in one of the following ways
|
|
206
|
+
|
|
207
|
+
- 'auto': The provider will choose the best mode for the model.
|
|
208
|
+
- 'tool': A tool with the JSON schema as parameters is provided and the provider is instructed to use it.
|
|
209
|
+
- 'json': The JSON schema and an instruction are injected into the prompt. If the provider supports JSON mode, it is enabled. If the provider supports JSON grammars, the grammar is used.
|
|
210
|
+
|
|
211
|
+
Please note that most providers do not support all modes.
|
|
212
|
+
|
|
213
|
+
Default and recommended: 'auto' (best mode for the model).
|
|
214
|
+
*/
|
|
215
|
+
mode?: "auto" | "json" | "tool";
|
|
216
|
+
}) & {
|
|
217
|
+
output?: OUTPUT;
|
|
218
|
+
/**
|
|
219
|
+
The language model to use.
|
|
220
|
+
*/
|
|
221
|
+
model?: LanguageModel;
|
|
222
|
+
/**
|
|
223
|
+
A function that attempts to repair the raw output of the model
|
|
224
|
+
to enable JSON parsing.
|
|
225
|
+
*/
|
|
178
226
|
experimental_repairText?: RepairTextFunction;
|
|
227
|
+
/**
|
|
228
|
+
Optional telemetry configuration (experimental).
|
|
229
|
+
*/
|
|
179
230
|
experimental_telemetry?: TelemetrySettings;
|
|
231
|
+
/**
|
|
232
|
+
Additional provider-specific options. They are passed through
|
|
233
|
+
to the provider from the AI SDK and enable provider-specific
|
|
234
|
+
functionality that can be fully encapsulated in the provider.
|
|
235
|
+
*/
|
|
180
236
|
providerOptions?: ProviderOptions;
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
schemaDescription?: string;
|
|
189
|
-
};
|
|
190
|
-
type GenerateObjectArrayOptions<T> = BaseGenerateObjectOptions & {
|
|
191
|
-
output: "array";
|
|
192
|
-
mode?: "auto" | "json" | "tool";
|
|
193
|
-
schema: Schema<T>;
|
|
194
|
-
schemaName?: string;
|
|
195
|
-
schemaDescription?: string;
|
|
196
|
-
};
|
|
197
|
-
type GenerateObjectWithEnumOptions<T extends string> = BaseGenerateObjectOptions & {
|
|
198
|
-
output: "enum";
|
|
199
|
-
enum: Array<T>;
|
|
200
|
-
mode?: "auto" | "json" | "tool";
|
|
237
|
+
/**
|
|
238
|
+
* Internal. For test use only. May change without notice.
|
|
239
|
+
*/
|
|
240
|
+
_internal?: {
|
|
241
|
+
generateId?: () => string;
|
|
242
|
+
currentDate?: () => Date;
|
|
243
|
+
};
|
|
201
244
|
};
|
|
202
|
-
type
|
|
203
|
-
|
|
204
|
-
|
|
245
|
+
export type StreamObjectArgs<SCHEMA extends ObjectSchema = DefaultObjectSchema, OUTPUT extends ObjectMode = InferSchema<SCHEMA> extends string ? "enum" : "object", RESULT = OUTPUT extends "array" ? Array<InferSchema<SCHEMA>> : InferSchema<SCHEMA>> = GenerateObjectArgs<SCHEMA, OUTPUT, RESULT> & Pick<Parameters<typeof streamObject<SCHEMA, OUTPUT, RESULT>>[0], "onError" | "onFinish" | "_internal">;
|
|
246
|
+
export type MaybeCustomCtx<CustomCtx, DataModel extends GenericDataModel, AgentTools extends ToolSet> = CustomCtx extends Record<string, unknown> ? {
|
|
247
|
+
/**
|
|
248
|
+
* If you have a custom ctx that you use with the Agent
|
|
249
|
+
* (e.g. new Agent<{ orgId: string }>(...))
|
|
250
|
+
* you need to provide this function to add any extra fields.
|
|
251
|
+
* e.g.
|
|
252
|
+
* ```ts
|
|
253
|
+
* const myAgent = new Agent<{ orgId: string }>(...);
|
|
254
|
+
* const myAction = myAgent.asTextAction({
|
|
255
|
+
* customCtx: (ctx: ActionCtx, target, llmArgs) => {
|
|
256
|
+
* const orgId = await lookupOrgId(ctx, target.threadId);
|
|
257
|
+
* return { orgId };
|
|
258
|
+
* },
|
|
259
|
+
* });
|
|
260
|
+
* ```
|
|
261
|
+
* Then, in your tools, you can
|
|
262
|
+
*/
|
|
263
|
+
customCtx: (ctx: GenericActionCtx<DataModel>, target: {
|
|
264
|
+
userId?: string | undefined;
|
|
265
|
+
threadId?: string | undefined;
|
|
266
|
+
}, llmArgs: TextArgs<AgentTools>) => CustomCtx;
|
|
267
|
+
} : {
|
|
268
|
+
customCtx?: never;
|
|
205
269
|
};
|
|
206
|
-
type GenerateObjectArgs<T> = T extends Record<string, unknown> ? GenerateObjectObjectOptions<T> : T extends Array<unknown> ? GenerateObjectArrayOptions<T> : T extends string ? GenerateObjectWithEnumOptions<T> : GenerateObjectNoSchemaOptions;
|
|
207
|
-
type StreamObjectArgs<T> = T extends Record<string, unknown> ? GenerateObjectObjectOptions<T> : T extends Array<unknown> ? GenerateObjectArrayOptions<T> : GenerateObjectNoSchemaOptions;
|
|
208
|
-
export type OurObjectArgs<T> = GenerateObjectArgs<T> & Pick<Parameters<typeof generateObject<any>>[0], "experimental_repairText" | "abortSignal">;
|
|
209
|
-
export type OurStreamObjectArgs<T> = StreamObjectArgs<T> & Pick<Parameters<typeof streamObject<T>>[0], "onError" | "onFinish" | "abortSignal">;
|
|
210
270
|
type ThreadOutputMetadata = Required<GenerationOutputMetadata>;
|
|
211
271
|
/**
|
|
212
272
|
* The interface for a thread returned from {@link createThread} or {@link continueThread}.
|
|
@@ -235,7 +295,7 @@ export interface Thread<DefaultTools extends ToolSet> {
|
|
|
235
295
|
* for the {@link ContextOptions} and {@link StorageOptions}.
|
|
236
296
|
* @returns The result of the generateText function.
|
|
237
297
|
*/
|
|
238
|
-
generateText<TOOLS extends ToolSet | undefined = undefined, OUTPUT = never, OUTPUT_PARTIAL = never>(
|
|
298
|
+
generateText<TOOLS extends ToolSet | undefined = undefined, OUTPUT = never, OUTPUT_PARTIAL = never>(generateTextArgs: TextArgs<TOOLS extends undefined ? DefaultTools : TOOLS, TOOLS, OUTPUT, OUTPUT_PARTIAL>, options?: Options): Promise<GenerateTextResult<TOOLS extends undefined ? DefaultTools : TOOLS, OUTPUT> & ThreadOutputMetadata>;
|
|
239
299
|
/**
|
|
240
300
|
* This behaves like {@link streamText} from the "ai" package except that
|
|
241
301
|
* it add context based on the userId and threadId and saves the input and
|
|
@@ -246,7 +306,7 @@ export interface Thread<DefaultTools extends ToolSet> {
|
|
|
246
306
|
* for the {@link ContextOptions} and {@link StorageOptions}.
|
|
247
307
|
* @returns The result of the streamText function.
|
|
248
308
|
*/
|
|
249
|
-
streamText<TOOLS extends ToolSet | undefined = undefined, OUTPUT = never, PARTIAL_OUTPUT = never>(
|
|
309
|
+
streamText<TOOLS extends ToolSet | undefined = undefined, OUTPUT = never, PARTIAL_OUTPUT = never>(streamTextArgs: StreamingTextArgs<TOOLS extends undefined ? DefaultTools : TOOLS, TOOLS, OUTPUT, PARTIAL_OUTPUT>, options?: Options & {
|
|
250
310
|
/**
|
|
251
311
|
* Whether to save incremental data (deltas) from streaming responses.
|
|
252
312
|
* Defaults to false.
|
|
@@ -269,18 +329,20 @@ export interface Thread<DefaultTools extends ToolSet> {
|
|
|
269
329
|
* for the {@link ContextOptions} and {@link StorageOptions}.
|
|
270
330
|
* @returns The result of the generateObject function.
|
|
271
331
|
*/
|
|
272
|
-
generateObject<
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
332
|
+
generateObject<SCHEMA extends ObjectSchema = DefaultObjectSchema, OUTPUT extends ObjectMode = InferSchema<SCHEMA> extends string ? "enum" : "object", RESULT = OUTPUT extends "array" ? Array<InferSchema<SCHEMA>> : InferSchema<SCHEMA>>(generateObjectArgs: GenerateObjectArgs<SCHEMA, OUTPUT, RESULT> & {
|
|
333
|
+
/**
|
|
334
|
+
* If provided, this message will be used as the "prompt" for the LLM call,
|
|
335
|
+
* instead of the prompt or messages.
|
|
336
|
+
* This is useful if you want to first save a user message, then use it as
|
|
337
|
+
* the prompt for the LLM call in another call.
|
|
338
|
+
*/
|
|
339
|
+
promptMessageId?: string;
|
|
340
|
+
/**
|
|
341
|
+
* The model to use for the LLM calls. This will override the model specified
|
|
342
|
+
* in the Agent constructor.
|
|
343
|
+
*/
|
|
344
|
+
model?: LanguageModel;
|
|
345
|
+
}, options?: Options): Promise<GenerateObjectResult<RESULT> & ThreadOutputMetadata>;
|
|
284
346
|
/**
|
|
285
347
|
* This behaves like {@link streamObject} from the "ai" package except that
|
|
286
348
|
* it add context based on the userId and threadId and saves the input and
|
|
@@ -291,7 +353,24 @@ export interface Thread<DefaultTools extends ToolSet> {
|
|
|
291
353
|
* for the {@link ContextOptions} and {@link StorageOptions}.
|
|
292
354
|
* @returns The result of the streamObject function.
|
|
293
355
|
*/
|
|
294
|
-
streamObject<
|
|
356
|
+
streamObject<SCHEMA extends ObjectSchema = DefaultObjectSchema, OUTPUT extends ObjectMode = InferSchema<SCHEMA> extends string ? "enum" : "object", RESULT = OUTPUT extends "array" ? Array<InferSchema<SCHEMA>> : InferSchema<SCHEMA>>(
|
|
357
|
+
/**
|
|
358
|
+
* The same arguments you'd pass to "ai" sdk {@link streamObject}.
|
|
359
|
+
*/
|
|
360
|
+
streamObjectArgs: StreamObjectArgs<SCHEMA, OUTPUT, RESULT> & {
|
|
361
|
+
/**
|
|
362
|
+
* If provided, this message will be used as the "prompt" for the LLM call,
|
|
363
|
+
* instead of the prompt or messages.
|
|
364
|
+
* This is useful if you want to first save a user message, then use it as
|
|
365
|
+
* the prompt for the LLM call in another call.
|
|
366
|
+
*/
|
|
367
|
+
promptMessageId?: string;
|
|
368
|
+
/**
|
|
369
|
+
* The model to use for the LLM calls. This will override the model specified
|
|
370
|
+
* in the Agent constructor.
|
|
371
|
+
*/
|
|
372
|
+
model?: LanguageModel;
|
|
373
|
+
}, options?: Options): Promise<ReturnType<typeof streamObject<SCHEMA, OUTPUT, RESULT>> & ThreadOutputMetadata>;
|
|
295
374
|
}
|
|
296
375
|
export type Options = {
|
|
297
376
|
/**
|
|
@@ -302,6 +381,11 @@ export type Options = {
|
|
|
302
381
|
* The storage options to use for saving the input and output messages to the thread.
|
|
303
382
|
*/
|
|
304
383
|
storageOptions?: StorageOptions;
|
|
384
|
+
/**
|
|
385
|
+
* The usage handler to use for this thread. Overrides any handler
|
|
386
|
+
* set in the agent constructor.
|
|
387
|
+
*/
|
|
388
|
+
usageHandler?: UsageHandler;
|
|
305
389
|
};
|
|
306
390
|
export type SyncStreamsReturnValue = {
|
|
307
391
|
kind: "list";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EACf,MAAM,EACP,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EACV,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,4BAA4B,EAC5B,6BAA6B,EAC7B,kBAAkB,EAClB,aAAa,EACb,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,OAAO,EACP,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,MAAM,EACP,MAAM,IAAI,CAAC;AACZ,OAAO,KAAK,EACV,IAAI,EACJ,MAAM,EACN,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACpB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,aAAa,EACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAC;AAElC;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;OAIG;IACH,cAAc,CAAC,EAAE,MA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