@yourgpt/llm-sdk 2.1.3 → 2.1.4-alpha.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/README.md +59 -0
- package/dist/adapters/index.d.mts +9 -2
- package/dist/adapters/index.d.ts +9 -2
- package/dist/adapters/index.js +421 -19
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/index.mjs +421 -19
- package/dist/adapters/index.mjs.map +1 -1
- package/dist/index.d.mts +164 -11
- package/dist/index.d.ts +164 -11
- package/dist/index.js +638 -54
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +635 -55
- package/dist/index.mjs.map +1 -1
- package/dist/providers/anthropic/index.d.mts +1 -1
- package/dist/providers/anthropic/index.d.ts +1 -1
- package/dist/providers/anthropic/index.js +95 -1
- package/dist/providers/anthropic/index.js.map +1 -1
- package/dist/providers/anthropic/index.mjs +95 -1
- package/dist/providers/anthropic/index.mjs.map +1 -1
- package/dist/providers/azure/index.d.mts +1 -1
- package/dist/providers/azure/index.d.ts +1 -1
- package/dist/providers/azure/index.js +51 -5
- package/dist/providers/azure/index.js.map +1 -1
- package/dist/providers/azure/index.mjs +51 -5
- package/dist/providers/azure/index.mjs.map +1 -1
- package/dist/providers/google/index.d.mts +1 -1
- package/dist/providers/google/index.d.ts +1 -1
- package/dist/providers/google/index.js +76 -0
- package/dist/providers/google/index.js.map +1 -1
- package/dist/providers/google/index.mjs +76 -0
- package/dist/providers/google/index.mjs.map +1 -1
- package/dist/providers/ollama/index.d.mts +2 -2
- package/dist/providers/ollama/index.d.ts +2 -2
- package/dist/providers/ollama/index.js +51 -8
- package/dist/providers/ollama/index.js.map +1 -1
- package/dist/providers/ollama/index.mjs +51 -8
- package/dist/providers/ollama/index.mjs.map +1 -1
- package/dist/providers/openai/index.d.mts +1 -1
- package/dist/providers/openai/index.d.ts +1 -1
- package/dist/providers/openai/index.js +301 -3
- package/dist/providers/openai/index.js.map +1 -1
- package/dist/providers/openai/index.mjs +301 -3
- package/dist/providers/openai/index.mjs.map +1 -1
- package/dist/providers/openrouter/index.d.mts +1 -1
- package/dist/providers/openrouter/index.d.ts +1 -1
- package/dist/providers/openrouter/index.js +301 -3
- package/dist/providers/openrouter/index.js.map +1 -1
- package/dist/providers/openrouter/index.mjs +301 -3
- package/dist/providers/openrouter/index.mjs.map +1 -1
- package/dist/providers/xai/index.d.mts +1 -1
- package/dist/providers/xai/index.d.ts +1 -1
- package/dist/providers/xai/index.js +51 -5
- package/dist/providers/xai/index.js.map +1 -1
- package/dist/providers/xai/index.mjs +51 -5
- package/dist/providers/xai/index.mjs.map +1 -1
- package/dist/{types-D20jKwJW.d.mts → types-COAOEe_y.d.mts} +68 -8
- package/dist/{types-D20jKwJW.d.ts → types-COAOEe_y.d.ts} +68 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -55,6 +55,65 @@ export async function POST(req: Request) {
|
|
|
55
55
|
}
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
+
## Selective Tool Loading
|
|
59
|
+
|
|
60
|
+
`llm-sdk` can now narrow tools before they reach the provider. This is opt-in and works with both local ranking and provider-native hints.
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { createRuntime, type ToolDefinition } from "@yourgpt/llm-sdk";
|
|
64
|
+
import { createOpenAI } from "@yourgpt/llm-sdk/openai";
|
|
65
|
+
|
|
66
|
+
const tools: ToolDefinition[] = [
|
|
67
|
+
{
|
|
68
|
+
name: "search_docs",
|
|
69
|
+
description: "Search product docs",
|
|
70
|
+
location: "server",
|
|
71
|
+
category: "knowledge",
|
|
72
|
+
profiles: ["support", "research"],
|
|
73
|
+
searchKeywords: ["docs", "kb", "help"],
|
|
74
|
+
inputSchema: { type: "object", properties: { query: { type: "string" } } },
|
|
75
|
+
handler: async ({ query }) => ({ query }),
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "get_time",
|
|
79
|
+
description: "Get current time",
|
|
80
|
+
location: "server",
|
|
81
|
+
category: "utility",
|
|
82
|
+
profiles: ["utility"],
|
|
83
|
+
deferLoading: true,
|
|
84
|
+
inputSchema: { type: "object", properties: {} },
|
|
85
|
+
handler: async () => ({ now: new Date().toISOString() }),
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
|
|
89
|
+
const runtime = createRuntime({
|
|
90
|
+
provider: createOpenAI({ apiKey: process.env.OPENAI_API_KEY }),
|
|
91
|
+
model: "gpt-4o-mini",
|
|
92
|
+
tools,
|
|
93
|
+
agentLoop: {
|
|
94
|
+
enabled: true,
|
|
95
|
+
toolSelection: {
|
|
96
|
+
enabled: true,
|
|
97
|
+
defaultProfile: "support",
|
|
98
|
+
search: {
|
|
99
|
+
enabled: true,
|
|
100
|
+
maxResults: 4,
|
|
101
|
+
exposeWhenToolCountExceeds: 1,
|
|
102
|
+
},
|
|
103
|
+
dynamicSelection: { enabled: true, maxTools: 2 },
|
|
104
|
+
nativeProviderHints: {
|
|
105
|
+
openai: { toolChoice: "single", parallelToolCalls: false },
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// Request body can override the active profile:
|
|
112
|
+
// { "messages": [...], "toolProfile": "utility" }
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
When `search.enabled` is on, deferred tools can be discovered through a hidden `search_tools` server tool. Matching tools are loaded into the next loop iteration instead of sending every deferred tool definition up front.
|
|
116
|
+
|
|
58
117
|
## Documentation
|
|
59
118
|
|
|
60
119
|
Visit **[copilot-sdk.yourgpt.ai](https://copilot-sdk.yourgpt.ai)** for full documentation:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LLMAdapter, W as WebSearchConfig,
|
|
2
|
-
export {
|
|
1
|
+
import { L as LLMAdapter, W as WebSearchConfig, Q as ChatCompletionRequest, g as StreamEvent, ap as CompletionResult, a3 as OllamaModelOptions } from '../types-COAOEe_y.mjs';
|
|
2
|
+
export { V as AdapterFactory, aB as AnthropicContentBlock, aC as OpenAIContentBlock, az as attachmentToAnthropicDocument, ay as attachmentToAnthropicImage, aA as attachmentToOpenAIImage, aq as formatMessages, as as formatMessagesForAnthropic, at as formatMessagesForOpenAI, ar as formatTools, aw as hasImageAttachments, ax as hasMediaAttachments, au as messageToAnthropicContent, av as messageToOpenAIContent } from '../types-COAOEe_y.mjs';
|
|
3
3
|
import 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -29,7 +29,13 @@ declare class OpenAIAdapter implements LLMAdapter {
|
|
|
29
29
|
private config;
|
|
30
30
|
constructor(config: OpenAIAdapterConfig);
|
|
31
31
|
private getClient;
|
|
32
|
+
private shouldUseResponsesApi;
|
|
33
|
+
private buildResponsesInput;
|
|
34
|
+
private buildResponsesTools;
|
|
35
|
+
private parseResponsesResult;
|
|
36
|
+
private completeWithResponses;
|
|
32
37
|
stream(request: ChatCompletionRequest): AsyncGenerator<StreamEvent>;
|
|
38
|
+
complete(request: ChatCompletionRequest): Promise<CompletionResult>;
|
|
33
39
|
}
|
|
34
40
|
/**
|
|
35
41
|
* Create OpenAI adapter
|
|
@@ -86,6 +92,7 @@ declare class AnthropicAdapter implements LLMAdapter {
|
|
|
86
92
|
* - { role: "user", content: [{ type: "tool_result", tool_use_id: "...", content: "..." }] }
|
|
87
93
|
*/
|
|
88
94
|
private convertToAnthropicMessages;
|
|
95
|
+
private buildNativeSearchTools;
|
|
89
96
|
/**
|
|
90
97
|
* Build common request options for both streaming and non-streaming
|
|
91
98
|
*/
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LLMAdapter, W as WebSearchConfig,
|
|
2
|
-
export {
|
|
1
|
+
import { L as LLMAdapter, W as WebSearchConfig, Q as ChatCompletionRequest, g as StreamEvent, ap as CompletionResult, a3 as OllamaModelOptions } from '../types-COAOEe_y.js';
|
|
2
|
+
export { V as AdapterFactory, aB as AnthropicContentBlock, aC as OpenAIContentBlock, az as attachmentToAnthropicDocument, ay as attachmentToAnthropicImage, aA as attachmentToOpenAIImage, aq as formatMessages, as as formatMessagesForAnthropic, at as formatMessagesForOpenAI, ar as formatTools, aw as hasImageAttachments, ax as hasMediaAttachments, au as messageToAnthropicContent, av as messageToOpenAIContent } from '../types-COAOEe_y.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -29,7 +29,13 @@ declare class OpenAIAdapter implements LLMAdapter {
|
|
|
29
29
|
private config;
|
|
30
30
|
constructor(config: OpenAIAdapterConfig);
|
|
31
31
|
private getClient;
|
|
32
|
+
private shouldUseResponsesApi;
|
|
33
|
+
private buildResponsesInput;
|
|
34
|
+
private buildResponsesTools;
|
|
35
|
+
private parseResponsesResult;
|
|
36
|
+
private completeWithResponses;
|
|
32
37
|
stream(request: ChatCompletionRequest): AsyncGenerator<StreamEvent>;
|
|
38
|
+
complete(request: ChatCompletionRequest): Promise<CompletionResult>;
|
|
33
39
|
}
|
|
34
40
|
/**
|
|
35
41
|
* Create OpenAI adapter
|
|
@@ -86,6 +92,7 @@ declare class AnthropicAdapter implements LLMAdapter {
|
|
|
86
92
|
* - { role: "user", content: [{ type: "tool_result", tool_use_id: "...", content: "..." }] }
|
|
87
93
|
*/
|
|
88
94
|
private convertToAnthropicMessages;
|
|
95
|
+
private buildNativeSearchTools;
|
|
89
96
|
/**
|
|
90
97
|
* Build common request options for both streaming and non-streaming
|
|
91
98
|
*/
|