ai 4.1.8 → 4.1.10
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/CHANGELOG.md +16 -0
- package/dist/index.d.mts +85 -95
- package/dist/index.d.ts +85 -95
- package/dist/index.js +184 -180
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +182 -179
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/rsc/dist/index.d.ts +2 -2
- package/rsc/dist/rsc-server.d.mts +2 -2
- package/rsc/dist/rsc-server.mjs +144 -144
- package/rsc/dist/rsc-server.mjs.map +1 -1
- package/test/dist/index.d.mts +0 -3
- package/test/dist/index.d.ts +0 -3
- package/test/dist/index.js.map +1 -1
- package/test/dist/index.mjs.map +1 -1
package/dist/index.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { IDGenerator } from '@ai-sdk/provider-utils';
|
2
|
-
export {
|
2
|
+
export { CoreToolCall, CoreToolResult, IDGenerator, ToolCall, ToolResult, createIdGenerator, generateId } from '@ai-sdk/provider-utils';
|
3
3
|
import { DataStreamString, ToolInvocation, Attachment, Schema, DeepPartial, Message, JSONValue as JSONValue$1, AssistantMessage, DataMessage } from '@ai-sdk/ui-utils';
|
4
4
|
export { AssistantMessage, AssistantStatus, Attachment, ChatRequest, ChatRequestOptions, CreateMessage, DataMessage, DataStreamPart, DeepPartial, IdGenerator, JSONValue, Message, RequestOptions, Schema, ToolInvocation, UseAssistantOptions, formatAssistantStreamPart, formatDataStreamPart, jsonSchema, parseAssistantStreamPart, parseDataStreamPart, processDataStream, processTextStream } from '@ai-sdk/ui-utils';
|
5
5
|
import { JSONValue, EmbeddingModelV1, EmbeddingModelV1Embedding, ImageModelV1, ImageModelV1CallWarning, LanguageModelV1, LanguageModelV1FinishReason, LanguageModelV1LogProbs, LanguageModelV1CallWarning, LanguageModelV1ProviderMetadata, LanguageModelV1CallOptions, AISDKError, LanguageModelV1FunctionToolCall, JSONSchema7, NoSuchModelError } from '@ai-sdk/provider';
|
@@ -150,10 +150,14 @@ Tool choice for the generation. It supports the following settings:
|
|
150
150
|
- `none`: the model must not call tools
|
151
151
|
- `{ type: 'tool', toolName: string (typed) }`: the model must call the specified tool
|
152
152
|
*/
|
153
|
-
type
|
153
|
+
type ToolChoice<TOOLS extends Record<string, unknown>> = 'auto' | 'none' | 'required' | {
|
154
154
|
type: 'tool';
|
155
155
|
toolName: keyof TOOLS;
|
156
156
|
};
|
157
|
+
/**
|
158
|
+
* @deprecated Use `ToolChoice` instead.
|
159
|
+
*/
|
160
|
+
type CoreToolChoice<TOOLS extends Record<string, unknown>> = ToolChoice<TOOLS>;
|
157
161
|
|
158
162
|
type LanguageModelRequestMetadata = {
|
159
163
|
/**
|
@@ -483,12 +487,6 @@ declare function generateImage({ model, prompt, n, size, aspectRatio, seed, prov
|
|
483
487
|
Only applicable for HTTP-based providers.
|
484
488
|
*/
|
485
489
|
headers?: Record<string, string>;
|
486
|
-
/**
|
487
|
-
* Internal. For test use only. May change without notice.
|
488
|
-
*/
|
489
|
-
_internal?: {
|
490
|
-
currentDate?: () => Date;
|
491
|
-
};
|
492
490
|
}): Promise<GenerateImageResult>;
|
493
491
|
|
494
492
|
type CallSettings = {
|
@@ -967,13 +965,6 @@ to the provider from the AI SDK and enable provider-specific
|
|
967
965
|
functionality that can be fully encapsulated in the provider.
|
968
966
|
*/
|
969
967
|
experimental_providerMetadata?: ProviderMetadata;
|
970
|
-
/**
|
971
|
-
* Internal. For test use only. May change without notice.
|
972
|
-
*/
|
973
|
-
_internal?: {
|
974
|
-
generateId?: () => string;
|
975
|
-
currentDate?: () => Date;
|
976
|
-
};
|
977
968
|
}): Promise<GenerateObjectResult<Array<ELEMENT>>>;
|
978
969
|
/**
|
979
970
|
Generate a value from an enum (limited list of string values) using a language model.
|
@@ -1238,14 +1229,6 @@ functionality that can be fully encapsulated in the provider.
|
|
1238
1229
|
Callback that is called when the LLM response and the final object validation are finished.
|
1239
1230
|
*/
|
1240
1231
|
onFinish?: OnFinishCallback<OBJECT>;
|
1241
|
-
/**
|
1242
|
-
* Internal. For test use only. May change without notice.
|
1243
|
-
*/
|
1244
|
-
_internal?: {
|
1245
|
-
generateId?: () => string;
|
1246
|
-
currentDate?: () => Date;
|
1247
|
-
now?: () => number;
|
1248
|
-
};
|
1249
1232
|
}): StreamObjectResult<DeepPartial<OBJECT>, OBJECT, never>;
|
1250
1233
|
/**
|
1251
1234
|
Generate an array with structured, typed elements for a given prompt and element schema using a language model.
|
@@ -1356,6 +1339,16 @@ Callback that is called when the LLM response and the final object validation ar
|
|
1356
1339
|
};
|
1357
1340
|
}): StreamObjectResult<JSONValue, JSONValue, never>;
|
1358
1341
|
|
1342
|
+
/**
|
1343
|
+
* Appends a client message to the messages array.
|
1344
|
+
* If the last message in the array has the same id as the new message, it will be replaced.
|
1345
|
+
* Otherwise, the new message will be appended.
|
1346
|
+
*/
|
1347
|
+
declare function appendClientMessage({ messages, message, }: {
|
1348
|
+
messages: Message[];
|
1349
|
+
message: Message;
|
1350
|
+
}): Message[];
|
1351
|
+
|
1359
1352
|
type Parameters = z.ZodTypeAny | Schema<any>;
|
1360
1353
|
type inferParameters<PARAMETERS extends Parameters> = PARAMETERS extends Schema<any> ? PARAMETERS['_type'] : PARAMETERS extends z.ZodTypeAny ? z.infer<PARAMETERS> : never;
|
1361
1354
|
interface ToolExecutionOptions {
|
@@ -1379,7 +1372,7 @@ This enables the language model to generate the input.
|
|
1379
1372
|
|
1380
1373
|
The tool can also contain an optional execute function for the actual execution function of the tool.
|
1381
1374
|
*/
|
1382
|
-
type
|
1375
|
+
type Tool<PARAMETERS extends Parameters = any, RESULT = any> = {
|
1383
1376
|
/**
|
1384
1377
|
The schema of the input that the tool expects. The language model will use this to generate the input.
|
1385
1378
|
It is also used to validate the output of the language model.
|
@@ -1421,30 +1414,24 @@ The arguments for configuring the tool. Must match the expected arguments define
|
|
1421
1414
|
*/
|
1422
1415
|
args: Record<string, unknown>;
|
1423
1416
|
});
|
1417
|
+
/**
|
1418
|
+
* @deprecated Use `Tool` instead.
|
1419
|
+
*/
|
1420
|
+
type CoreTool<PARAMETERS extends Parameters = any, RESULT = any> = Tool<PARAMETERS, RESULT>;
|
1424
1421
|
/**
|
1425
1422
|
Helper function for inferring the execute args of a tool.
|
1426
1423
|
*/
|
1427
|
-
declare function tool<PARAMETERS extends Parameters, RESULT>(tool:
|
1424
|
+
declare function tool<PARAMETERS extends Parameters, RESULT>(tool: Tool<PARAMETERS, RESULT> & {
|
1428
1425
|
execute: (args: inferParameters<PARAMETERS>, options: ToolExecutionOptions) => PromiseLike<RESULT>;
|
1429
|
-
}):
|
1426
|
+
}): Tool<PARAMETERS, RESULT> & {
|
1430
1427
|
execute: (args: inferParameters<PARAMETERS>, options: ToolExecutionOptions) => PromiseLike<RESULT>;
|
1431
1428
|
};
|
1432
|
-
declare function tool<PARAMETERS extends Parameters, RESULT>(tool:
|
1429
|
+
declare function tool<PARAMETERS extends Parameters, RESULT>(tool: Tool<PARAMETERS, RESULT> & {
|
1433
1430
|
execute?: undefined;
|
1434
|
-
}):
|
1431
|
+
}): Tool<PARAMETERS, RESULT> & {
|
1435
1432
|
execute: undefined;
|
1436
1433
|
};
|
1437
1434
|
|
1438
|
-
/**
|
1439
|
-
* Appends a client message to the messages array.
|
1440
|
-
* If the last message in the array has the same id as the new message, it will be replaced.
|
1441
|
-
* Otherwise, the new message will be appended.
|
1442
|
-
*/
|
1443
|
-
declare function appendClientMessage({ messages, message, }: {
|
1444
|
-
messages: Message[];
|
1445
|
-
message: Message;
|
1446
|
-
}): Message[];
|
1447
|
-
|
1448
1435
|
/**
|
1449
1436
|
Create a union of the given object's values, and optionally specify which keys to get the values from.
|
1450
1437
|
|
@@ -1487,7 +1474,9 @@ onlyBar('bar');
|
|
1487
1474
|
*/
|
1488
1475
|
type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
|
1489
1476
|
|
1490
|
-
type
|
1477
|
+
type ToolSet = Record<string, Tool>;
|
1478
|
+
|
1479
|
+
type ToolCallUnion<TOOLS extends ToolSet> = ValueOf<{
|
1491
1480
|
[NAME in keyof TOOLS]: {
|
1492
1481
|
type: 'tool-call';
|
1493
1482
|
toolCallId: string;
|
@@ -1495,17 +1484,21 @@ type ToolCallUnion<TOOLS extends Record<string, CoreTool>> = ValueOf<{
|
|
1495
1484
|
args: inferParameters<TOOLS[NAME]['parameters']>;
|
1496
1485
|
};
|
1497
1486
|
}>;
|
1498
|
-
|
1487
|
+
/**
|
1488
|
+
* @deprecated Use `ToolCallUnion` instead.
|
1489
|
+
*/
|
1490
|
+
type CoreToolCallUnion<TOOLS extends ToolSet> = ToolCallUnion<ToolSet>;
|
1491
|
+
type ToolCallArray<TOOLS extends ToolSet> = Array<ToolCallUnion<TOOLS>>;
|
1499
1492
|
|
1500
|
-
type ToToolsWithExecute<TOOLS extends
|
1493
|
+
type ToToolsWithExecute<TOOLS extends ToolSet> = {
|
1501
1494
|
[K in keyof TOOLS as TOOLS[K] extends {
|
1502
1495
|
execute: any;
|
1503
1496
|
} ? K : never]: TOOLS[K];
|
1504
1497
|
};
|
1505
|
-
type ToToolsWithDefinedExecute<TOOLS extends
|
1498
|
+
type ToToolsWithDefinedExecute<TOOLS extends ToolSet> = {
|
1506
1499
|
[K in keyof TOOLS as TOOLS[K]['execute'] extends undefined ? never : K]: TOOLS[K];
|
1507
1500
|
};
|
1508
|
-
type ToToolResultObject<TOOLS extends
|
1501
|
+
type ToToolResultObject<TOOLS extends ToolSet> = ValueOf<{
|
1509
1502
|
[NAME in keyof TOOLS]: {
|
1510
1503
|
type: 'tool-result';
|
1511
1504
|
toolCallId: string;
|
@@ -1514,8 +1507,12 @@ type ToToolResultObject<TOOLS extends Record<string, CoreTool>> = ValueOf<{
|
|
1514
1507
|
result: Awaited<ReturnType<Exclude<TOOLS[NAME]['execute'], undefined>>>;
|
1515
1508
|
};
|
1516
1509
|
}>;
|
1517
|
-
type ToolResultUnion<TOOLS extends
|
1518
|
-
|
1510
|
+
type ToolResultUnion<TOOLS extends ToolSet> = ToToolResultObject<ToToolsWithDefinedExecute<ToToolsWithExecute<TOOLS>>>;
|
1511
|
+
/**
|
1512
|
+
* @deprecated Use `ToolResultUnion` instead.
|
1513
|
+
*/
|
1514
|
+
type CoreToolResultUnion<TOOLS extends ToolSet> = ToolResultUnion<TOOLS>;
|
1515
|
+
type ToolResultArray<TOOLS extends ToolSet> = Array<ToolResultUnion<TOOLS>>;
|
1519
1516
|
|
1520
1517
|
/**
|
1521
1518
|
A message that was generated during the generation process.
|
@@ -1530,7 +1527,7 @@ Message ID generated by the AI SDK.
|
|
1530
1527
|
/**
|
1531
1528
|
* The result of a single step in the generation process.
|
1532
1529
|
*/
|
1533
|
-
type StepResult<TOOLS extends
|
1530
|
+
type StepResult<TOOLS extends ToolSet> = {
|
1534
1531
|
/**
|
1535
1532
|
The generated text.
|
1536
1533
|
*/
|
@@ -1613,7 +1610,7 @@ declare function appendResponseMessages({ messages, responseMessages, }: {
|
|
1613
1610
|
Converts an array of messages from useChat into an array of CoreMessages that can be used
|
1614
1611
|
with the AI core functions (e.g. `streamText`).
|
1615
1612
|
*/
|
1616
|
-
declare function convertToCoreMessages<TOOLS extends
|
1613
|
+
declare function convertToCoreMessages<TOOLS extends ToolSet = never>(messages: Array<UIMessage>, options?: {
|
1617
1614
|
tools?: TOOLS;
|
1618
1615
|
}): CoreMessage[];
|
1619
1616
|
|
@@ -1621,7 +1618,7 @@ declare function convertToCoreMessages<TOOLS extends Record<string, CoreTool> =
|
|
1621
1618
|
The result of a `generateText` call.
|
1622
1619
|
It contains the generated text, the tool calls that were made during the generation, and the results of the tool calls.
|
1623
1620
|
*/
|
1624
|
-
interface GenerateTextResult<TOOLS extends
|
1621
|
+
interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT> {
|
1625
1622
|
/**
|
1626
1623
|
The generated text.
|
1627
1624
|
*/
|
@@ -1771,7 +1768,7 @@ declare class NoSuchToolError extends AISDKError {
|
|
1771
1768
|
* @param options.parameterSchema - A function that returns the JSON Schema for a tool.
|
1772
1769
|
* @param options.error - The error that occurred while parsing the tool call.
|
1773
1770
|
*/
|
1774
|
-
type ToolCallRepairFunction<TOOLS extends
|
1771
|
+
type ToolCallRepairFunction<TOOLS extends ToolSet> = (options: {
|
1775
1772
|
system: string | undefined;
|
1776
1773
|
messages: CoreMessage[];
|
1777
1774
|
toolCall: LanguageModelV1FunctionToolCall;
|
@@ -1829,7 +1826,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
1829
1826
|
@returns
|
1830
1827
|
A result object that contains the generated text, the results of the tool calls, and additional information.
|
1831
1828
|
*/
|
1832
|
-
declare function generateText<TOOLS extends
|
1829
|
+
declare function generateText<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never>({ model, tools, toolChoice, system, prompt, messages, maxRetries: maxRetriesArg, abortSignal, headers, maxSteps, experimental_generateMessageId: generateMessageId, experimental_output: output, experimental_continueSteps: continueSteps, experimental_telemetry: telemetry, experimental_providerMetadata: providerMetadata, experimental_activeTools: activeTools, experimental_repairToolCall: repairToolCall, _internal: { generateId, currentDate, }, onStepFinish, ...settings }: CallSettings & Prompt & {
|
1833
1830
|
/**
|
1834
1831
|
The language model to use.
|
1835
1832
|
*/
|
@@ -1841,7 +1838,7 @@ The tools that the model can call. The model needs to support calling tools.
|
|
1841
1838
|
/**
|
1842
1839
|
The tool choice strategy. Default: 'auto'.
|
1843
1840
|
*/
|
1844
|
-
toolChoice?:
|
1841
|
+
toolChoice?: ToolChoice<TOOLS>;
|
1845
1842
|
/**
|
1846
1843
|
Maximum number of sequential LLM calls (steps), e.g. when you use tool calls. Must be at least 1.
|
1847
1844
|
|
@@ -1887,13 +1884,6 @@ A function that attempts to repair a tool call that failed to parse.
|
|
1887
1884
|
Callback that is called when each step (LLM call) is finished, including intermediate steps.
|
1888
1885
|
*/
|
1889
1886
|
onStepFinish?: (event: StepResult<TOOLS>) => Promise<void> | void;
|
1890
|
-
/**
|
1891
|
-
* Internal. For test use only. May change without notice.
|
1892
|
-
*/
|
1893
|
-
_internal?: {
|
1894
|
-
generateId?: IDGenerator;
|
1895
|
-
currentDate?: () => Date;
|
1896
|
-
};
|
1897
1887
|
}): Promise<GenerateTextResult<TOOLS, OUTPUT>>;
|
1898
1888
|
|
1899
1889
|
/**
|
@@ -1916,7 +1906,7 @@ declare class StreamData {
|
|
1916
1906
|
/**
|
1917
1907
|
A result object for accessing different stream types and additional information.
|
1918
1908
|
*/
|
1919
|
-
interface StreamTextResult<TOOLS extends
|
1909
|
+
interface StreamTextResult<TOOLS extends ToolSet, PARTIAL_OUTPUT> {
|
1920
1910
|
/**
|
1921
1911
|
Warnings from the model provider (e.g. unsupported settings) for the first step.
|
1922
1912
|
*/
|
@@ -2087,7 +2077,7 @@ interface StreamTextResult<TOOLS extends Record<string, CoreTool>, PARTIAL_OUTPU
|
|
2087
2077
|
*/
|
2088
2078
|
toTextStreamResponse(init?: ResponseInit): Response;
|
2089
2079
|
}
|
2090
|
-
type TextStreamPart<TOOLS extends
|
2080
|
+
type TextStreamPart<TOOLS extends ToolSet> = {
|
2091
2081
|
type: 'text-delta';
|
2092
2082
|
textDelta: string;
|
2093
2083
|
} | {
|
@@ -2148,15 +2138,9 @@ type TextStreamPart<TOOLS extends Record<string, CoreTool>> = {
|
|
2148
2138
|
*
|
2149
2139
|
* @returns A transform stream that smooths text streaming output.
|
2150
2140
|
*/
|
2151
|
-
declare function smoothStream<TOOLS extends
|
2141
|
+
declare function smoothStream<TOOLS extends ToolSet>({ delayInMs, chunking, _internal: { delay }, }?: {
|
2152
2142
|
delayInMs?: number | null;
|
2153
2143
|
chunking?: 'word' | 'line' | RegExp;
|
2154
|
-
/**
|
2155
|
-
* Internal. For test use only. May change without notice.
|
2156
|
-
*/
|
2157
|
-
_internal?: {
|
2158
|
-
delay?: (delayInMs: number | null) => Promise<void>;
|
2159
|
-
};
|
2160
2144
|
}): (options: {
|
2161
2145
|
tools: TOOLS;
|
2162
2146
|
}) => TransformStream<TextStreamPart<TOOLS>, TextStreamPart<TOOLS>>;
|
@@ -2167,7 +2151,7 @@ A transformation that is applied to the stream.
|
|
2167
2151
|
@param stopStream - A function that stops the source stream.
|
2168
2152
|
@param tools - The tools that are accessible to and can be called by the model. The model needs to support calling tools.
|
2169
2153
|
*/
|
2170
|
-
type StreamTextTransform<TOOLS extends
|
2154
|
+
type StreamTextTransform<TOOLS extends ToolSet> = (options: {
|
2171
2155
|
tools: TOOLS;
|
2172
2156
|
stopStream: () => void;
|
2173
2157
|
}) => TransformStream<TextStreamPart<TOOLS>, TextStreamPart<TOOLS>>;
|
@@ -2219,7 +2203,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
2219
2203
|
@return
|
2220
2204
|
A result object for accessing different stream types and additional information.
|
2221
2205
|
*/
|
2222
|
-
declare function streamText<TOOLS extends
|
2206
|
+
declare function streamText<TOOLS extends ToolSet, OUTPUT = never, PARTIAL_OUTPUT = never>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, maxSteps, experimental_generateMessageId: generateMessageId, experimental_output: output, experimental_continueSteps: continueSteps, experimental_telemetry: telemetry, experimental_providerMetadata: providerMetadata, experimental_toolCallStreaming, toolCallStreaming, experimental_activeTools: activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, onChunk, onFinish, onStepFinish, _internal: { now, generateId, currentDate, }, ...settings }: CallSettings & Prompt & {
|
2223
2207
|
/**
|
2224
2208
|
The language model to use.
|
2225
2209
|
*/
|
@@ -2231,7 +2215,7 @@ The tools that the model can call. The model needs to support calling tools.
|
|
2231
2215
|
/**
|
2232
2216
|
The tool choice strategy. Default: 'auto'.
|
2233
2217
|
*/
|
2234
|
-
toolChoice?:
|
2218
|
+
toolChoice?: ToolChoice<TOOLS>;
|
2235
2219
|
/**
|
2236
2220
|
Maximum number of sequential LLM calls (steps), e.g. when you use tool calls. Must be at least 1.
|
2237
2221
|
|
@@ -2311,14 +2295,6 @@ Details for all steps.
|
|
2311
2295
|
Callback that is called when each step (LLM call) is finished, including intermediate steps.
|
2312
2296
|
*/
|
2313
2297
|
onStepFinish?: (event: StepResult<TOOLS>) => Promise<void> | void;
|
2314
|
-
/**
|
2315
|
-
Internal. For test use only. May change without notice.
|
2316
|
-
*/
|
2317
|
-
_internal?: {
|
2318
|
-
now?: () => number;
|
2319
|
-
generateId?: IDGenerator;
|
2320
|
-
currentDate?: () => Date;
|
2321
|
-
};
|
2322
2298
|
}): StreamTextResult<TOOLS, PARTIAL_OUTPUT>;
|
2323
2299
|
|
2324
2300
|
/**
|
@@ -2326,7 +2302,11 @@ Internal. For test use only. May change without notice.
|
|
2326
2302
|
* This type defines the structure for middleware that can be used to modify
|
2327
2303
|
* the behavior of LanguageModelV1 operations.
|
2328
2304
|
*/
|
2329
|
-
type
|
2305
|
+
type LanguageModelV1Middleware = {
|
2306
|
+
/**
|
2307
|
+
* Middleware specification version. Use `v1` for the current version.
|
2308
|
+
*/
|
2309
|
+
middlewareVersion?: 'v1' | undefined;
|
2330
2310
|
/**
|
2331
2311
|
* Transforms the parameters before they are passed to the language model.
|
2332
2312
|
* @param options - Object containing the type of operation and the parameters.
|
@@ -2367,6 +2347,22 @@ type Experimental_LanguageModelV1Middleware = {
|
|
2367
2347
|
model: LanguageModelV1;
|
2368
2348
|
}) => PromiseLike<Awaited<ReturnType<LanguageModelV1['doStream']>>>;
|
2369
2349
|
};
|
2350
|
+
/**
|
2351
|
+
* @deprecated Use `LanguageModelV1Middleware` instead.
|
2352
|
+
*/
|
2353
|
+
type Experimental_LanguageModelV1Middleware = LanguageModelV1Middleware;
|
2354
|
+
|
2355
|
+
/**
|
2356
|
+
* Extract an XML-tagged reasoning section from the generated text and exposes it
|
2357
|
+
* as a `reasoning` property on the result.
|
2358
|
+
*
|
2359
|
+
* @param tagName - The name of the XML tag to extract reasoning from.
|
2360
|
+
* @param separator - The separator to use between reasoning and text sections.
|
2361
|
+
*/
|
2362
|
+
declare function extractReasoningMiddleware({ tagName, separator, }: {
|
2363
|
+
tagName: string;
|
2364
|
+
separator?: string;
|
2365
|
+
}): LanguageModelV1Middleware;
|
2370
2366
|
|
2371
2367
|
/**
|
2372
2368
|
* Wraps a LanguageModelV1 instance with middleware functionality.
|
@@ -2380,24 +2376,21 @@ type Experimental_LanguageModelV1Middleware = {
|
|
2380
2376
|
* @param options.providerId - Optional custom provider ID to override the original model's provider.
|
2381
2377
|
* @returns A new LanguageModelV1 instance with middleware applied.
|
2382
2378
|
*/
|
2383
|
-
declare const
|
2379
|
+
declare const wrapLanguageModel: ({ model, middleware: { transformParams, wrapGenerate, wrapStream }, modelId, providerId, }: {
|
2384
2380
|
model: LanguageModelV1;
|
2385
|
-
middleware:
|
2381
|
+
middleware: LanguageModelV1Middleware;
|
2386
2382
|
modelId?: string;
|
2387
2383
|
providerId?: string;
|
2388
2384
|
}) => LanguageModelV1;
|
2389
|
-
|
2390
2385
|
/**
|
2391
|
-
*
|
2392
|
-
* as a `reasoning` property on the result.
|
2393
|
-
*
|
2394
|
-
* @param tagName - The name of the XML tag to extract reasoning from.
|
2395
|
-
* @param separator - The separator to use between reasoning and text sections.
|
2386
|
+
* @deprecated Use `wrapLanguageModel` instead.
|
2396
2387
|
*/
|
2397
|
-
declare
|
2398
|
-
|
2399
|
-
|
2400
|
-
|
2388
|
+
declare const experimental_wrapLanguageModel: ({ model, middleware: { transformParams, wrapGenerate, wrapStream }, modelId, providerId, }: {
|
2389
|
+
model: LanguageModelV1;
|
2390
|
+
middleware: LanguageModelV1Middleware;
|
2391
|
+
modelId?: string;
|
2392
|
+
providerId?: string;
|
2393
|
+
}) => LanguageModelV1;
|
2401
2394
|
|
2402
2395
|
/**
|
2403
2396
|
* Creates a custom provider with specified language models, text embedding models, and an optional fallback provider.
|
@@ -2467,9 +2460,6 @@ declare function simulateReadableStream<T>({ chunks, initialDelayInMs, chunkDela
|
|
2467
2460
|
chunks: T[];
|
2468
2461
|
initialDelayInMs?: number | null;
|
2469
2462
|
chunkDelayInMs?: number | null;
|
2470
|
-
_internal?: {
|
2471
|
-
delay?: (ms: number | null) => Promise<void>;
|
2472
|
-
};
|
2473
2463
|
}): ReadableStream<T>;
|
2474
2464
|
|
2475
2465
|
declare const symbol$a: unique symbol;
|
@@ -2780,4 +2770,4 @@ declare namespace llamaindexAdapter {
|
|
2780
2770
|
};
|
2781
2771
|
}
|
2782
2772
|
|
2783
|
-
export { AssistantContent, AssistantResponse, CallWarning, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreTool,
|
2773
|
+
export { AssistantContent, AssistantResponse, CallWarning, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreTool, CoreToolCallUnion, CoreToolChoice, CoreToolMessage, CoreToolResultUnion, CoreUserMessage, DataContent, DataStreamWriter, DownloadError, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, GenerateImageResult as Experimental_GenerateImageResult, GeneratedImage as Experimental_GeneratedImage, Experimental_LanguageModelV1Middleware, FilePart, FinishReason, GenerateObjectResult, GenerateTextResult, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelResponseMetadata, ImagePart, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidToolArgumentsError, langchainAdapter as LangChainAdapter, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, LanguageModelV1Middleware, llamaindexAdapter as LlamaIndexAdapter, LogProbs, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, Provider, ProviderMetadata, RetryError, StepResult, StreamData, StreamObjectResult, StreamTextResult, StreamTextTransform, TelemetrySettings, TextPart, TextStreamPart, Tool, ToolCallPart, ToolCallRepairError, ToolCallRepairFunction, ToolCallUnion, ToolChoice, ToolContent, ToolExecutionError, ToolExecutionOptions, ToolResultPart, ToolResultUnion, ToolSet, UserContent, appendClientMessage, appendResponseMessages, convertToCoreMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createDataStream, createDataStreamResponse, embed, embedMany, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, experimental_wrapLanguageModel, extractReasoningMiddleware, generateObject, generateText, pipeDataStreamToResponse, simulateReadableStream, smoothStream, streamObject, streamText, tool, wrapLanguageModel };
|