@yourgpt/llm-sdk 2.1.4-alpha.1 → 2.1.4-alpha.3
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/adapters/index.d.mts +4 -2
- package/dist/adapters/index.d.ts +4 -2
- package/dist/base-5n-UuPfS.d.mts +768 -0
- package/dist/base-Di31iy_8.d.ts +768 -0
- package/dist/fallback/index.d.mts +96 -0
- package/dist/fallback/index.d.ts +96 -0
- package/dist/fallback/index.js +284 -0
- package/dist/fallback/index.mjs +280 -0
- package/dist/index.d.mts +62 -3
- package/dist/index.d.ts +62 -3
- package/dist/index.js +117 -2
- package/dist/index.mjs +116 -3
- package/dist/providers/anthropic/index.d.mts +3 -1
- package/dist/providers/anthropic/index.d.ts +3 -1
- package/dist/providers/azure/index.d.mts +3 -1
- package/dist/providers/azure/index.d.ts +3 -1
- package/dist/providers/google/index.d.mts +3 -1
- package/dist/providers/google/index.d.ts +3 -1
- package/dist/providers/ollama/index.d.mts +4 -2
- package/dist/providers/ollama/index.d.ts +4 -2
- package/dist/providers/openai/index.d.mts +3 -1
- package/dist/providers/openai/index.d.ts +3 -1
- package/dist/providers/openrouter/index.d.mts +3 -1
- package/dist/providers/openrouter/index.d.ts +3 -1
- package/dist/providers/xai/index.d.mts +3 -1
- package/dist/providers/xai/index.d.ts +3 -1
- package/dist/types-BQl1suAv.d.mts +212 -0
- package/dist/types-C0vLXzuw.d.ts +355 -0
- package/dist/types-CNL8ZRne.d.ts +212 -0
- package/dist/types-CR8mi9I0.d.mts +417 -0
- package/dist/types-CR8mi9I0.d.ts +417 -0
- package/dist/types-VDgiUvH2.d.mts +355 -0
- package/dist/yourgpt/index.d.mts +77 -0
- package/dist/yourgpt/index.d.ts +77 -0
- package/dist/yourgpt/index.js +167 -0
- package/dist/yourgpt/index.mjs +164 -0
- package/package.json +12 -1
- package/dist/adapters/index.js.map +0 -1
- package/dist/adapters/index.mjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/providers/anthropic/index.js.map +0 -1
- package/dist/providers/anthropic/index.mjs.map +0 -1
- package/dist/providers/azure/index.js.map +0 -1
- package/dist/providers/azure/index.mjs.map +0 -1
- package/dist/providers/google/index.js.map +0 -1
- package/dist/providers/google/index.mjs.map +0 -1
- package/dist/providers/ollama/index.js.map +0 -1
- package/dist/providers/ollama/index.mjs.map +0 -1
- package/dist/providers/openai/index.js.map +0 -1
- package/dist/providers/openai/index.mjs.map +0 -1
- package/dist/providers/openrouter/index.js.map +0 -1
- package/dist/providers/openrouter/index.mjs.map +0 -1
- package/dist/providers/xai/index.js.map +0 -1
- package/dist/providers/xai/index.mjs.map +0 -1
- package/dist/types-COAOEe_y.d.mts +0 -1460
- package/dist/types-COAOEe_y.d.ts +0 -1460
|
@@ -1,1460 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Core Types for @yourgpt/llm-sdk
|
|
5
|
-
*
|
|
6
|
-
* Modern, instance-based types following Vercel AI SDK patterns.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* A language model instance that can generate text.
|
|
11
|
-
* This is what provider functions like `openai('gpt-4o')` return.
|
|
12
|
-
*/
|
|
13
|
-
interface LanguageModel {
|
|
14
|
-
/** Provider identifier (e.g., 'openai', 'anthropic') */
|
|
15
|
-
readonly provider: string;
|
|
16
|
-
/** Model identifier (e.g., 'gpt-4o', 'claude-3-5-sonnet') */
|
|
17
|
-
readonly modelId: string;
|
|
18
|
-
/** Model capabilities for feature detection */
|
|
19
|
-
readonly capabilities: ModelCapabilities;
|
|
20
|
-
/**
|
|
21
|
-
* Generate a complete response (non-streaming)
|
|
22
|
-
* Used internally by generateText()
|
|
23
|
-
*/
|
|
24
|
-
doGenerate(params: DoGenerateParams): Promise<DoGenerateResult>;
|
|
25
|
-
/**
|
|
26
|
-
* Stream a response
|
|
27
|
-
* Used internally by streamText()
|
|
28
|
-
*/
|
|
29
|
-
doStream(params: DoGenerateParams): AsyncGenerator<StreamChunk>;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Model capabilities for UI feature flags
|
|
33
|
-
*/
|
|
34
|
-
interface ModelCapabilities {
|
|
35
|
-
/** Supports image inputs */
|
|
36
|
-
supportsVision: boolean;
|
|
37
|
-
/** Supports tool/function calling */
|
|
38
|
-
supportsTools: boolean;
|
|
39
|
-
/** Supports streaming responses */
|
|
40
|
-
supportsStreaming: boolean;
|
|
41
|
-
/** Supports JSON mode / structured output */
|
|
42
|
-
supportsJsonMode: boolean;
|
|
43
|
-
/** Supports extended thinking (Claude) */
|
|
44
|
-
supportsThinking: boolean;
|
|
45
|
-
/** Supports PDF document inputs */
|
|
46
|
-
supportsPDF: boolean;
|
|
47
|
-
/** Maximum context tokens */
|
|
48
|
-
maxTokens: number;
|
|
49
|
-
/** Supported image MIME types */
|
|
50
|
-
supportedImageTypes: string[];
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Default capabilities for unknown models
|
|
54
|
-
*/
|
|
55
|
-
declare const DEFAULT_CAPABILITIES: ModelCapabilities;
|
|
56
|
-
/**
|
|
57
|
-
* Core message types for LLM conversations
|
|
58
|
-
*/
|
|
59
|
-
type CoreMessage = SystemMessage | UserMessage | AssistantMessage | ToolMessage;
|
|
60
|
-
interface SystemMessage {
|
|
61
|
-
role: "system";
|
|
62
|
-
content: string;
|
|
63
|
-
}
|
|
64
|
-
interface UserMessage {
|
|
65
|
-
role: "user";
|
|
66
|
-
content: string | UserContentPart[];
|
|
67
|
-
}
|
|
68
|
-
interface AssistantMessage {
|
|
69
|
-
role: "assistant";
|
|
70
|
-
content: string | null;
|
|
71
|
-
toolCalls?: ToolCall$1[];
|
|
72
|
-
}
|
|
73
|
-
interface ToolMessage {
|
|
74
|
-
role: "tool";
|
|
75
|
-
toolCallId: string;
|
|
76
|
-
content: string;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Content parts for multimodal user messages
|
|
80
|
-
*/
|
|
81
|
-
type UserContentPart = TextPart | ImagePart | FilePart;
|
|
82
|
-
interface TextPart {
|
|
83
|
-
type: "text";
|
|
84
|
-
text: string;
|
|
85
|
-
}
|
|
86
|
-
interface ImagePart {
|
|
87
|
-
type: "image";
|
|
88
|
-
/** Base64 data or URL */
|
|
89
|
-
image: string | Uint8Array;
|
|
90
|
-
/** MIME type (e.g., 'image/png') */
|
|
91
|
-
mimeType?: string;
|
|
92
|
-
}
|
|
93
|
-
interface FilePart {
|
|
94
|
-
type: "file";
|
|
95
|
-
/** Base64 data or URL */
|
|
96
|
-
data: string;
|
|
97
|
-
/** MIME type (e.g., 'application/pdf') */
|
|
98
|
-
mimeType: string;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Tool definition with Zod schema support
|
|
102
|
-
*/
|
|
103
|
-
interface Tool<TParams = unknown, TResult = unknown> {
|
|
104
|
-
/** Tool description for the LLM */
|
|
105
|
-
description: string;
|
|
106
|
-
/** Zod schema for parameters */
|
|
107
|
-
parameters: z.ZodType<TParams>;
|
|
108
|
-
/** Execute function */
|
|
109
|
-
execute: (params: TParams, context: ToolContext$1) => Promise<TResult>;
|
|
110
|
-
/**
|
|
111
|
-
* Hide this tool's execution from the chat UI.
|
|
112
|
-
* When true, tool calls and results won't be displayed to the user,
|
|
113
|
-
* but the tool will still execute normally.
|
|
114
|
-
* @default false
|
|
115
|
-
*/
|
|
116
|
-
hidden?: boolean;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Context passed to tool execute function
|
|
120
|
-
*/
|
|
121
|
-
interface ToolContext$1 {
|
|
122
|
-
/** Abort signal for cancellation */
|
|
123
|
-
abortSignal?: AbortSignal;
|
|
124
|
-
/** Unique tool call ID */
|
|
125
|
-
toolCallId: string;
|
|
126
|
-
/** Optional: messages in conversation */
|
|
127
|
-
messages?: CoreMessage[];
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Tool call from LLM response
|
|
131
|
-
*/
|
|
132
|
-
interface ToolCall$1 {
|
|
133
|
-
/** Unique ID for this tool call */
|
|
134
|
-
id: string;
|
|
135
|
-
/** Tool name */
|
|
136
|
-
name: string;
|
|
137
|
-
/** Parsed arguments */
|
|
138
|
-
args: Record<string, unknown>;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Tool execution result
|
|
142
|
-
*/
|
|
143
|
-
interface ToolResult {
|
|
144
|
-
/** Tool call ID this result corresponds to */
|
|
145
|
-
toolCallId: string;
|
|
146
|
-
/** Result data (will be JSON stringified for LLM) */
|
|
147
|
-
result: unknown;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Parameters for model.doGenerate() and model.doStream()
|
|
151
|
-
*/
|
|
152
|
-
interface DoGenerateParams {
|
|
153
|
-
/** Messages to send to LLM */
|
|
154
|
-
messages: CoreMessage[];
|
|
155
|
-
/** Tools available to the LLM (already formatted for provider) */
|
|
156
|
-
tools?: unknown[];
|
|
157
|
-
/** Temperature (0-2) */
|
|
158
|
-
temperature?: number;
|
|
159
|
-
/** Maximum tokens to generate */
|
|
160
|
-
maxTokens?: number;
|
|
161
|
-
/** Abort signal */
|
|
162
|
-
signal?: AbortSignal;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Result from model.doGenerate()
|
|
166
|
-
*/
|
|
167
|
-
interface DoGenerateResult {
|
|
168
|
-
/** Generated text content */
|
|
169
|
-
text: string;
|
|
170
|
-
/** Tool calls requested by the LLM */
|
|
171
|
-
toolCalls: ToolCall$1[];
|
|
172
|
-
/** Why generation stopped */
|
|
173
|
-
finishReason: FinishReason;
|
|
174
|
-
/** Token usage */
|
|
175
|
-
usage: TokenUsage;
|
|
176
|
-
/** Raw provider response (for debugging) */
|
|
177
|
-
rawResponse?: unknown;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Finish reason for generation
|
|
181
|
-
*/
|
|
182
|
-
type FinishReason = "stop" | "length" | "tool-calls" | "content-filter" | "error" | "unknown";
|
|
183
|
-
/**
|
|
184
|
-
* Token usage statistics
|
|
185
|
-
*/
|
|
186
|
-
interface TokenUsage {
|
|
187
|
-
promptTokens: number;
|
|
188
|
-
completionTokens: number;
|
|
189
|
-
totalTokens: number;
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Stream chunk from model.doStream()
|
|
193
|
-
*/
|
|
194
|
-
type StreamChunk = TextDeltaChunk | ToolCallChunk | ToolResultChunk | FinishChunk | ErrorChunk;
|
|
195
|
-
interface TextDeltaChunk {
|
|
196
|
-
type: "text-delta";
|
|
197
|
-
text: string;
|
|
198
|
-
}
|
|
199
|
-
interface ToolCallChunk {
|
|
200
|
-
type: "tool-call";
|
|
201
|
-
toolCall: ToolCall$1;
|
|
202
|
-
}
|
|
203
|
-
interface ToolResultChunk {
|
|
204
|
-
type: "tool-result";
|
|
205
|
-
toolCallId: string;
|
|
206
|
-
result: unknown;
|
|
207
|
-
}
|
|
208
|
-
interface FinishChunk {
|
|
209
|
-
type: "finish";
|
|
210
|
-
finishReason: FinishReason;
|
|
211
|
-
usage?: TokenUsage;
|
|
212
|
-
}
|
|
213
|
-
interface ErrorChunk {
|
|
214
|
-
type: "error";
|
|
215
|
-
error: Error;
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Parameters for generateText()
|
|
219
|
-
*/
|
|
220
|
-
interface GenerateTextParams {
|
|
221
|
-
/** Language model to use */
|
|
222
|
-
model: LanguageModel;
|
|
223
|
-
/** Simple prompt (converted to user message) */
|
|
224
|
-
prompt?: string;
|
|
225
|
-
/** System prompt */
|
|
226
|
-
system?: string;
|
|
227
|
-
/** Full message history */
|
|
228
|
-
messages?: CoreMessage[];
|
|
229
|
-
/** Tools available to the LLM */
|
|
230
|
-
tools?: Record<string, Tool>;
|
|
231
|
-
/** Maximum agentic steps (tool call loops) */
|
|
232
|
-
maxSteps?: number;
|
|
233
|
-
/** Temperature (0-2) */
|
|
234
|
-
temperature?: number;
|
|
235
|
-
/** Maximum tokens to generate */
|
|
236
|
-
maxTokens?: number;
|
|
237
|
-
/** Abort signal */
|
|
238
|
-
signal?: AbortSignal;
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Result from generateText()
|
|
242
|
-
*/
|
|
243
|
-
interface GenerateTextResult {
|
|
244
|
-
/** Final text output */
|
|
245
|
-
text: string;
|
|
246
|
-
/** Token usage */
|
|
247
|
-
usage: TokenUsage;
|
|
248
|
-
/** Why generation stopped */
|
|
249
|
-
finishReason: FinishReason;
|
|
250
|
-
/** All steps taken (for agentic workflows) */
|
|
251
|
-
steps: GenerateStep[];
|
|
252
|
-
/** All tool calls made across all steps */
|
|
253
|
-
toolCalls: ToolCall$1[];
|
|
254
|
-
/** All tool results across all steps */
|
|
255
|
-
toolResults: ToolResult[];
|
|
256
|
-
/** Final message list including tool interactions */
|
|
257
|
-
response: {
|
|
258
|
-
messages: CoreMessage[];
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* A single step in the generation process
|
|
263
|
-
*/
|
|
264
|
-
interface GenerateStep {
|
|
265
|
-
/** Text generated in this step */
|
|
266
|
-
text: string;
|
|
267
|
-
/** Tool calls made in this step */
|
|
268
|
-
toolCalls: ToolCall$1[];
|
|
269
|
-
/** Tool results from this step */
|
|
270
|
-
toolResults: ToolResult[];
|
|
271
|
-
/** Finish reason for this step */
|
|
272
|
-
finishReason: FinishReason;
|
|
273
|
-
/** Token usage for this step */
|
|
274
|
-
usage: TokenUsage;
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Parameters for streamText() - same as generateText
|
|
278
|
-
*/
|
|
279
|
-
type StreamTextParams = GenerateTextParams;
|
|
280
|
-
/**
|
|
281
|
-
* Result from streamText()
|
|
282
|
-
*/
|
|
283
|
-
interface StreamTextResult {
|
|
284
|
-
/** Async iterable of text chunks only */
|
|
285
|
-
textStream: AsyncIterable<string>;
|
|
286
|
-
/** Async iterable of all stream parts */
|
|
287
|
-
fullStream: AsyncIterable<StreamPart>;
|
|
288
|
-
/** Promise that resolves to full text when complete */
|
|
289
|
-
readonly text: Promise<string>;
|
|
290
|
-
/** Promise that resolves to usage when complete */
|
|
291
|
-
readonly usage: Promise<TokenUsage>;
|
|
292
|
-
/** Promise that resolves to finish reason when complete */
|
|
293
|
-
readonly finishReason: Promise<FinishReason>;
|
|
294
|
-
/** Convert to plain text streaming Response */
|
|
295
|
-
toTextStreamResponse(options?: ResponseOptions): Response;
|
|
296
|
-
/** Convert to data stream Response (SSE with tool calls) */
|
|
297
|
-
toDataStreamResponse(options?: ResponseOptions): Response;
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Stream part for fullStream
|
|
301
|
-
*/
|
|
302
|
-
type StreamPart = {
|
|
303
|
-
type: "text-delta";
|
|
304
|
-
text: string;
|
|
305
|
-
} | {
|
|
306
|
-
type: "tool-call-start";
|
|
307
|
-
toolCallId: string;
|
|
308
|
-
toolName: string;
|
|
309
|
-
} | {
|
|
310
|
-
type: "tool-call-delta";
|
|
311
|
-
toolCallId: string;
|
|
312
|
-
argsText: string;
|
|
313
|
-
} | {
|
|
314
|
-
type: "tool-call-complete";
|
|
315
|
-
toolCall: ToolCall$1;
|
|
316
|
-
} | {
|
|
317
|
-
type: "tool-result";
|
|
318
|
-
toolCallId: string;
|
|
319
|
-
result: unknown;
|
|
320
|
-
} | {
|
|
321
|
-
type: "step-start";
|
|
322
|
-
step: number;
|
|
323
|
-
} | {
|
|
324
|
-
type: "step-finish";
|
|
325
|
-
step: number;
|
|
326
|
-
finishReason: FinishReason;
|
|
327
|
-
} | {
|
|
328
|
-
type: "finish";
|
|
329
|
-
finishReason: FinishReason;
|
|
330
|
-
usage: TokenUsage;
|
|
331
|
-
} | {
|
|
332
|
-
type: "error";
|
|
333
|
-
error: Error;
|
|
334
|
-
};
|
|
335
|
-
/**
|
|
336
|
-
* Options for Response helpers
|
|
337
|
-
*/
|
|
338
|
-
interface ResponseOptions {
|
|
339
|
-
/** Additional headers */
|
|
340
|
-
headers?: Record<string, string>;
|
|
341
|
-
/** Response status (default: 200) */
|
|
342
|
-
status?: number;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* Stream event types for llm-sdk
|
|
347
|
-
* These types are used internally by the SDK for streaming responses
|
|
348
|
-
*/
|
|
349
|
-
/**
|
|
350
|
-
* Stream event types
|
|
351
|
-
*/
|
|
352
|
-
type StreamEventType = "message:start" | "message:delta" | "message:end" | "thinking:start" | "thinking:delta" | "thinking:end" | "action:start" | "action:args" | "action:end" | "tool_calls" | "tool:result" | "citation" | "loop:iteration" | "loop:complete" | "error" | "done";
|
|
353
|
-
/**
|
|
354
|
-
* Base event interface
|
|
355
|
-
*/
|
|
356
|
-
interface BaseEvent {
|
|
357
|
-
type: StreamEventType;
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* Message started streaming
|
|
361
|
-
*/
|
|
362
|
-
interface MessageStartEvent extends BaseEvent {
|
|
363
|
-
type: "message:start";
|
|
364
|
-
id: string;
|
|
365
|
-
}
|
|
366
|
-
/**
|
|
367
|
-
* Message content delta (incremental update)
|
|
368
|
-
*/
|
|
369
|
-
interface MessageDeltaEvent extends BaseEvent {
|
|
370
|
-
type: "message:delta";
|
|
371
|
-
content: string;
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
* Message finished streaming
|
|
375
|
-
*/
|
|
376
|
-
interface MessageEndEvent extends BaseEvent {
|
|
377
|
-
type: "message:end";
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* Thinking/reasoning started (for models like Claude, DeepSeek)
|
|
381
|
-
*/
|
|
382
|
-
interface ThinkingStartEvent extends BaseEvent {
|
|
383
|
-
type: "thinking:start";
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Thinking content delta
|
|
387
|
-
*/
|
|
388
|
-
interface ThinkingDeltaEvent extends BaseEvent {
|
|
389
|
-
type: "thinking:delta";
|
|
390
|
-
content: string;
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Thinking finished
|
|
394
|
-
*/
|
|
395
|
-
interface ThinkingEndEvent extends BaseEvent {
|
|
396
|
-
type: "thinking:end";
|
|
397
|
-
}
|
|
398
|
-
/**
|
|
399
|
-
* Action/tool execution started
|
|
400
|
-
*/
|
|
401
|
-
interface ActionStartEvent extends BaseEvent {
|
|
402
|
-
type: "action:start";
|
|
403
|
-
id: string;
|
|
404
|
-
name: string;
|
|
405
|
-
/** Whether this tool should be hidden from UI */
|
|
406
|
-
hidden?: boolean;
|
|
407
|
-
}
|
|
408
|
-
/**
|
|
409
|
-
* Action arguments (streaming)
|
|
410
|
-
*/
|
|
411
|
-
interface ActionArgsEvent extends BaseEvent {
|
|
412
|
-
type: "action:args";
|
|
413
|
-
id: string;
|
|
414
|
-
args: string;
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
* Action execution completed
|
|
418
|
-
*/
|
|
419
|
-
interface ActionEndEvent extends BaseEvent {
|
|
420
|
-
type: "action:end";
|
|
421
|
-
id: string;
|
|
422
|
-
name?: string;
|
|
423
|
-
result?: unknown;
|
|
424
|
-
error?: string;
|
|
425
|
-
}
|
|
426
|
-
/**
|
|
427
|
-
* Error event
|
|
428
|
-
*/
|
|
429
|
-
interface ErrorEvent extends BaseEvent {
|
|
430
|
-
type: "error";
|
|
431
|
-
message: string;
|
|
432
|
-
code?: string;
|
|
433
|
-
}
|
|
434
|
-
/**
|
|
435
|
-
* Tool call information
|
|
436
|
-
*/
|
|
437
|
-
interface ToolCallInfo {
|
|
438
|
-
id: string;
|
|
439
|
-
name: string;
|
|
440
|
-
args: Record<string, unknown>;
|
|
441
|
-
/** Whether this tool should be hidden from UI */
|
|
442
|
-
hidden?: boolean;
|
|
443
|
-
}
|
|
444
|
-
/**
|
|
445
|
-
* Assistant message with tool calls
|
|
446
|
-
*/
|
|
447
|
-
interface AssistantToolMessage {
|
|
448
|
-
role: "assistant";
|
|
449
|
-
content: string | null;
|
|
450
|
-
tool_calls: Array<{
|
|
451
|
-
id: string;
|
|
452
|
-
type: "function";
|
|
453
|
-
function: {
|
|
454
|
-
name: string;
|
|
455
|
-
arguments: string;
|
|
456
|
-
};
|
|
457
|
-
}>;
|
|
458
|
-
}
|
|
459
|
-
/**
|
|
460
|
-
* Tool calls event - client should execute and send results
|
|
461
|
-
*/
|
|
462
|
-
interface ToolCallsEvent extends BaseEvent {
|
|
463
|
-
type: "tool_calls";
|
|
464
|
-
toolCalls: ToolCallInfo[];
|
|
465
|
-
assistantMessage: AssistantToolMessage;
|
|
466
|
-
}
|
|
467
|
-
/**
|
|
468
|
-
* Tool result event
|
|
469
|
-
*/
|
|
470
|
-
interface ToolResultEvent extends BaseEvent {
|
|
471
|
-
type: "tool:result";
|
|
472
|
-
id: string;
|
|
473
|
-
name: string;
|
|
474
|
-
result: ToolResponse;
|
|
475
|
-
}
|
|
476
|
-
/**
|
|
477
|
-
* Loop iteration event
|
|
478
|
-
*/
|
|
479
|
-
interface LoopIterationEvent extends BaseEvent {
|
|
480
|
-
type: "loop:iteration";
|
|
481
|
-
iteration: number;
|
|
482
|
-
maxIterations: number;
|
|
483
|
-
}
|
|
484
|
-
/**
|
|
485
|
-
* Loop complete event
|
|
486
|
-
*/
|
|
487
|
-
interface LoopCompleteEvent extends BaseEvent {
|
|
488
|
-
type: "loop:complete";
|
|
489
|
-
iterations: number;
|
|
490
|
-
aborted?: boolean;
|
|
491
|
-
maxIterationsReached?: boolean;
|
|
492
|
-
}
|
|
493
|
-
/**
|
|
494
|
-
* Citation from web search (unified format for all providers)
|
|
495
|
-
*/
|
|
496
|
-
interface Citation {
|
|
497
|
-
/** Unique citation index (1-based) */
|
|
498
|
-
index: number;
|
|
499
|
-
/** Source URL */
|
|
500
|
-
url: string;
|
|
501
|
-
/** Page title */
|
|
502
|
-
title: string;
|
|
503
|
-
/** Cited text snippet (optional) */
|
|
504
|
-
citedText?: string;
|
|
505
|
-
/** Source domain (extracted from URL) */
|
|
506
|
-
domain?: string;
|
|
507
|
-
/** Favicon URL (generated from domain) */
|
|
508
|
-
favicon?: string;
|
|
509
|
-
}
|
|
510
|
-
/**
|
|
511
|
-
* Citation event - web search returned citations
|
|
512
|
-
*/
|
|
513
|
-
interface CitationEvent extends BaseEvent {
|
|
514
|
-
type: "citation";
|
|
515
|
-
citations: Citation[];
|
|
516
|
-
}
|
|
517
|
-
/**
|
|
518
|
-
* Message format for done event (API format with snake_case)
|
|
519
|
-
*/
|
|
520
|
-
interface DoneEventMessage {
|
|
521
|
-
role: "assistant" | "tool";
|
|
522
|
-
content: string | null;
|
|
523
|
-
tool_calls?: Array<{
|
|
524
|
-
id: string;
|
|
525
|
-
type: "function";
|
|
526
|
-
function: {
|
|
527
|
-
name: string;
|
|
528
|
-
arguments: string;
|
|
529
|
-
};
|
|
530
|
-
}>;
|
|
531
|
-
tool_call_id?: string;
|
|
532
|
-
}
|
|
533
|
-
/**
|
|
534
|
-
* Token usage (snake_case for API compatibility)
|
|
535
|
-
*/
|
|
536
|
-
interface TokenUsageRaw {
|
|
537
|
-
prompt_tokens: number;
|
|
538
|
-
completion_tokens: number;
|
|
539
|
-
total_tokens?: number;
|
|
540
|
-
}
|
|
541
|
-
/**
|
|
542
|
-
* Stream completed
|
|
543
|
-
*/
|
|
544
|
-
interface DoneEvent extends BaseEvent {
|
|
545
|
-
type: "done";
|
|
546
|
-
requiresAction?: boolean;
|
|
547
|
-
messages?: DoneEventMessage[];
|
|
548
|
-
/** Token usage (server-side only, stripped before sending to client) */
|
|
549
|
-
usage?: TokenUsageRaw;
|
|
550
|
-
}
|
|
551
|
-
/**
|
|
552
|
-
* Union of all stream events
|
|
553
|
-
*/
|
|
554
|
-
type StreamEvent = MessageStartEvent | MessageDeltaEvent | MessageEndEvent | ThinkingStartEvent | ThinkingDeltaEvent | ThinkingEndEvent | ActionStartEvent | ActionArgsEvent | ActionEndEvent | ToolCallsEvent | ToolResultEvent | CitationEvent | LoopIterationEvent | LoopCompleteEvent | ErrorEvent | DoneEvent;
|
|
555
|
-
/**
|
|
556
|
-
* LLM configuration
|
|
557
|
-
*/
|
|
558
|
-
interface LLMConfig {
|
|
559
|
-
temperature?: number;
|
|
560
|
-
maxTokens?: number;
|
|
561
|
-
}
|
|
562
|
-
/**
|
|
563
|
-
* Tool call format (OpenAI style)
|
|
564
|
-
*/
|
|
565
|
-
interface ToolCall {
|
|
566
|
-
id: string;
|
|
567
|
-
type: "function";
|
|
568
|
-
function: {
|
|
569
|
-
name: string;
|
|
570
|
-
arguments: string;
|
|
571
|
-
};
|
|
572
|
-
}
|
|
573
|
-
/**
|
|
574
|
-
* Message role
|
|
575
|
-
*/
|
|
576
|
-
type MessageRole = "system" | "user" | "assistant" | "tool";
|
|
577
|
-
/**
|
|
578
|
-
* Message attachment
|
|
579
|
-
*/
|
|
580
|
-
interface MessageAttachment {
|
|
581
|
-
type: "image" | "file" | "audio" | "video";
|
|
582
|
-
data?: string;
|
|
583
|
-
url?: string;
|
|
584
|
-
mimeType: string;
|
|
585
|
-
filename?: string;
|
|
586
|
-
}
|
|
587
|
-
/**
|
|
588
|
-
* Message metadata
|
|
589
|
-
*/
|
|
590
|
-
interface MessageMetadata {
|
|
591
|
-
thinking?: string;
|
|
592
|
-
attachments?: MessageAttachment[];
|
|
593
|
-
toolName?: string;
|
|
594
|
-
[key: string]: unknown;
|
|
595
|
-
}
|
|
596
|
-
/**
|
|
597
|
-
* Message type (simplified for llm-sdk)
|
|
598
|
-
*/
|
|
599
|
-
interface Message {
|
|
600
|
-
id: string;
|
|
601
|
-
thread_id?: string;
|
|
602
|
-
role: MessageRole;
|
|
603
|
-
content: string | null;
|
|
604
|
-
tool_calls?: ToolCall[];
|
|
605
|
-
tool_call_id?: string;
|
|
606
|
-
metadata?: MessageMetadata;
|
|
607
|
-
created_at?: Date;
|
|
608
|
-
}
|
|
609
|
-
/**
|
|
610
|
-
* Action parameter definition
|
|
611
|
-
*/
|
|
612
|
-
interface ActionParameter {
|
|
613
|
-
type: string;
|
|
614
|
-
description?: string;
|
|
615
|
-
required?: boolean;
|
|
616
|
-
enum?: string[];
|
|
617
|
-
items?: ActionParameter;
|
|
618
|
-
properties?: Record<string, ActionParameter>;
|
|
619
|
-
}
|
|
620
|
-
/**
|
|
621
|
-
* Action definition for tool calling
|
|
622
|
-
*/
|
|
623
|
-
interface ActionDefinition<TParams = Record<string, unknown>> {
|
|
624
|
-
name: string;
|
|
625
|
-
description: string;
|
|
626
|
-
parameters?: Record<string, ActionParameter>;
|
|
627
|
-
handler: (params: TParams) => unknown | Promise<unknown>;
|
|
628
|
-
}
|
|
629
|
-
/**
|
|
630
|
-
* Tool location (server or client)
|
|
631
|
-
*/
|
|
632
|
-
type ToolLocation = "server" | "client";
|
|
633
|
-
/**
|
|
634
|
-
* Tool execution status
|
|
635
|
-
*/
|
|
636
|
-
type ToolExecutionStatus = "pending" | "executing" | "completed" | "error";
|
|
637
|
-
/**
|
|
638
|
-
* Tool response
|
|
639
|
-
*/
|
|
640
|
-
interface ToolResponse<T = unknown> {
|
|
641
|
-
success: boolean;
|
|
642
|
-
data?: T;
|
|
643
|
-
error?: string;
|
|
644
|
-
/** Internal: AI response mode override */
|
|
645
|
-
_aiResponseMode?: AIResponseMode;
|
|
646
|
-
/** Internal: AI content for multimodal response (images, etc.) */
|
|
647
|
-
_aiContent?: AIContent[];
|
|
648
|
-
/** Internal: AI context string override */
|
|
649
|
-
_aiContext?: string;
|
|
650
|
-
}
|
|
651
|
-
/**
|
|
652
|
-
* Tool context passed to handlers
|
|
653
|
-
*/
|
|
654
|
-
interface ToolContext {
|
|
655
|
-
userId?: string;
|
|
656
|
-
threadId?: string;
|
|
657
|
-
[key: string]: unknown;
|
|
658
|
-
}
|
|
659
|
-
/**
|
|
660
|
-
* AI response mode for tool results
|
|
661
|
-
*/
|
|
662
|
-
type AIResponseMode = "none" | "brief" | "full";
|
|
663
|
-
/**
|
|
664
|
-
* AI content structure
|
|
665
|
-
*/
|
|
666
|
-
interface AIContent {
|
|
667
|
-
type?: "text" | "image";
|
|
668
|
-
text?: string;
|
|
669
|
-
mediaType?: string;
|
|
670
|
-
data?: string;
|
|
671
|
-
summary?: string;
|
|
672
|
-
details?: string;
|
|
673
|
-
}
|
|
674
|
-
/**
|
|
675
|
-
* JSON Schema for tool input
|
|
676
|
-
*/
|
|
677
|
-
interface ToolInputSchema {
|
|
678
|
-
type: "object";
|
|
679
|
-
properties?: Record<string, unknown>;
|
|
680
|
-
required?: string[];
|
|
681
|
-
}
|
|
682
|
-
/**
|
|
683
|
-
* Tool definition
|
|
684
|
-
*/
|
|
685
|
-
interface ToolDefinition<TParams = Record<string, unknown>> {
|
|
686
|
-
name: string;
|
|
687
|
-
description: string;
|
|
688
|
-
location: ToolLocation;
|
|
689
|
-
/** Optional logical category for tool search and selective loading. */
|
|
690
|
-
category?: string;
|
|
691
|
-
/** Optional group label for related tools. */
|
|
692
|
-
group?: string;
|
|
693
|
-
title?: string | ((args: TParams) => string);
|
|
694
|
-
inputSchema?: ToolInputSchema;
|
|
695
|
-
handler?: (params: TParams, context?: ToolContext) => unknown | Promise<unknown>;
|
|
696
|
-
render?: (props: unknown) => unknown;
|
|
697
|
-
available?: boolean;
|
|
698
|
-
/**
|
|
699
|
-
* Hide this tool's execution from the chat UI.
|
|
700
|
-
* When true, tool calls and results won't be displayed to the user,
|
|
701
|
-
* but the tool will still execute normally.
|
|
702
|
-
* @default false
|
|
703
|
-
*/
|
|
704
|
-
hidden?: boolean;
|
|
705
|
-
needsApproval?: boolean;
|
|
706
|
-
approvalMessage?: string | ((params: TParams) => string);
|
|
707
|
-
/** AI response mode for this tool (none, brief, full) */
|
|
708
|
-
aiResponseMode?: AIResponseMode;
|
|
709
|
-
/** AI context string or function to generate context */
|
|
710
|
-
aiContext?: string | ((result: ToolResponse, args: Record<string, unknown>) => string);
|
|
711
|
-
/** Hint that this tool should be loaded lazily when dynamic selection is active. */
|
|
712
|
-
deferLoading?: boolean;
|
|
713
|
-
/** Named profiles this tool belongs to (for example "coding" or "search"). */
|
|
714
|
-
profiles?: string[];
|
|
715
|
-
/** Extra keywords used by lightweight tool search/ranking. */
|
|
716
|
-
searchKeywords?: string[];
|
|
717
|
-
}
|
|
718
|
-
interface ToolProfile {
|
|
719
|
-
include?: string[];
|
|
720
|
-
exclude?: string[];
|
|
721
|
-
}
|
|
722
|
-
interface OpenAIToolSelectionHints {
|
|
723
|
-
/**
|
|
724
|
-
* "single" forces the selected tool when exactly one tool remains after selection.
|
|
725
|
-
* Otherwise the adapter falls back to automatic tool choice.
|
|
726
|
-
*/
|
|
727
|
-
toolChoice?: "auto" | "required" | "single";
|
|
728
|
-
/** Set false to disable parallel tool calls on OpenAI-compatible providers. */
|
|
729
|
-
parallelToolCalls?: boolean;
|
|
730
|
-
}
|
|
731
|
-
interface AnthropicToolSelectionHints {
|
|
732
|
-
/**
|
|
733
|
-
* "single" forces the selected tool when exactly one tool remains after selection.
|
|
734
|
-
* Otherwise the adapter falls back to Anthropic's automatic tool choice.
|
|
735
|
-
*/
|
|
736
|
-
toolChoice?: "auto" | "any" | "single";
|
|
737
|
-
/** Disable parallel tool use when supported by the Anthropic API. */
|
|
738
|
-
disableParallelToolUse?: boolean;
|
|
739
|
-
}
|
|
740
|
-
interface ToolNativeProviderHints {
|
|
741
|
-
openai?: OpenAIToolSelectionHints;
|
|
742
|
-
anthropic?: AnthropicToolSelectionHints;
|
|
743
|
-
}
|
|
744
|
-
interface OpenAIProviderToolOptions {
|
|
745
|
-
toolChoice?: "auto" | "required" | {
|
|
746
|
-
type: "function";
|
|
747
|
-
name: string;
|
|
748
|
-
};
|
|
749
|
-
parallelToolCalls?: boolean;
|
|
750
|
-
nativeToolSearch?: {
|
|
751
|
-
enabled: boolean;
|
|
752
|
-
useResponsesApi?: boolean;
|
|
753
|
-
};
|
|
754
|
-
}
|
|
755
|
-
interface AnthropicProviderToolOptions {
|
|
756
|
-
toolChoice?: "auto" | "any" | {
|
|
757
|
-
type: "tool";
|
|
758
|
-
name: string;
|
|
759
|
-
};
|
|
760
|
-
disableParallelToolUse?: boolean;
|
|
761
|
-
nativeToolSearch?: {
|
|
762
|
-
enabled: boolean;
|
|
763
|
-
variant: "bm25" | "regex";
|
|
764
|
-
};
|
|
765
|
-
}
|
|
766
|
-
interface ProviderToolRuntimeOptions {
|
|
767
|
-
openai?: OpenAIProviderToolOptions;
|
|
768
|
-
anthropic?: AnthropicProviderToolOptions;
|
|
769
|
-
}
|
|
770
|
-
/**
|
|
771
|
-
* Web search configuration for native provider search
|
|
772
|
-
*
|
|
773
|
-
* Enables native web search for supported providers:
|
|
774
|
-
* - Anthropic: Uses Claude's built-in web search tool
|
|
775
|
-
* - OpenAI: Uses GPT's web search preview
|
|
776
|
-
* - Google: Uses Gemini's Google Search grounding
|
|
777
|
-
*
|
|
778
|
-
* @example
|
|
779
|
-
* ```typescript
|
|
780
|
-
* const runtime = createRuntime({
|
|
781
|
-
* provider: createAnthropic({ apiKey: '...' }),
|
|
782
|
-
* model: 'claude-sonnet-4-20250514',
|
|
783
|
-
* webSearch: true, // Enable with defaults
|
|
784
|
-
* });
|
|
785
|
-
*
|
|
786
|
-
* // Or with configuration
|
|
787
|
-
* const runtime = createRuntime({
|
|
788
|
-
* provider: createOpenAI({ apiKey: '...' }),
|
|
789
|
-
* model: 'gpt-4o',
|
|
790
|
-
* webSearch: {
|
|
791
|
-
* maxUses: 5,
|
|
792
|
-
* allowedDomains: ['docs.anthropic.com', 'openai.com'],
|
|
793
|
-
* },
|
|
794
|
-
* });
|
|
795
|
-
* ```
|
|
796
|
-
*/
|
|
797
|
-
interface WebSearchConfig {
|
|
798
|
-
/** Maximum number of search uses per request (default: unlimited) */
|
|
799
|
-
maxUses?: number;
|
|
800
|
-
/** Only search these domains (provider-specific support) */
|
|
801
|
-
allowedDomains?: string[];
|
|
802
|
-
/** Exclude these domains from search (provider-specific support) */
|
|
803
|
-
blockedDomains?: string[];
|
|
804
|
-
/** User location for localized results (Anthropic only) */
|
|
805
|
-
userLocation?: {
|
|
806
|
-
type: "approximate";
|
|
807
|
-
city?: string;
|
|
808
|
-
region?: string;
|
|
809
|
-
country?: string;
|
|
810
|
-
timezone?: string;
|
|
811
|
-
};
|
|
812
|
-
}
|
|
813
|
-
/**
|
|
814
|
-
* Unified tool call format
|
|
815
|
-
*/
|
|
816
|
-
interface UnifiedToolCall {
|
|
817
|
-
id: string;
|
|
818
|
-
name: string;
|
|
819
|
-
input: Record<string, unknown>;
|
|
820
|
-
}
|
|
821
|
-
/**
|
|
822
|
-
* Unified tool result format
|
|
823
|
-
*/
|
|
824
|
-
interface UnifiedToolResult {
|
|
825
|
-
toolCallId: string;
|
|
826
|
-
content: string;
|
|
827
|
-
success: boolean;
|
|
828
|
-
error?: string;
|
|
829
|
-
}
|
|
830
|
-
/**
|
|
831
|
-
* Tool execution state
|
|
832
|
-
*/
|
|
833
|
-
interface ToolExecution {
|
|
834
|
-
id: string;
|
|
835
|
-
name: string;
|
|
836
|
-
args: Record<string, unknown>;
|
|
837
|
-
status: ToolExecutionStatus;
|
|
838
|
-
result?: ToolResponse;
|
|
839
|
-
}
|
|
840
|
-
/**
|
|
841
|
-
* Knowledge base provider
|
|
842
|
-
*/
|
|
843
|
-
type KnowledgeBaseProvider = "pinecone" | "qdrant" | "weaviate" | "custom";
|
|
844
|
-
/**
|
|
845
|
-
* Knowledge base configuration
|
|
846
|
-
*/
|
|
847
|
-
interface KnowledgeBaseConfig {
|
|
848
|
-
id: string;
|
|
849
|
-
name?: string;
|
|
850
|
-
provider: KnowledgeBaseProvider;
|
|
851
|
-
apiKey?: string;
|
|
852
|
-
index?: string;
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
/**
|
|
856
|
-
* Request-level LLM configuration overrides
|
|
857
|
-
*/
|
|
858
|
-
interface RequestLLMConfig {
|
|
859
|
-
model?: string;
|
|
860
|
-
temperature?: number;
|
|
861
|
-
maxTokens?: number;
|
|
862
|
-
}
|
|
863
|
-
/**
|
|
864
|
-
* Chat completion request
|
|
865
|
-
*/
|
|
866
|
-
interface ChatCompletionRequest {
|
|
867
|
-
/** Conversation messages */
|
|
868
|
-
messages: Message[];
|
|
869
|
-
/**
|
|
870
|
-
* Raw provider-formatted messages (for agent loop with tool calls)
|
|
871
|
-
* When provided, these are used instead of converting from Message[]
|
|
872
|
-
* This allows passing messages with tool_calls and tool role
|
|
873
|
-
*/
|
|
874
|
-
rawMessages?: Array<Record<string, unknown>>;
|
|
875
|
-
/** Available actions/tools */
|
|
876
|
-
actions?: ActionDefinition[];
|
|
877
|
-
/** Full tool definitions for provider-native tool search / deferred loading paths. */
|
|
878
|
-
toolDefinitions?: ToolDefinition[];
|
|
879
|
-
/** System prompt */
|
|
880
|
-
systemPrompt?: string;
|
|
881
|
-
/** LLM configuration overrides */
|
|
882
|
-
config?: RequestLLMConfig;
|
|
883
|
-
/** Abort signal for cancellation */
|
|
884
|
-
signal?: AbortSignal;
|
|
885
|
-
/**
|
|
886
|
-
* Enable native web search for the provider.
|
|
887
|
-
* When true or configured, the provider's native search is enabled.
|
|
888
|
-
*/
|
|
889
|
-
webSearch?: boolean | WebSearchConfig;
|
|
890
|
-
/** Optional provider-specific tool policy hints derived from runtime selection. */
|
|
891
|
-
providerToolOptions?: ProviderToolRuntimeOptions;
|
|
892
|
-
/** Enable adapter-level provider payload logging. */
|
|
893
|
-
debug?: boolean;
|
|
894
|
-
}
|
|
895
|
-
/**
|
|
896
|
-
* Non-streaming completion result
|
|
897
|
-
*/
|
|
898
|
-
interface CompletionResult {
|
|
899
|
-
/** Text content */
|
|
900
|
-
content: string;
|
|
901
|
-
/** Tool calls */
|
|
902
|
-
toolCalls: Array<{
|
|
903
|
-
id: string;
|
|
904
|
-
name: string;
|
|
905
|
-
args: Record<string, unknown>;
|
|
906
|
-
}>;
|
|
907
|
-
/** Thinking content (if extended thinking enabled) */
|
|
908
|
-
thinking?: string;
|
|
909
|
-
/** Token usage for billing/tracking */
|
|
910
|
-
usage?: TokenUsage;
|
|
911
|
-
/** Raw provider response for debugging */
|
|
912
|
-
rawResponse: Record<string, unknown>;
|
|
913
|
-
}
|
|
914
|
-
/**
|
|
915
|
-
* Base LLM adapter interface
|
|
916
|
-
*/
|
|
917
|
-
interface LLMAdapter {
|
|
918
|
-
/** Provider name */
|
|
919
|
-
readonly provider: string;
|
|
920
|
-
/** Model name */
|
|
921
|
-
readonly model: string;
|
|
922
|
-
/**
|
|
923
|
-
* Stream a chat completion
|
|
924
|
-
*/
|
|
925
|
-
stream(request: ChatCompletionRequest): AsyncGenerator<StreamEvent>;
|
|
926
|
-
/**
|
|
927
|
-
* Non-streaming chat completion (for debugging/comparison)
|
|
928
|
-
*/
|
|
929
|
-
complete?(request: ChatCompletionRequest): Promise<CompletionResult>;
|
|
930
|
-
}
|
|
931
|
-
/**
|
|
932
|
-
* Adapter factory function type
|
|
933
|
-
*/
|
|
934
|
-
type AdapterFactory = (config: LLMConfig) => LLMAdapter;
|
|
935
|
-
/**
|
|
936
|
-
* Convert messages to provider format (simple text only)
|
|
937
|
-
*/
|
|
938
|
-
declare function formatMessages(messages: Message[], systemPrompt?: string): Array<{
|
|
939
|
-
role: string;
|
|
940
|
-
content: string;
|
|
941
|
-
}>;
|
|
942
|
-
/**
|
|
943
|
-
* Convert actions to OpenAI tool format
|
|
944
|
-
*/
|
|
945
|
-
declare function formatTools(actions: ActionDefinition[]): Array<{
|
|
946
|
-
type: "function";
|
|
947
|
-
function: {
|
|
948
|
-
name: string;
|
|
949
|
-
description: string;
|
|
950
|
-
parameters: object;
|
|
951
|
-
};
|
|
952
|
-
}>;
|
|
953
|
-
/**
|
|
954
|
-
* Content block types for multimodal messages
|
|
955
|
-
*/
|
|
956
|
-
type AnthropicContentBlock = {
|
|
957
|
-
type: "text";
|
|
958
|
-
text: string;
|
|
959
|
-
} | {
|
|
960
|
-
type: "image";
|
|
961
|
-
source: {
|
|
962
|
-
type: "base64";
|
|
963
|
-
media_type: string;
|
|
964
|
-
data: string;
|
|
965
|
-
} | {
|
|
966
|
-
type: "url";
|
|
967
|
-
url: string;
|
|
968
|
-
};
|
|
969
|
-
} | {
|
|
970
|
-
type: "document";
|
|
971
|
-
source: {
|
|
972
|
-
type: "base64";
|
|
973
|
-
media_type: string;
|
|
974
|
-
data: string;
|
|
975
|
-
} | {
|
|
976
|
-
type: "url";
|
|
977
|
-
url: string;
|
|
978
|
-
};
|
|
979
|
-
};
|
|
980
|
-
type OpenAIContentBlock = {
|
|
981
|
-
type: "text";
|
|
982
|
-
text: string;
|
|
983
|
-
} | {
|
|
984
|
-
type: "image_url";
|
|
985
|
-
image_url: {
|
|
986
|
-
url: string;
|
|
987
|
-
detail?: "low" | "high" | "auto";
|
|
988
|
-
};
|
|
989
|
-
};
|
|
990
|
-
/**
|
|
991
|
-
* Check if a message has image attachments
|
|
992
|
-
* Supports both new format (metadata.attachments) and legacy (attachments)
|
|
993
|
-
*/
|
|
994
|
-
declare function hasImageAttachments(message: Message): boolean;
|
|
995
|
-
/**
|
|
996
|
-
* Check if a message has media attachments (images or PDFs)
|
|
997
|
-
*/
|
|
998
|
-
declare function hasMediaAttachments(message: Message): boolean;
|
|
999
|
-
/**
|
|
1000
|
-
* Convert MessageAttachment to Anthropic image content block
|
|
1001
|
-
*
|
|
1002
|
-
* Anthropic format:
|
|
1003
|
-
* {
|
|
1004
|
-
* type: "image",
|
|
1005
|
-
* source: {
|
|
1006
|
-
* type: "base64",
|
|
1007
|
-
* media_type: "image/png",
|
|
1008
|
-
* data: "base64data..."
|
|
1009
|
-
* }
|
|
1010
|
-
* }
|
|
1011
|
-
*/
|
|
1012
|
-
declare function attachmentToAnthropicImage(attachment: MessageAttachment): AnthropicContentBlock | null;
|
|
1013
|
-
/**
|
|
1014
|
-
* Convert MessageAttachment to OpenAI image_url content block
|
|
1015
|
-
*
|
|
1016
|
-
* OpenAI format:
|
|
1017
|
-
* {
|
|
1018
|
-
* type: "image_url",
|
|
1019
|
-
* image_url: {
|
|
1020
|
-
* url: "data:image/png;base64,..."
|
|
1021
|
-
* }
|
|
1022
|
-
* }
|
|
1023
|
-
*/
|
|
1024
|
-
declare function attachmentToOpenAIImage(attachment: MessageAttachment): OpenAIContentBlock | null;
|
|
1025
|
-
/**
|
|
1026
|
-
* Convert MessageAttachment (PDF) to Anthropic document content block
|
|
1027
|
-
*
|
|
1028
|
-
* Anthropic format:
|
|
1029
|
-
* {
|
|
1030
|
-
* type: "document",
|
|
1031
|
-
* source: {
|
|
1032
|
-
* type: "base64",
|
|
1033
|
-
* media_type: "application/pdf",
|
|
1034
|
-
* data: "base64data..."
|
|
1035
|
-
* }
|
|
1036
|
-
* }
|
|
1037
|
-
*/
|
|
1038
|
-
declare function attachmentToAnthropicDocument(attachment: MessageAttachment): AnthropicContentBlock | null;
|
|
1039
|
-
/**
|
|
1040
|
-
* Convert a Message to Anthropic multimodal content blocks
|
|
1041
|
-
*/
|
|
1042
|
-
declare function messageToAnthropicContent(message: Message): string | AnthropicContentBlock[];
|
|
1043
|
-
/**
|
|
1044
|
-
* Convert a Message to OpenAI multimodal content blocks
|
|
1045
|
-
*/
|
|
1046
|
-
declare function messageToOpenAIContent(message: Message): string | OpenAIContentBlock[];
|
|
1047
|
-
/**
|
|
1048
|
-
* Anthropic content block types (extended for tools)
|
|
1049
|
-
*/
|
|
1050
|
-
type AnthropicToolUseBlock = {
|
|
1051
|
-
type: "tool_use";
|
|
1052
|
-
id: string;
|
|
1053
|
-
name: string;
|
|
1054
|
-
input: Record<string, unknown>;
|
|
1055
|
-
};
|
|
1056
|
-
type AnthropicToolResultBlock = {
|
|
1057
|
-
type: "tool_result";
|
|
1058
|
-
tool_use_id: string;
|
|
1059
|
-
content: string;
|
|
1060
|
-
};
|
|
1061
|
-
type AnthropicMessageContent = string | Array<AnthropicContentBlock | AnthropicToolUseBlock | AnthropicToolResultBlock>;
|
|
1062
|
-
/**
|
|
1063
|
-
* Format messages for Anthropic with full tool support
|
|
1064
|
-
* Handles: text, images, tool_use, and tool_result
|
|
1065
|
-
*
|
|
1066
|
-
* Key differences from OpenAI:
|
|
1067
|
-
* - tool_calls become tool_use blocks in assistant content
|
|
1068
|
-
* - tool results become tool_result blocks in user content
|
|
1069
|
-
*/
|
|
1070
|
-
declare function formatMessagesForAnthropic(messages: Message[], systemPrompt?: string): {
|
|
1071
|
-
system: string;
|
|
1072
|
-
messages: Array<{
|
|
1073
|
-
role: "user" | "assistant";
|
|
1074
|
-
content: AnthropicMessageContent;
|
|
1075
|
-
}>;
|
|
1076
|
-
};
|
|
1077
|
-
/**
|
|
1078
|
-
* OpenAI message format with tool support
|
|
1079
|
-
*/
|
|
1080
|
-
type OpenAIMessage = {
|
|
1081
|
-
role: "system";
|
|
1082
|
-
content: string;
|
|
1083
|
-
} | {
|
|
1084
|
-
role: "user";
|
|
1085
|
-
content: string | OpenAIContentBlock[];
|
|
1086
|
-
} | {
|
|
1087
|
-
role: "assistant";
|
|
1088
|
-
content: string | null;
|
|
1089
|
-
tool_calls?: Array<{
|
|
1090
|
-
id: string;
|
|
1091
|
-
type: "function";
|
|
1092
|
-
function: {
|
|
1093
|
-
name: string;
|
|
1094
|
-
arguments: string;
|
|
1095
|
-
};
|
|
1096
|
-
}>;
|
|
1097
|
-
} | {
|
|
1098
|
-
role: "tool";
|
|
1099
|
-
content: string;
|
|
1100
|
-
tool_call_id: string;
|
|
1101
|
-
};
|
|
1102
|
-
/**
|
|
1103
|
-
* Format messages for OpenAI with full tool support
|
|
1104
|
-
* Handles: text, images, tool_calls, and tool results
|
|
1105
|
-
*/
|
|
1106
|
-
declare function formatMessagesForOpenAI(messages: Message[], systemPrompt?: string): OpenAIMessage[];
|
|
1107
|
-
|
|
1108
|
-
/**
|
|
1109
|
-
* Provider Types
|
|
1110
|
-
*
|
|
1111
|
-
* Defines interfaces for:
|
|
1112
|
-
* 1. Provider Formatters (for tool transformations in agent loop)
|
|
1113
|
-
* 2. Multi-provider architecture (AIProvider, capabilities, configs)
|
|
1114
|
-
*/
|
|
1115
|
-
|
|
1116
|
-
/**
|
|
1117
|
-
* Provider formatter interface
|
|
1118
|
-
*
|
|
1119
|
-
* Each provider implements this interface to handle:
|
|
1120
|
-
* - Tool definition transformation
|
|
1121
|
-
* - Tool call parsing from responses
|
|
1122
|
-
* - Tool result formatting
|
|
1123
|
-
* - Stop reason detection
|
|
1124
|
-
*/
|
|
1125
|
-
interface ProviderFormatter {
|
|
1126
|
-
/**
|
|
1127
|
-
* Transform unified tool definitions to provider format
|
|
1128
|
-
*/
|
|
1129
|
-
transformTools(tools: ToolDefinition[]): unknown[];
|
|
1130
|
-
/**
|
|
1131
|
-
* Parse tool calls from provider response
|
|
1132
|
-
*/
|
|
1133
|
-
parseToolCalls(response: unknown): UnifiedToolCall[];
|
|
1134
|
-
/**
|
|
1135
|
-
* Format tool results for provider
|
|
1136
|
-
*/
|
|
1137
|
-
formatToolResults(results: UnifiedToolResult[]): unknown[];
|
|
1138
|
-
/**
|
|
1139
|
-
* Check if response indicates tool use is requested
|
|
1140
|
-
*/
|
|
1141
|
-
isToolUseStop(response: unknown): boolean;
|
|
1142
|
-
/**
|
|
1143
|
-
* Check if response indicates end of turn
|
|
1144
|
-
*/
|
|
1145
|
-
isEndTurnStop(response: unknown): boolean;
|
|
1146
|
-
/**
|
|
1147
|
-
* Get stop reason string from response
|
|
1148
|
-
*/
|
|
1149
|
-
getStopReason(response: unknown): string;
|
|
1150
|
-
/**
|
|
1151
|
-
* Extract text content from response
|
|
1152
|
-
*/
|
|
1153
|
-
extractTextContent(response: unknown): string;
|
|
1154
|
-
/**
|
|
1155
|
-
* Build assistant message with tool calls for conversation history
|
|
1156
|
-
*/
|
|
1157
|
-
buildAssistantToolMessage(toolCalls: UnifiedToolCall[], textContent?: string): unknown;
|
|
1158
|
-
/**
|
|
1159
|
-
* Build user message with tool results for conversation history
|
|
1160
|
-
*/
|
|
1161
|
-
buildToolResultMessage(results: UnifiedToolResult[]): unknown;
|
|
1162
|
-
}
|
|
1163
|
-
/**
|
|
1164
|
-
* Anthropic tool definition format
|
|
1165
|
-
*/
|
|
1166
|
-
interface AnthropicTool {
|
|
1167
|
-
name: string;
|
|
1168
|
-
description: string;
|
|
1169
|
-
input_schema: {
|
|
1170
|
-
type: "object";
|
|
1171
|
-
properties: Record<string, unknown>;
|
|
1172
|
-
required?: string[];
|
|
1173
|
-
};
|
|
1174
|
-
}
|
|
1175
|
-
/**
|
|
1176
|
-
* Anthropic tool_use block from response
|
|
1177
|
-
*/
|
|
1178
|
-
interface AnthropicToolUse {
|
|
1179
|
-
type: "tool_use";
|
|
1180
|
-
id: string;
|
|
1181
|
-
name: string;
|
|
1182
|
-
input: Record<string, unknown>;
|
|
1183
|
-
}
|
|
1184
|
-
/**
|
|
1185
|
-
* Anthropic tool_result block
|
|
1186
|
-
*/
|
|
1187
|
-
interface AnthropicToolResult {
|
|
1188
|
-
type: "tool_result";
|
|
1189
|
-
tool_use_id: string;
|
|
1190
|
-
content: string;
|
|
1191
|
-
}
|
|
1192
|
-
/**
|
|
1193
|
-
* OpenAI tool definition format
|
|
1194
|
-
*/
|
|
1195
|
-
interface OpenAITool {
|
|
1196
|
-
type: "function";
|
|
1197
|
-
function: {
|
|
1198
|
-
name: string;
|
|
1199
|
-
description: string;
|
|
1200
|
-
parameters: {
|
|
1201
|
-
type: "object";
|
|
1202
|
-
properties: Record<string, unknown>;
|
|
1203
|
-
required?: string[];
|
|
1204
|
-
};
|
|
1205
|
-
};
|
|
1206
|
-
}
|
|
1207
|
-
/**
|
|
1208
|
-
* OpenAI tool call from response
|
|
1209
|
-
*/
|
|
1210
|
-
interface OpenAIToolCall {
|
|
1211
|
-
id: string;
|
|
1212
|
-
type: "function";
|
|
1213
|
-
function: {
|
|
1214
|
-
name: string;
|
|
1215
|
-
arguments: string;
|
|
1216
|
-
};
|
|
1217
|
-
}
|
|
1218
|
-
/**
|
|
1219
|
-
* OpenAI tool result message
|
|
1220
|
-
*/
|
|
1221
|
-
interface OpenAIToolResult {
|
|
1222
|
-
role: "tool";
|
|
1223
|
-
tool_call_id: string;
|
|
1224
|
-
content: string;
|
|
1225
|
-
}
|
|
1226
|
-
/**
|
|
1227
|
-
* Google Gemini function declaration
|
|
1228
|
-
*/
|
|
1229
|
-
interface GeminiFunctionDeclaration {
|
|
1230
|
-
name: string;
|
|
1231
|
-
description: string;
|
|
1232
|
-
parameters?: {
|
|
1233
|
-
type: "object";
|
|
1234
|
-
properties: Record<string, unknown>;
|
|
1235
|
-
required?: string[];
|
|
1236
|
-
};
|
|
1237
|
-
}
|
|
1238
|
-
/**
|
|
1239
|
-
* Gemini function call from response
|
|
1240
|
-
*/
|
|
1241
|
-
interface GeminiFunctionCall {
|
|
1242
|
-
name: string;
|
|
1243
|
-
args: Record<string, unknown>;
|
|
1244
|
-
}
|
|
1245
|
-
/**
|
|
1246
|
-
* Gemini function response
|
|
1247
|
-
*/
|
|
1248
|
-
interface GeminiFunctionResponse {
|
|
1249
|
-
name: string;
|
|
1250
|
-
response: Record<string, unknown>;
|
|
1251
|
-
}
|
|
1252
|
-
/**
|
|
1253
|
-
* Capabilities of a model for UI feature flags
|
|
1254
|
-
* UI components can use this to enable/disable features
|
|
1255
|
-
*/
|
|
1256
|
-
interface ProviderCapabilities {
|
|
1257
|
-
/** Supports image inputs */
|
|
1258
|
-
supportsVision: boolean;
|
|
1259
|
-
/** Supports tool/function calling */
|
|
1260
|
-
supportsTools: boolean;
|
|
1261
|
-
/** Supports extended thinking (Claude, DeepSeek) */
|
|
1262
|
-
supportsThinking: boolean;
|
|
1263
|
-
/** Supports streaming responses */
|
|
1264
|
-
supportsStreaming: boolean;
|
|
1265
|
-
/** Supports PDF document inputs */
|
|
1266
|
-
supportsPDF: boolean;
|
|
1267
|
-
/** Supports audio inputs */
|
|
1268
|
-
supportsAudio: boolean;
|
|
1269
|
-
/** Supports video inputs */
|
|
1270
|
-
supportsVideo: boolean;
|
|
1271
|
-
/** Maximum context tokens */
|
|
1272
|
-
maxTokens: number;
|
|
1273
|
-
/** Supported image MIME types */
|
|
1274
|
-
supportedImageTypes: string[];
|
|
1275
|
-
/** Supported audio MIME types */
|
|
1276
|
-
supportedAudioTypes?: string[];
|
|
1277
|
-
/** Supported video MIME types */
|
|
1278
|
-
supportedVideoTypes?: string[];
|
|
1279
|
-
/** Supports JSON mode / structured output */
|
|
1280
|
-
supportsJsonMode?: boolean;
|
|
1281
|
-
/** Supports system messages */
|
|
1282
|
-
supportsSystemMessages?: boolean;
|
|
1283
|
-
}
|
|
1284
|
-
/**
|
|
1285
|
-
* AI Provider interface (object form)
|
|
1286
|
-
*
|
|
1287
|
-
* Wraps existing LLMAdapter with additional metadata:
|
|
1288
|
-
* - Supported models list
|
|
1289
|
-
* - Per-model capabilities
|
|
1290
|
-
* - Provider name
|
|
1291
|
-
*/
|
|
1292
|
-
interface AIProviderObject {
|
|
1293
|
-
/** Provider name (e.g., 'openai', 'anthropic') */
|
|
1294
|
-
readonly name: string;
|
|
1295
|
-
/** List of supported model IDs */
|
|
1296
|
-
readonly supportedModels: string[];
|
|
1297
|
-
/**
|
|
1298
|
-
* Get a language model adapter for the given model ID
|
|
1299
|
-
* Returns the existing LLMAdapter interface - no breaking changes
|
|
1300
|
-
*/
|
|
1301
|
-
languageModel(modelId: string): LLMAdapter;
|
|
1302
|
-
/**
|
|
1303
|
-
* Get capabilities for a specific model
|
|
1304
|
-
* UI components use this to enable/disable features
|
|
1305
|
-
*/
|
|
1306
|
-
getCapabilities(modelId: string): ProviderCapabilities;
|
|
1307
|
-
/**
|
|
1308
|
-
* Optional: Get an embedding model (future expansion)
|
|
1309
|
-
*/
|
|
1310
|
-
embeddingModel?(modelId: string): EmbeddingModel;
|
|
1311
|
-
}
|
|
1312
|
-
/**
|
|
1313
|
-
* Callable AI Provider (Vercel AI SDK style)
|
|
1314
|
-
*
|
|
1315
|
-
* A function that returns a LanguageModel when called with a model ID,
|
|
1316
|
-
* but also has properties for provider metadata and methods.
|
|
1317
|
-
*
|
|
1318
|
-
* @example
|
|
1319
|
-
* ```typescript
|
|
1320
|
-
* const openai = createOpenAI({ apiKey: '...' });
|
|
1321
|
-
*
|
|
1322
|
-
* // Callable - returns LanguageModel directly (Vercel AI SDK style)
|
|
1323
|
-
* const model = openai('gpt-4o');
|
|
1324
|
-
*
|
|
1325
|
-
* // Also supports method calls (backward compatible)
|
|
1326
|
-
* const model2 = openai.languageModel('gpt-4o');
|
|
1327
|
-
*
|
|
1328
|
-
* // Check capabilities
|
|
1329
|
-
* const caps = openai.getCapabilities('gpt-4o');
|
|
1330
|
-
* if (caps.supportsVision) {
|
|
1331
|
-
* // Show image upload button
|
|
1332
|
-
* }
|
|
1333
|
-
* ```
|
|
1334
|
-
*/
|
|
1335
|
-
interface AIProvider extends AIProviderObject {
|
|
1336
|
-
/**
|
|
1337
|
-
* Call the provider directly with a model ID to get a LanguageModel
|
|
1338
|
-
* This is the Vercel AI SDK style pattern
|
|
1339
|
-
*/
|
|
1340
|
-
(modelId: string): LLMAdapter;
|
|
1341
|
-
}
|
|
1342
|
-
/**
|
|
1343
|
-
* Embedding model interface (for future expansion)
|
|
1344
|
-
*/
|
|
1345
|
-
interface EmbeddingModel {
|
|
1346
|
-
readonly provider: string;
|
|
1347
|
-
readonly modelId: string;
|
|
1348
|
-
embed(texts: string[]): Promise<number[][]>;
|
|
1349
|
-
}
|
|
1350
|
-
/**
|
|
1351
|
-
* Base provider configuration
|
|
1352
|
-
*/
|
|
1353
|
-
interface BaseProviderConfig {
|
|
1354
|
-
/** API key (falls back to environment variable) */
|
|
1355
|
-
apiKey?: string;
|
|
1356
|
-
/** Custom base URL */
|
|
1357
|
-
baseUrl?: string;
|
|
1358
|
-
/** Request timeout in milliseconds */
|
|
1359
|
-
timeout?: number;
|
|
1360
|
-
/** Custom headers to include */
|
|
1361
|
-
headers?: Record<string, string>;
|
|
1362
|
-
}
|
|
1363
|
-
/**
|
|
1364
|
-
* OpenAI provider configuration
|
|
1365
|
-
*/
|
|
1366
|
-
interface OpenAIProviderConfig extends BaseProviderConfig {
|
|
1367
|
-
/** OpenAI organization ID */
|
|
1368
|
-
organization?: string;
|
|
1369
|
-
/** OpenAI project ID */
|
|
1370
|
-
project?: string;
|
|
1371
|
-
/** Vision detail level for images */
|
|
1372
|
-
imageDetail?: "auto" | "low" | "high";
|
|
1373
|
-
}
|
|
1374
|
-
/**
|
|
1375
|
-
* Anthropic provider configuration
|
|
1376
|
-
*/
|
|
1377
|
-
interface AnthropicProviderConfig extends BaseProviderConfig {
|
|
1378
|
-
/** Extended thinking budget in tokens (minimum 1024) */
|
|
1379
|
-
thinkingBudget?: number;
|
|
1380
|
-
/** Enable prompt caching */
|
|
1381
|
-
cacheControl?: boolean;
|
|
1382
|
-
}
|
|
1383
|
-
/**
|
|
1384
|
-
* Google provider configuration
|
|
1385
|
-
*/
|
|
1386
|
-
interface GoogleProviderConfig extends BaseProviderConfig {
|
|
1387
|
-
/** Safety settings */
|
|
1388
|
-
safetySettings?: GoogleSafetySetting[];
|
|
1389
|
-
/** Grounding configuration (for web search) */
|
|
1390
|
-
groundingConfig?: GoogleGroundingConfig;
|
|
1391
|
-
}
|
|
1392
|
-
/**
|
|
1393
|
-
* Google safety setting
|
|
1394
|
-
*/
|
|
1395
|
-
interface GoogleSafetySetting {
|
|
1396
|
-
category: "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_DANGEROUS_CONTENT";
|
|
1397
|
-
threshold: "BLOCK_NONE" | "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_HIGH_AND_ABOVE";
|
|
1398
|
-
}
|
|
1399
|
-
/**
|
|
1400
|
-
* Google grounding configuration
|
|
1401
|
-
*/
|
|
1402
|
-
interface GoogleGroundingConfig {
|
|
1403
|
-
/** Enable Google Search grounding */
|
|
1404
|
-
googleSearchRetrieval?: boolean;
|
|
1405
|
-
}
|
|
1406
|
-
/**
|
|
1407
|
-
* xAI provider configuration
|
|
1408
|
-
*/
|
|
1409
|
-
interface XAIProviderConfig extends BaseProviderConfig {
|
|
1410
|
-
}
|
|
1411
|
-
/**
|
|
1412
|
-
* Azure OpenAI provider configuration
|
|
1413
|
-
*/
|
|
1414
|
-
interface AzureProviderConfig extends BaseProviderConfig {
|
|
1415
|
-
/** Azure resource name */
|
|
1416
|
-
resourceName: string;
|
|
1417
|
-
/** Deployment name */
|
|
1418
|
-
deploymentName: string;
|
|
1419
|
-
/** API version (default: 2024-02-15-preview) */
|
|
1420
|
-
apiVersion?: string;
|
|
1421
|
-
}
|
|
1422
|
-
/**
|
|
1423
|
-
* Ollama model-specific options
|
|
1424
|
-
* These map to Ollama's native API options
|
|
1425
|
-
*/
|
|
1426
|
-
interface OllamaModelOptions {
|
|
1427
|
-
/** Context window size (default varies by model) */
|
|
1428
|
-
num_ctx?: number;
|
|
1429
|
-
/** Max tokens to predict (-1 = infinite, -2 = fill context) */
|
|
1430
|
-
num_predict?: number;
|
|
1431
|
-
/** Mirostat sampling (0 = disabled, 1 = Mirostat, 2 = Mirostat 2.0) */
|
|
1432
|
-
mirostat?: 0 | 1 | 2;
|
|
1433
|
-
/** Mirostat learning rate (default: 0.1) */
|
|
1434
|
-
mirostat_eta?: number;
|
|
1435
|
-
/** Mirostat target entropy (default: 5.0) */
|
|
1436
|
-
mirostat_tau?: number;
|
|
1437
|
-
/** Repeat penalty (default: 1.1) */
|
|
1438
|
-
repeat_penalty?: number;
|
|
1439
|
-
/** Random seed for reproducibility (-1 = random) */
|
|
1440
|
-
seed?: number;
|
|
1441
|
-
/** Top-k sampling (default: 40) */
|
|
1442
|
-
top_k?: number;
|
|
1443
|
-
/** Top-p (nucleus) sampling (default: 0.9) */
|
|
1444
|
-
top_p?: number;
|
|
1445
|
-
/** Min-p sampling (default: 0.0) */
|
|
1446
|
-
min_p?: number;
|
|
1447
|
-
/** Stop sequences */
|
|
1448
|
-
stop?: string[];
|
|
1449
|
-
/** Temperature override (also available in config) */
|
|
1450
|
-
temperature?: number;
|
|
1451
|
-
}
|
|
1452
|
-
/**
|
|
1453
|
-
* Ollama provider configuration
|
|
1454
|
-
*/
|
|
1455
|
-
interface OllamaProviderConfig extends BaseProviderConfig {
|
|
1456
|
-
/** Default Ollama-specific model options */
|
|
1457
|
-
options?: OllamaModelOptions;
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
|
-
export { type GoogleProviderConfig as $, type AIProvider as A, type ToolResultChunk as B, type CoreMessage as C, type DoneEventMessage as D, type FinishChunk as E, type FilePart as F, type GenerateTextParams as G, type ErrorChunk as H, type ImagePart as I, type TokenUsage as J, type KnowledgeBaseConfig as K, type LLMAdapter as L, type Message as M, type FinishReason as N, DEFAULT_CAPABILITIES as O, type ProviderToolRuntimeOptions as P, type ChatCompletionRequest as Q, type ResponseOptions as R, type StreamTextParams as S, type ToolContext$1 as T, type UserMessage as U, type AdapterFactory as V, type WebSearchConfig as W, type ProviderCapabilities as X, type BaseProviderConfig as Y, type OpenAIProviderConfig as Z, type AnthropicProviderConfig as _, type GenerateTextResult as a, type XAIProviderConfig as a0, type AzureProviderConfig as a1, type OllamaProviderConfig as a2, type OllamaModelOptions as a3, type ProviderFormatter as a4, type AnthropicTool as a5, type AnthropicToolUse as a6, type AnthropicToolResult as a7, type OpenAITool as a8, type OpenAIToolCall as a9, attachmentToOpenAIImage as aA, type AnthropicContentBlock as aB, type OpenAIContentBlock as aC, type OpenAIToolResult as aa, type GeminiFunctionDeclaration as ab, type GeminiFunctionCall as ac, type GeminiFunctionResponse as ad, type LLMConfig as ae, type ToolLocation as af, type UnifiedToolCall as ag, type UnifiedToolResult as ah, type ToolExecution as ai, type OpenAIToolSelectionHints as aj, type AnthropicToolSelectionHints as ak, type ToolNativeProviderHints as al, type OpenAIProviderToolOptions as am, type AnthropicProviderToolOptions as an, type Citation as ao, type CompletionResult as ap, formatMessages as aq, formatTools as ar, formatMessagesForAnthropic as as, formatMessagesForOpenAI as at, messageToAnthropicContent as au, messageToOpenAIContent as av, hasImageAttachments as aw, hasMediaAttachments as ax, attachmentToAnthropicImage as ay, attachmentToAnthropicDocument as az, type StreamTextResult as b, type Tool as c, type ActionDefinition as d, type ToolDefinition as e, type ToolProfile as f, type StreamEvent as g, type ToolCallInfo as h, type TokenUsageRaw as i, type ToolResponse as j, type LanguageModel as k, type ModelCapabilities as l, type DoGenerateParams as m, type DoGenerateResult as n, type SystemMessage as o, type AssistantMessage as p, type ToolMessage as q, type UserContentPart as r, type TextPart as s, type ToolCall$1 as t, type ToolResult as u, type GenerateStep as v, type StreamPart as w, type StreamChunk as x, type TextDeltaChunk as y, type ToolCallChunk as z };
|