@yourgpt/llm-sdk 2.0.0 → 2.0.2-beta.1
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 +17 -5
- package/dist/index.d.ts +17 -5
- package/dist/index.js +18 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -3
- 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-ClJBhmS0.d.mts} +427 -3
- package/dist/{base-DdxolpKP.d.ts → types-ClJBhmS0.d.ts} +427 -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-ClJBhmS0.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-ClJBhmS0.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
|
|
|
@@ -186,6 +184,11 @@ interface RuntimeConfigWithAdapter {
|
|
|
186
184
|
debug?: boolean;
|
|
187
185
|
/** Custom context data passed to all tool handlers */
|
|
188
186
|
toolContext?: Record<string, unknown>;
|
|
187
|
+
/**
|
|
188
|
+
* Enable native web search for the provider.
|
|
189
|
+
* Set to true for defaults, or pass WebSearchConfig for customization.
|
|
190
|
+
*/
|
|
191
|
+
webSearch?: boolean | WebSearchConfig;
|
|
189
192
|
}
|
|
190
193
|
/**
|
|
191
194
|
* Runtime configuration with AIProvider
|
|
@@ -220,6 +223,11 @@ interface RuntimeConfigWithProvider {
|
|
|
220
223
|
debug?: boolean;
|
|
221
224
|
/** Custom context data passed to all tool handlers */
|
|
222
225
|
toolContext?: Record<string, unknown>;
|
|
226
|
+
/**
|
|
227
|
+
* Enable native web search for the provider.
|
|
228
|
+
* Set to true for defaults, or pass WebSearchConfig for customization.
|
|
229
|
+
*/
|
|
230
|
+
webSearch?: boolean | WebSearchConfig;
|
|
223
231
|
}
|
|
224
232
|
/**
|
|
225
233
|
* Runtime configuration - provide either a provider instance or a custom adapter
|
|
@@ -848,6 +856,10 @@ declare class Runtime {
|
|
|
848
856
|
* Get the current model ID
|
|
849
857
|
*/
|
|
850
858
|
getModel(): string;
|
|
859
|
+
/**
|
|
860
|
+
* Get web search configuration from runtime config
|
|
861
|
+
*/
|
|
862
|
+
private getWebSearchConfig;
|
|
851
863
|
/**
|
|
852
864
|
* Process a chat request with tool support (Vercel AI SDK pattern)
|
|
853
865
|
*
|
|
@@ -1305,4 +1317,4 @@ declare function generateThreadId(): string;
|
|
|
1305
1317
|
*/
|
|
1306
1318
|
declare function generateToolCallId(): string;
|
|
1307
1319
|
|
|
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 };
|
|
1320
|
+
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-ClJBhmS0.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-ClJBhmS0.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
|
|
|
@@ -186,6 +184,11 @@ interface RuntimeConfigWithAdapter {
|
|
|
186
184
|
debug?: boolean;
|
|
187
185
|
/** Custom context data passed to all tool handlers */
|
|
188
186
|
toolContext?: Record<string, unknown>;
|
|
187
|
+
/**
|
|
188
|
+
* Enable native web search for the provider.
|
|
189
|
+
* Set to true for defaults, or pass WebSearchConfig for customization.
|
|
190
|
+
*/
|
|
191
|
+
webSearch?: boolean | WebSearchConfig;
|
|
189
192
|
}
|
|
190
193
|
/**
|
|
191
194
|
* Runtime configuration with AIProvider
|
|
@@ -220,6 +223,11 @@ interface RuntimeConfigWithProvider {
|
|
|
220
223
|
debug?: boolean;
|
|
221
224
|
/** Custom context data passed to all tool handlers */
|
|
222
225
|
toolContext?: Record<string, unknown>;
|
|
226
|
+
/**
|
|
227
|
+
* Enable native web search for the provider.
|
|
228
|
+
* Set to true for defaults, or pass WebSearchConfig for customization.
|
|
229
|
+
*/
|
|
230
|
+
webSearch?: boolean | WebSearchConfig;
|
|
223
231
|
}
|
|
224
232
|
/**
|
|
225
233
|
* Runtime configuration - provide either a provider instance or a custom adapter
|
|
@@ -848,6 +856,10 @@ declare class Runtime {
|
|
|
848
856
|
* Get the current model ID
|
|
849
857
|
*/
|
|
850
858
|
getModel(): string;
|
|
859
|
+
/**
|
|
860
|
+
* Get web search configuration from runtime config
|
|
861
|
+
*/
|
|
862
|
+
private getWebSearchConfig;
|
|
851
863
|
/**
|
|
852
864
|
* Process a chat request with tool support (Vercel AI SDK pattern)
|
|
853
865
|
*
|
|
@@ -1305,4 +1317,4 @@ declare function generateThreadId(): string;
|
|
|
1305
1317
|
*/
|
|
1306
1318
|
declare function generateToolCallId(): string;
|
|
1307
1319
|
|
|
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 };
|
|
1320
|
+
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
|
@@ -1252,7 +1252,8 @@ var Runtime = class {
|
|
|
1252
1252
|
actions: allActions.length > 0 ? allActions : void 0,
|
|
1253
1253
|
systemPrompt: request.systemPrompt || this.config.systemPrompt,
|
|
1254
1254
|
config: request.config,
|
|
1255
|
-
signal
|
|
1255
|
+
signal,
|
|
1256
|
+
webSearch: this.getWebSearchConfig()
|
|
1256
1257
|
};
|
|
1257
1258
|
const stream = this.adapter.stream(completionRequest);
|
|
1258
1259
|
for await (const event of stream) {
|
|
@@ -1560,6 +1561,15 @@ var Runtime = class {
|
|
|
1560
1561
|
}
|
|
1561
1562
|
return this.adapter.model;
|
|
1562
1563
|
}
|
|
1564
|
+
/**
|
|
1565
|
+
* Get web search configuration from runtime config
|
|
1566
|
+
*/
|
|
1567
|
+
getWebSearchConfig() {
|
|
1568
|
+
if ("webSearch" in this.config) {
|
|
1569
|
+
return this.config.webSearch;
|
|
1570
|
+
}
|
|
1571
|
+
return void 0;
|
|
1572
|
+
}
|
|
1563
1573
|
/**
|
|
1564
1574
|
* Process a chat request with tool support (Vercel AI SDK pattern)
|
|
1565
1575
|
*
|
|
@@ -1632,7 +1642,8 @@ var Runtime = class {
|
|
|
1632
1642
|
actions: this.convertToolsToActions(allTools),
|
|
1633
1643
|
systemPrompt,
|
|
1634
1644
|
config: request.config,
|
|
1635
|
-
signal
|
|
1645
|
+
signal,
|
|
1646
|
+
webSearch: this.getWebSearchConfig()
|
|
1636
1647
|
};
|
|
1637
1648
|
const stream = this.adapter.stream(completionRequest);
|
|
1638
1649
|
for await (const event of stream) {
|
|
@@ -1683,6 +1694,9 @@ var Runtime = class {
|
|
|
1683
1694
|
}
|
|
1684
1695
|
yield event;
|
|
1685
1696
|
break;
|
|
1697
|
+
case "citation":
|
|
1698
|
+
yield event;
|
|
1699
|
+
break;
|
|
1686
1700
|
case "error":
|
|
1687
1701
|
yield event;
|
|
1688
1702
|
return;
|
|
@@ -1923,7 +1937,8 @@ var Runtime = class {
|
|
|
1923
1937
|
actions: this.convertToolsToActions(allTools),
|
|
1924
1938
|
systemPrompt,
|
|
1925
1939
|
config: request.config,
|
|
1926
|
-
signal
|
|
1940
|
+
signal,
|
|
1941
|
+
webSearch: this.getWebSearchConfig()
|
|
1927
1942
|
};
|
|
1928
1943
|
try {
|
|
1929
1944
|
const result = await this.adapter.complete(completionRequest);
|