@yourgpt/llm-sdk 2.0.1 → 2.0.2-beta.2
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 +27 -4
- package/dist/adapters/index.d.ts +27 -4
- package/dist/adapters/index.js +395 -25
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/index.mjs +395 -25
- package/dist/adapters/index.mjs.map +1 -1
- package/dist/index.d.mts +24 -5
- package/dist/index.d.ts +24 -5
- package/dist/index.js +20 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -4
- package/dist/index.mjs.map +1 -1
- package/dist/providers/anthropic/index.d.mts +1 -2
- package/dist/providers/anthropic/index.d.ts +1 -2
- package/dist/providers/anthropic/index.js +108 -12
- package/dist/providers/anthropic/index.js.map +1 -1
- package/dist/providers/anthropic/index.mjs +108 -12
- package/dist/providers/anthropic/index.mjs.map +1 -1
- package/dist/providers/azure/index.d.mts +1 -2
- package/dist/providers/azure/index.d.ts +1 -2
- package/dist/providers/azure/index.js.map +1 -1
- package/dist/providers/azure/index.mjs.map +1 -1
- package/dist/providers/google/index.d.mts +1 -2
- package/dist/providers/google/index.d.ts +1 -2
- package/dist/providers/google/index.js +61 -2
- package/dist/providers/google/index.js.map +1 -1
- package/dist/providers/google/index.mjs +61 -2
- package/dist/providers/google/index.mjs.map +1 -1
- package/dist/providers/ollama/index.d.mts +8 -3
- package/dist/providers/ollama/index.d.ts +8 -3
- package/dist/providers/ollama/index.js +227 -17
- package/dist/providers/ollama/index.js.map +1 -1
- package/dist/providers/ollama/index.mjs +227 -17
- package/dist/providers/ollama/index.mjs.map +1 -1
- package/dist/providers/openai/index.d.mts +1 -2
- package/dist/providers/openai/index.d.ts +1 -2
- package/dist/providers/openai/index.js +57 -3
- package/dist/providers/openai/index.js.map +1 -1
- package/dist/providers/openai/index.mjs +57 -3
- package/dist/providers/openai/index.mjs.map +1 -1
- package/dist/providers/openrouter/index.d.mts +56 -3
- package/dist/providers/openrouter/index.d.ts +56 -3
- package/dist/providers/openrouter/index.js +90 -276
- package/dist/providers/openrouter/index.js.map +1 -1
- package/dist/providers/openrouter/index.mjs +89 -277
- package/dist/providers/openrouter/index.mjs.map +1 -1
- package/dist/providers/xai/index.d.mts +1 -2
- package/dist/providers/xai/index.d.ts +1 -2
- package/dist/providers/xai/index.js.map +1 -1
- package/dist/providers/xai/index.mjs.map +1 -1
- package/dist/{base-DdxolpKP.d.mts → types-C_f95PKp.d.mts} +434 -3
- package/dist/{base-DdxolpKP.d.ts → types-C_f95PKp.d.ts} +434 -3
- package/package.json +1 -1
- package/dist/types-Ck25ZYma.d.mts +0 -323
- package/dist/types-Dsz8SpdB.d.ts +0 -323
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { G as GenerateTextParams, a as GenerateTextResult, S as StreamTextParams, b as StreamTextResult, T as ToolContext, c as Tool, A as
|
|
2
|
-
export {
|
|
1
|
+
import { G as GenerateTextParams, a as GenerateTextResult, S as StreamTextParams, b as StreamTextResult, T as ToolContext, c as Tool, A as AIProvider, d as ActionDefinition, e as ToolDefinition, f as AgentLoopConfig, K as KnowledgeBaseConfig, W as WebSearchConfig, L as LLMAdapter, D as DoneEventMessage, g as StreamEvent, h as ToolCallInfo, i as TokenUsageRaw, M as Message, j as ToolResponse } from './types-C_f95PKp.mjs';
|
|
2
|
+
export { Q as AdapterFactory, Z as AnthropicProviderConfig, a4 as AnthropicTool, a6 as AnthropicToolResult, a5 as AnthropicToolUse, p as AssistantMessage, a0 as AzureProviderConfig, X as BaseProviderConfig, P as ChatCompletionRequest, ai as Citation, C as CoreMessage, O as DEFAULT_CAPABILITIES, m as DoGenerateParams, n as DoGenerateResult, H as ErrorChunk, F as FilePart, E as FinishChunk, N as FinishReason, ab as GeminiFunctionCall, aa as GeminiFunctionDeclaration, ac as GeminiFunctionResponse, v as GenerateStep, _ as GoogleProviderConfig, I as ImagePart, ad as LLMConfig, k as LanguageModel, l as ModelCapabilities, a2 as OllamaModelOptions, a1 as OllamaProviderConfig, Y as OpenAIProviderConfig, a7 as OpenAITool, a8 as OpenAIToolCall, a9 as OpenAIToolResult, V as ProviderCapabilities, a3 as ProviderFormatter, R as ResponseOptions, x as StreamChunk, w as StreamPart, o as SystemMessage, y as TextDeltaChunk, s as TextPart, J as TokenUsage, t as ToolCall, z as ToolCallChunk, ah as ToolExecution, ae as ToolLocation, q as ToolMessage, u as ToolResult, B as ToolResultChunk, af as UnifiedToolCall, ag as UnifiedToolResult, r as UserContentPart, U as UserMessage, $ as XAIProviderConfig } from './types-C_f95PKp.mjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { A as AIProvider } from './types-Ck25ZYma.mjs';
|
|
5
|
-
export { a as AnthropicProviderConfig, e as AnthropicTool, g as AnthropicToolResult, f as AnthropicToolUse, b as AzureProviderConfig, B as BaseProviderConfig, l as GeminiFunctionCall, k as GeminiFunctionDeclaration, m as GeminiFunctionResponse, G as GoogleProviderConfig, c as OllamaProviderConfig, O as OpenAIProviderConfig, h as OpenAITool, i as OpenAIToolCall, j as OpenAIToolResult, P as ProviderCapabilities, d as ProviderFormatter, X as XAIProviderConfig } from './types-Ck25ZYma.mjs';
|
|
6
4
|
import * as hono from 'hono';
|
|
7
5
|
import { Hono } from 'hono';
|
|
8
6
|
|
|
@@ -108,6 +106,13 @@ interface ToolConfig<TParams extends z.ZodType, TResult = unknown> {
|
|
|
108
106
|
parameters: TParams;
|
|
109
107
|
/** Function to execute when the tool is called */
|
|
110
108
|
execute: (params: z.infer<TParams>, context: ToolContext) => Promise<TResult>;
|
|
109
|
+
/**
|
|
110
|
+
* Hide this tool's execution from the chat UI.
|
|
111
|
+
* When true, tool calls and results won't be displayed to the user,
|
|
112
|
+
* but the tool will still execute normally.
|
|
113
|
+
* @default false
|
|
114
|
+
*/
|
|
115
|
+
hidden?: boolean;
|
|
111
116
|
}
|
|
112
117
|
/**
|
|
113
118
|
* Create a type-safe tool definition
|
|
@@ -186,6 +191,11 @@ interface RuntimeConfigWithAdapter {
|
|
|
186
191
|
debug?: boolean;
|
|
187
192
|
/** Custom context data passed to all tool handlers */
|
|
188
193
|
toolContext?: Record<string, unknown>;
|
|
194
|
+
/**
|
|
195
|
+
* Enable native web search for the provider.
|
|
196
|
+
* Set to true for defaults, or pass WebSearchConfig for customization.
|
|
197
|
+
*/
|
|
198
|
+
webSearch?: boolean | WebSearchConfig;
|
|
189
199
|
}
|
|
190
200
|
/**
|
|
191
201
|
* Runtime configuration with AIProvider
|
|
@@ -220,6 +230,11 @@ interface RuntimeConfigWithProvider {
|
|
|
220
230
|
debug?: boolean;
|
|
221
231
|
/** Custom context data passed to all tool handlers */
|
|
222
232
|
toolContext?: Record<string, unknown>;
|
|
233
|
+
/**
|
|
234
|
+
* Enable native web search for the provider.
|
|
235
|
+
* Set to true for defaults, or pass WebSearchConfig for customization.
|
|
236
|
+
*/
|
|
237
|
+
webSearch?: boolean | WebSearchConfig;
|
|
223
238
|
}
|
|
224
239
|
/**
|
|
225
240
|
* Runtime configuration - provide either a provider instance or a custom adapter
|
|
@@ -848,6 +863,10 @@ declare class Runtime {
|
|
|
848
863
|
* Get the current model ID
|
|
849
864
|
*/
|
|
850
865
|
getModel(): string;
|
|
866
|
+
/**
|
|
867
|
+
* Get web search configuration from runtime config
|
|
868
|
+
*/
|
|
869
|
+
private getWebSearchConfig;
|
|
851
870
|
/**
|
|
852
871
|
* Process a chat request with tool support (Vercel AI SDK pattern)
|
|
853
872
|
*
|
|
@@ -1305,4 +1324,4 @@ declare function generateThreadId(): string;
|
|
|
1305
1324
|
*/
|
|
1306
1325
|
declare function generateToolCallId(): string;
|
|
1307
1326
|
|
|
1308
|
-
export { AIProvider, ActionDefinition, type ActionRequest, AgentLoopConfig, type AgentLoopOptions, type ChatRequest, type CollectedResult, type CopilotChatResponse, DEFAULT_MAX_ITERATIONS, DoneEventMessage, GenerateResult, type GenerateResultData, GenerateTextParams, GenerateTextResult, LLMAdapter, Message, type RequestContext, Runtime, type RuntimeConfig, StreamEvent, StreamResult, type StreamResultOptions, StreamTextParams, StreamTextResult, TokenUsageRaw, Tool, ToolCallInfo, ToolContext, ToolDefinition, ToolResponse, createEventStream, createExpressHandler, createExpressMiddleware, createHonoApp, createNextHandler, createNodeHandler, createRuntime, createSSEHeaders, createSSEResponse, createStreamResult, createTextStreamHeaders, createTextStreamResponse, formatSSEData, formatToolsForAnthropic, formatToolsForGoogle, formatToolsForOpenAI, generateMessageId, generateText, generateThreadId, generateToolCallId, pipeSSEToResponse, pipeTextToResponse, runAgentLoop, streamText, tool };
|
|
1327
|
+
export { AIProvider, ActionDefinition, type ActionRequest, AgentLoopConfig, type AgentLoopOptions, type ChatRequest, type CollectedResult, type CopilotChatResponse, DEFAULT_MAX_ITERATIONS, DoneEventMessage, GenerateResult, type GenerateResultData, GenerateTextParams, GenerateTextResult, LLMAdapter, Message, type RequestContext, Runtime, type RuntimeConfig, StreamEvent, StreamResult, type StreamResultOptions, StreamTextParams, StreamTextResult, TokenUsageRaw, Tool, ToolCallInfo, ToolContext, ToolDefinition, ToolResponse, WebSearchConfig, createEventStream, createExpressHandler, createExpressMiddleware, createHonoApp, createNextHandler, createNodeHandler, createRuntime, createSSEHeaders, createSSEResponse, createStreamResult, createTextStreamHeaders, createTextStreamResponse, formatSSEData, formatToolsForAnthropic, formatToolsForGoogle, formatToolsForOpenAI, generateMessageId, generateText, generateThreadId, generateToolCallId, pipeSSEToResponse, pipeTextToResponse, runAgentLoop, streamText, tool };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { G as GenerateTextParams, a as GenerateTextResult, S as StreamTextParams, b as StreamTextResult, T as ToolContext, c as Tool, A as
|
|
2
|
-
export {
|
|
1
|
+
import { G as GenerateTextParams, a as GenerateTextResult, S as StreamTextParams, b as StreamTextResult, T as ToolContext, c as Tool, A as AIProvider, d as ActionDefinition, e as ToolDefinition, f as AgentLoopConfig, K as KnowledgeBaseConfig, W as WebSearchConfig, L as LLMAdapter, D as DoneEventMessage, g as StreamEvent, h as ToolCallInfo, i as TokenUsageRaw, M as Message, j as ToolResponse } from './types-C_f95PKp.js';
|
|
2
|
+
export { Q as AdapterFactory, Z as AnthropicProviderConfig, a4 as AnthropicTool, a6 as AnthropicToolResult, a5 as AnthropicToolUse, p as AssistantMessage, a0 as AzureProviderConfig, X as BaseProviderConfig, P as ChatCompletionRequest, ai as Citation, C as CoreMessage, O as DEFAULT_CAPABILITIES, m as DoGenerateParams, n as DoGenerateResult, H as ErrorChunk, F as FilePart, E as FinishChunk, N as FinishReason, ab as GeminiFunctionCall, aa as GeminiFunctionDeclaration, ac as GeminiFunctionResponse, v as GenerateStep, _ as GoogleProviderConfig, I as ImagePart, ad as LLMConfig, k as LanguageModel, l as ModelCapabilities, a2 as OllamaModelOptions, a1 as OllamaProviderConfig, Y as OpenAIProviderConfig, a7 as OpenAITool, a8 as OpenAIToolCall, a9 as OpenAIToolResult, V as ProviderCapabilities, a3 as ProviderFormatter, R as ResponseOptions, x as StreamChunk, w as StreamPart, o as SystemMessage, y as TextDeltaChunk, s as TextPart, J as TokenUsage, t as ToolCall, z as ToolCallChunk, ah as ToolExecution, ae as ToolLocation, q as ToolMessage, u as ToolResult, B as ToolResultChunk, af as UnifiedToolCall, ag as UnifiedToolResult, r as UserContentPart, U as UserMessage, $ as XAIProviderConfig } from './types-C_f95PKp.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { A as AIProvider } from './types-Dsz8SpdB.js';
|
|
5
|
-
export { a as AnthropicProviderConfig, e as AnthropicTool, g as AnthropicToolResult, f as AnthropicToolUse, b as AzureProviderConfig, B as BaseProviderConfig, l as GeminiFunctionCall, k as GeminiFunctionDeclaration, m as GeminiFunctionResponse, G as GoogleProviderConfig, c as OllamaProviderConfig, O as OpenAIProviderConfig, h as OpenAITool, i as OpenAIToolCall, j as OpenAIToolResult, P as ProviderCapabilities, d as ProviderFormatter, X as XAIProviderConfig } from './types-Dsz8SpdB.js';
|
|
6
4
|
import * as hono from 'hono';
|
|
7
5
|
import { Hono } from 'hono';
|
|
8
6
|
|
|
@@ -108,6 +106,13 @@ interface ToolConfig<TParams extends z.ZodType, TResult = unknown> {
|
|
|
108
106
|
parameters: TParams;
|
|
109
107
|
/** Function to execute when the tool is called */
|
|
110
108
|
execute: (params: z.infer<TParams>, context: ToolContext) => Promise<TResult>;
|
|
109
|
+
/**
|
|
110
|
+
* Hide this tool's execution from the chat UI.
|
|
111
|
+
* When true, tool calls and results won't be displayed to the user,
|
|
112
|
+
* but the tool will still execute normally.
|
|
113
|
+
* @default false
|
|
114
|
+
*/
|
|
115
|
+
hidden?: boolean;
|
|
111
116
|
}
|
|
112
117
|
/**
|
|
113
118
|
* Create a type-safe tool definition
|
|
@@ -186,6 +191,11 @@ interface RuntimeConfigWithAdapter {
|
|
|
186
191
|
debug?: boolean;
|
|
187
192
|
/** Custom context data passed to all tool handlers */
|
|
188
193
|
toolContext?: Record<string, unknown>;
|
|
194
|
+
/**
|
|
195
|
+
* Enable native web search for the provider.
|
|
196
|
+
* Set to true for defaults, or pass WebSearchConfig for customization.
|
|
197
|
+
*/
|
|
198
|
+
webSearch?: boolean | WebSearchConfig;
|
|
189
199
|
}
|
|
190
200
|
/**
|
|
191
201
|
* Runtime configuration with AIProvider
|
|
@@ -220,6 +230,11 @@ interface RuntimeConfigWithProvider {
|
|
|
220
230
|
debug?: boolean;
|
|
221
231
|
/** Custom context data passed to all tool handlers */
|
|
222
232
|
toolContext?: Record<string, unknown>;
|
|
233
|
+
/**
|
|
234
|
+
* Enable native web search for the provider.
|
|
235
|
+
* Set to true for defaults, or pass WebSearchConfig for customization.
|
|
236
|
+
*/
|
|
237
|
+
webSearch?: boolean | WebSearchConfig;
|
|
223
238
|
}
|
|
224
239
|
/**
|
|
225
240
|
* Runtime configuration - provide either a provider instance or a custom adapter
|
|
@@ -848,6 +863,10 @@ declare class Runtime {
|
|
|
848
863
|
* Get the current model ID
|
|
849
864
|
*/
|
|
850
865
|
getModel(): string;
|
|
866
|
+
/**
|
|
867
|
+
* Get web search configuration from runtime config
|
|
868
|
+
*/
|
|
869
|
+
private getWebSearchConfig;
|
|
851
870
|
/**
|
|
852
871
|
* Process a chat request with tool support (Vercel AI SDK pattern)
|
|
853
872
|
*
|
|
@@ -1305,4 +1324,4 @@ declare function generateThreadId(): string;
|
|
|
1305
1324
|
*/
|
|
1306
1325
|
declare function generateToolCallId(): string;
|
|
1307
1326
|
|
|
1308
|
-
export { AIProvider, ActionDefinition, type ActionRequest, AgentLoopConfig, type AgentLoopOptions, type ChatRequest, type CollectedResult, type CopilotChatResponse, DEFAULT_MAX_ITERATIONS, DoneEventMessage, GenerateResult, type GenerateResultData, GenerateTextParams, GenerateTextResult, LLMAdapter, Message, type RequestContext, Runtime, type RuntimeConfig, StreamEvent, StreamResult, type StreamResultOptions, StreamTextParams, StreamTextResult, TokenUsageRaw, Tool, ToolCallInfo, ToolContext, ToolDefinition, ToolResponse, createEventStream, createExpressHandler, createExpressMiddleware, createHonoApp, createNextHandler, createNodeHandler, createRuntime, createSSEHeaders, createSSEResponse, createStreamResult, createTextStreamHeaders, createTextStreamResponse, formatSSEData, formatToolsForAnthropic, formatToolsForGoogle, formatToolsForOpenAI, generateMessageId, generateText, generateThreadId, generateToolCallId, pipeSSEToResponse, pipeTextToResponse, runAgentLoop, streamText, tool };
|
|
1327
|
+
export { AIProvider, ActionDefinition, type ActionRequest, AgentLoopConfig, type AgentLoopOptions, type ChatRequest, type CollectedResult, type CopilotChatResponse, DEFAULT_MAX_ITERATIONS, DoneEventMessage, GenerateResult, type GenerateResultData, GenerateTextParams, GenerateTextResult, LLMAdapter, Message, type RequestContext, Runtime, type RuntimeConfig, StreamEvent, StreamResult, type StreamResultOptions, StreamTextParams, StreamTextResult, TokenUsageRaw, Tool, ToolCallInfo, ToolContext, ToolDefinition, ToolResponse, WebSearchConfig, createEventStream, createExpressHandler, createExpressMiddleware, createHonoApp, createNextHandler, createNodeHandler, createRuntime, createSSEHeaders, createSSEResponse, createStreamResult, createTextStreamHeaders, createTextStreamResponse, formatSSEData, formatToolsForAnthropic, formatToolsForGoogle, formatToolsForOpenAI, generateMessageId, generateText, generateThreadId, generateToolCallId, pipeSSEToResponse, pipeTextToResponse, runAgentLoop, streamText, tool };
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,8 @@ function tool(config) {
|
|
|
8
8
|
return {
|
|
9
9
|
description: config.description,
|
|
10
10
|
parameters: config.parameters,
|
|
11
|
-
execute: config.execute
|
|
11
|
+
execute: config.execute,
|
|
12
|
+
hidden: config.hidden
|
|
12
13
|
};
|
|
13
14
|
}
|
|
14
15
|
function toolToJsonSchema(toolDef) {
|
|
@@ -1252,7 +1253,8 @@ var Runtime = class {
|
|
|
1252
1253
|
actions: allActions.length > 0 ? allActions : void 0,
|
|
1253
1254
|
systemPrompt: request.systemPrompt || this.config.systemPrompt,
|
|
1254
1255
|
config: request.config,
|
|
1255
|
-
signal
|
|
1256
|
+
signal,
|
|
1257
|
+
webSearch: this.getWebSearchConfig()
|
|
1256
1258
|
};
|
|
1257
1259
|
const stream = this.adapter.stream(completionRequest);
|
|
1258
1260
|
for await (const event of stream) {
|
|
@@ -1560,6 +1562,15 @@ var Runtime = class {
|
|
|
1560
1562
|
}
|
|
1561
1563
|
return this.adapter.model;
|
|
1562
1564
|
}
|
|
1565
|
+
/**
|
|
1566
|
+
* Get web search configuration from runtime config
|
|
1567
|
+
*/
|
|
1568
|
+
getWebSearchConfig() {
|
|
1569
|
+
if ("webSearch" in this.config) {
|
|
1570
|
+
return this.config.webSearch;
|
|
1571
|
+
}
|
|
1572
|
+
return void 0;
|
|
1573
|
+
}
|
|
1563
1574
|
/**
|
|
1564
1575
|
* Process a chat request with tool support (Vercel AI SDK pattern)
|
|
1565
1576
|
*
|
|
@@ -1632,7 +1643,8 @@ var Runtime = class {
|
|
|
1632
1643
|
actions: this.convertToolsToActions(allTools),
|
|
1633
1644
|
systemPrompt,
|
|
1634
1645
|
config: request.config,
|
|
1635
|
-
signal
|
|
1646
|
+
signal,
|
|
1647
|
+
webSearch: this.getWebSearchConfig()
|
|
1636
1648
|
};
|
|
1637
1649
|
const stream = this.adapter.stream(completionRequest);
|
|
1638
1650
|
for await (const event of stream) {
|
|
@@ -1683,6 +1695,9 @@ var Runtime = class {
|
|
|
1683
1695
|
}
|
|
1684
1696
|
yield event;
|
|
1685
1697
|
break;
|
|
1698
|
+
case "citation":
|
|
1699
|
+
yield event;
|
|
1700
|
+
break;
|
|
1686
1701
|
case "error":
|
|
1687
1702
|
yield event;
|
|
1688
1703
|
return;
|
|
@@ -1923,7 +1938,8 @@ var Runtime = class {
|
|
|
1923
1938
|
actions: this.convertToolsToActions(allTools),
|
|
1924
1939
|
systemPrompt,
|
|
1925
1940
|
config: request.config,
|
|
1926
|
-
signal
|
|
1941
|
+
signal,
|
|
1942
|
+
webSearch: this.getWebSearchConfig()
|
|
1927
1943
|
};
|
|
1928
1944
|
try {
|
|
1929
1945
|
const result = await this.adapter.complete(completionRequest);
|