@yourgpt/llm-sdk 2.1.10-alpha.0 → 2.5.1-beta.0
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 -38
- package/dist/adapters/index.d.ts +4 -38
- package/dist/adapters/index.js +158 -325
- package/dist/adapters/index.mjs +158 -325
- package/dist/base-C58Dsr9p.d.ts +259 -0
- package/dist/base-tNgbBaSo.d.mts +259 -0
- package/dist/fallback/index.d.mts +4 -4
- package/dist/fallback/index.d.ts +4 -4
- package/dist/index.d.mts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +35 -43
- package/dist/index.mjs +35 -43
- package/dist/providers/anthropic/index.d.mts +3 -3
- package/dist/providers/anthropic/index.d.ts +3 -3
- package/dist/providers/anthropic/index.js +271 -212
- package/dist/providers/anthropic/index.mjs +271 -212
- package/dist/providers/azure/index.d.mts +3 -3
- package/dist/providers/azure/index.d.ts +3 -3
- package/dist/providers/azure/index.js +49 -1
- package/dist/providers/azure/index.mjs +49 -1
- package/dist/providers/fireworks/index.d.mts +1 -1
- package/dist/providers/fireworks/index.d.ts +1 -1
- package/dist/providers/fireworks/index.js +56 -0
- package/dist/providers/fireworks/index.mjs +56 -0
- package/dist/providers/google/index.d.mts +3 -3
- package/dist/providers/google/index.d.ts +3 -3
- package/dist/providers/google/index.js +254 -510
- package/dist/providers/google/index.mjs +254 -510
- package/dist/providers/ollama/index.d.mts +4 -4
- package/dist/providers/ollama/index.d.ts +4 -4
- package/dist/providers/ollama/index.js +10 -2
- package/dist/providers/ollama/index.mjs +10 -2
- package/dist/providers/openai/index.d.mts +3 -3
- package/dist/providers/openai/index.d.ts +3 -3
- package/dist/providers/openai/index.js +269 -529
- package/dist/providers/openai/index.mjs +269 -529
- package/dist/providers/openrouter/index.d.mts +3 -7
- package/dist/providers/openrouter/index.d.ts +3 -7
- package/dist/providers/openrouter/index.js +365 -902
- package/dist/providers/openrouter/index.mjs +365 -902
- package/dist/providers/togetherai/index.d.mts +3 -3
- package/dist/providers/togetherai/index.d.ts +3 -3
- package/dist/providers/togetherai/index.js +259 -509
- package/dist/providers/togetherai/index.mjs +259 -509
- package/dist/providers/xai/index.d.mts +3 -3
- package/dist/providers/xai/index.d.ts +3 -3
- package/dist/providers/xai/index.js +258 -513
- package/dist/providers/xai/index.mjs +258 -513
- package/dist/{types-BNCmlJMs.d.mts → types-B6dhnguR.d.mts} +1 -1
- package/dist/{types-DhktekQ3.d.ts → types-BQ31QIsA.d.ts} +2 -1
- package/dist/{types-CMMQ8s2O.d.mts → types-BSSiJW2o.d.mts} +2 -1
- package/dist/{base-DN1EfKnE.d.mts → types-BkQCSiIt.d.mts} +388 -214
- package/dist/{base-DuUNxtVg.d.ts → types-BkQCSiIt.d.ts} +388 -214
- package/dist/{types-Pj-vpmoT.d.ts → types-CCxPmkmK.d.ts} +1 -1
- package/dist/yourgpt/index.d.mts +1 -1
- package/dist/yourgpt/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/types-CMvvDo-E.d.mts +0 -428
- package/dist/types-CMvvDo-E.d.ts +0 -428
package/dist/index.js
CHANGED
|
@@ -135,6 +135,11 @@ function formatToolsForGoogle(tools) {
|
|
|
135
135
|
// src/core/generate-text.ts
|
|
136
136
|
async function generateText(params) {
|
|
137
137
|
const { model, tools, maxSteps = 1, signal } = params;
|
|
138
|
+
if (params.responseFormat && model.capabilities.supportsJsonMode === false) {
|
|
139
|
+
console.warn(
|
|
140
|
+
`[llm-sdk] ${model.provider}/${model.modelId} does not support structured output (responseFormat); the request will be sent but the provider may ignore it.`
|
|
141
|
+
);
|
|
142
|
+
}
|
|
138
143
|
let messages = buildMessages(params);
|
|
139
144
|
const steps = [];
|
|
140
145
|
const allToolCalls = [];
|
|
@@ -149,6 +154,7 @@ async function generateText(params) {
|
|
|
149
154
|
tools: formattedTools,
|
|
150
155
|
temperature: params.temperature,
|
|
151
156
|
maxTokens: params.maxTokens,
|
|
157
|
+
responseFormat: params.responseFormat,
|
|
152
158
|
signal
|
|
153
159
|
});
|
|
154
160
|
const stepToolResults = [];
|
|
@@ -266,6 +272,11 @@ function sumUsage(steps) {
|
|
|
266
272
|
// src/core/stream-text.ts
|
|
267
273
|
async function streamText(params) {
|
|
268
274
|
const { model, tools, maxSteps = 1, signal } = params;
|
|
275
|
+
if (params.responseFormat && model.capabilities.supportsJsonMode === false) {
|
|
276
|
+
console.warn(
|
|
277
|
+
`[llm-sdk] ${model.provider}/${model.modelId} does not support structured output (responseFormat); the request will be sent but the provider may ignore it.`
|
|
278
|
+
);
|
|
279
|
+
}
|
|
269
280
|
let fullText = "";
|
|
270
281
|
let finalUsage = {
|
|
271
282
|
promptTokens: 0,
|
|
@@ -291,6 +302,7 @@ async function streamText(params) {
|
|
|
291
302
|
tools: formattedTools,
|
|
292
303
|
temperature: params.temperature,
|
|
293
304
|
maxTokens: params.maxTokens,
|
|
305
|
+
responseFormat: params.responseFormat,
|
|
294
306
|
signal
|
|
295
307
|
})) {
|
|
296
308
|
switch (chunk.type) {
|
|
@@ -299,20 +311,6 @@ async function streamText(params) {
|
|
|
299
311
|
fullText += chunk.text;
|
|
300
312
|
yield { type: "text-delta", text: chunk.text };
|
|
301
313
|
break;
|
|
302
|
-
case "tool-call-start":
|
|
303
|
-
yield {
|
|
304
|
-
type: "tool-call-start",
|
|
305
|
-
toolCallId: chunk.toolCallId,
|
|
306
|
-
toolName: chunk.toolName
|
|
307
|
-
};
|
|
308
|
-
break;
|
|
309
|
-
case "tool-call-delta":
|
|
310
|
-
yield {
|
|
311
|
-
type: "tool-call-delta",
|
|
312
|
-
toolCallId: chunk.toolCallId,
|
|
313
|
-
argsText: chunk.argsText
|
|
314
|
-
};
|
|
315
|
-
break;
|
|
316
314
|
case "tool-call":
|
|
317
315
|
toolCalls.push(chunk.toolCall);
|
|
318
316
|
yield {
|
|
@@ -1611,7 +1609,7 @@ var Runtime = class {
|
|
|
1611
1609
|
const completionRequest = {
|
|
1612
1610
|
messages,
|
|
1613
1611
|
actions: allActions.length > 0 ? allActions : void 0,
|
|
1614
|
-
systemPrompt:
|
|
1612
|
+
systemPrompt: request.systemPrompt || this.config.systemPrompt,
|
|
1615
1613
|
config: request.config,
|
|
1616
1614
|
signal,
|
|
1617
1615
|
webSearch: this.getWebSearchConfig(),
|
|
@@ -2175,7 +2173,7 @@ var Runtime = class {
|
|
|
2175
2173
|
}
|
|
2176
2174
|
}
|
|
2177
2175
|
}
|
|
2178
|
-
const systemPrompt =
|
|
2176
|
+
const systemPrompt = request.systemPrompt || this.config.systemPrompt || "";
|
|
2179
2177
|
let accumulatedText = "";
|
|
2180
2178
|
const toolCalls = [];
|
|
2181
2179
|
let currentToolCall = null;
|
|
@@ -2222,44 +2220,38 @@ var Runtime = class {
|
|
|
2222
2220
|
break;
|
|
2223
2221
|
case "action:args":
|
|
2224
2222
|
if (currentToolCall) {
|
|
2225
|
-
currentToolCall.args = event.args || currentToolCall.args;
|
|
2226
2223
|
try {
|
|
2227
|
-
const parsedArgs = JSON.parse(
|
|
2228
|
-
const existingIdx = toolCalls.findIndex(
|
|
2229
|
-
(t) => t.id === currentToolCall.id
|
|
2230
|
-
);
|
|
2231
|
-
const entry = {
|
|
2232
|
-
id: currentToolCall.id,
|
|
2233
|
-
name: currentToolCall.name,
|
|
2234
|
-
args: parsedArgs,
|
|
2235
|
-
...currentToolCall.extra_content ? { extra_content: currentToolCall.extra_content } : {}
|
|
2236
|
-
};
|
|
2237
|
-
if (existingIdx >= 0) {
|
|
2238
|
-
toolCalls[existingIdx] = entry;
|
|
2239
|
-
} else {
|
|
2240
|
-
toolCalls.push(entry);
|
|
2241
|
-
}
|
|
2224
|
+
const parsedArgs = JSON.parse(event.args || "{}");
|
|
2242
2225
|
if (debug) {
|
|
2243
2226
|
console.log(
|
|
2244
2227
|
`[Copilot SDK] Tool args for ${currentToolCall.name}:`,
|
|
2245
2228
|
parsedArgs
|
|
2246
2229
|
);
|
|
2247
2230
|
}
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2231
|
+
toolCalls.push({
|
|
2232
|
+
id: currentToolCall.id,
|
|
2233
|
+
name: currentToolCall.name,
|
|
2234
|
+
args: parsedArgs,
|
|
2235
|
+
...currentToolCall.extra_content ? { extra_content: currentToolCall.extra_content } : {}
|
|
2236
|
+
});
|
|
2237
|
+
} catch (e) {
|
|
2238
|
+
console.error(
|
|
2239
|
+
"[Copilot SDK] Failed to parse tool args:",
|
|
2240
|
+
event.args,
|
|
2241
|
+
e
|
|
2242
|
+
);
|
|
2243
|
+
toolCalls.push({
|
|
2244
|
+
id: currentToolCall.id,
|
|
2245
|
+
name: currentToolCall.name,
|
|
2246
|
+
args: {},
|
|
2247
|
+
...currentToolCall.extra_content ? { extra_content: currentToolCall.extra_content } : {}
|
|
2248
|
+
});
|
|
2257
2249
|
}
|
|
2250
|
+
currentToolCall = null;
|
|
2258
2251
|
}
|
|
2259
2252
|
yield event;
|
|
2260
2253
|
break;
|
|
2261
2254
|
case "action:end": {
|
|
2262
|
-
currentToolCall = null;
|
|
2263
2255
|
const toolName = event.name;
|
|
2264
2256
|
const tool2 = toolName ? selectedToolMap.get(toolName) : void 0;
|
|
2265
2257
|
if (tool2?.location === "server" && tool2.handler) {
|
|
@@ -2469,7 +2461,7 @@ var Runtime = class {
|
|
|
2469
2461
|
const allTools = this.collectToolsForRequest(request);
|
|
2470
2462
|
const nativeToolSearch = this.resolveNativeToolSearchForRequest(request);
|
|
2471
2463
|
let toolSearchState = _toolSearchState;
|
|
2472
|
-
const systemPrompt =
|
|
2464
|
+
const systemPrompt = request.systemPrompt || this.config.systemPrompt || "";
|
|
2473
2465
|
let iteration = 0;
|
|
2474
2466
|
let conversationMessages = request.messages;
|
|
2475
2467
|
while (iteration < maxIterations) {
|
package/dist/index.mjs
CHANGED
|
@@ -133,6 +133,11 @@ function formatToolsForGoogle(tools) {
|
|
|
133
133
|
// src/core/generate-text.ts
|
|
134
134
|
async function generateText(params) {
|
|
135
135
|
const { model, tools, maxSteps = 1, signal } = params;
|
|
136
|
+
if (params.responseFormat && model.capabilities.supportsJsonMode === false) {
|
|
137
|
+
console.warn(
|
|
138
|
+
`[llm-sdk] ${model.provider}/${model.modelId} does not support structured output (responseFormat); the request will be sent but the provider may ignore it.`
|
|
139
|
+
);
|
|
140
|
+
}
|
|
136
141
|
let messages = buildMessages(params);
|
|
137
142
|
const steps = [];
|
|
138
143
|
const allToolCalls = [];
|
|
@@ -147,6 +152,7 @@ async function generateText(params) {
|
|
|
147
152
|
tools: formattedTools,
|
|
148
153
|
temperature: params.temperature,
|
|
149
154
|
maxTokens: params.maxTokens,
|
|
155
|
+
responseFormat: params.responseFormat,
|
|
150
156
|
signal
|
|
151
157
|
});
|
|
152
158
|
const stepToolResults = [];
|
|
@@ -264,6 +270,11 @@ function sumUsage(steps) {
|
|
|
264
270
|
// src/core/stream-text.ts
|
|
265
271
|
async function streamText(params) {
|
|
266
272
|
const { model, tools, maxSteps = 1, signal } = params;
|
|
273
|
+
if (params.responseFormat && model.capabilities.supportsJsonMode === false) {
|
|
274
|
+
console.warn(
|
|
275
|
+
`[llm-sdk] ${model.provider}/${model.modelId} does not support structured output (responseFormat); the request will be sent but the provider may ignore it.`
|
|
276
|
+
);
|
|
277
|
+
}
|
|
267
278
|
let fullText = "";
|
|
268
279
|
let finalUsage = {
|
|
269
280
|
promptTokens: 0,
|
|
@@ -289,6 +300,7 @@ async function streamText(params) {
|
|
|
289
300
|
tools: formattedTools,
|
|
290
301
|
temperature: params.temperature,
|
|
291
302
|
maxTokens: params.maxTokens,
|
|
303
|
+
responseFormat: params.responseFormat,
|
|
292
304
|
signal
|
|
293
305
|
})) {
|
|
294
306
|
switch (chunk.type) {
|
|
@@ -297,20 +309,6 @@ async function streamText(params) {
|
|
|
297
309
|
fullText += chunk.text;
|
|
298
310
|
yield { type: "text-delta", text: chunk.text };
|
|
299
311
|
break;
|
|
300
|
-
case "tool-call-start":
|
|
301
|
-
yield {
|
|
302
|
-
type: "tool-call-start",
|
|
303
|
-
toolCallId: chunk.toolCallId,
|
|
304
|
-
toolName: chunk.toolName
|
|
305
|
-
};
|
|
306
|
-
break;
|
|
307
|
-
case "tool-call-delta":
|
|
308
|
-
yield {
|
|
309
|
-
type: "tool-call-delta",
|
|
310
|
-
toolCallId: chunk.toolCallId,
|
|
311
|
-
argsText: chunk.argsText
|
|
312
|
-
};
|
|
313
|
-
break;
|
|
314
312
|
case "tool-call":
|
|
315
313
|
toolCalls.push(chunk.toolCall);
|
|
316
314
|
yield {
|
|
@@ -1609,7 +1607,7 @@ var Runtime = class {
|
|
|
1609
1607
|
const completionRequest = {
|
|
1610
1608
|
messages,
|
|
1611
1609
|
actions: allActions.length > 0 ? allActions : void 0,
|
|
1612
|
-
systemPrompt:
|
|
1610
|
+
systemPrompt: request.systemPrompt || this.config.systemPrompt,
|
|
1613
1611
|
config: request.config,
|
|
1614
1612
|
signal,
|
|
1615
1613
|
webSearch: this.getWebSearchConfig(),
|
|
@@ -2173,7 +2171,7 @@ var Runtime = class {
|
|
|
2173
2171
|
}
|
|
2174
2172
|
}
|
|
2175
2173
|
}
|
|
2176
|
-
const systemPrompt =
|
|
2174
|
+
const systemPrompt = request.systemPrompt || this.config.systemPrompt || "";
|
|
2177
2175
|
let accumulatedText = "";
|
|
2178
2176
|
const toolCalls = [];
|
|
2179
2177
|
let currentToolCall = null;
|
|
@@ -2220,44 +2218,38 @@ var Runtime = class {
|
|
|
2220
2218
|
break;
|
|
2221
2219
|
case "action:args":
|
|
2222
2220
|
if (currentToolCall) {
|
|
2223
|
-
currentToolCall.args = event.args || currentToolCall.args;
|
|
2224
2221
|
try {
|
|
2225
|
-
const parsedArgs = JSON.parse(
|
|
2226
|
-
const existingIdx = toolCalls.findIndex(
|
|
2227
|
-
(t) => t.id === currentToolCall.id
|
|
2228
|
-
);
|
|
2229
|
-
const entry = {
|
|
2230
|
-
id: currentToolCall.id,
|
|
2231
|
-
name: currentToolCall.name,
|
|
2232
|
-
args: parsedArgs,
|
|
2233
|
-
...currentToolCall.extra_content ? { extra_content: currentToolCall.extra_content } : {}
|
|
2234
|
-
};
|
|
2235
|
-
if (existingIdx >= 0) {
|
|
2236
|
-
toolCalls[existingIdx] = entry;
|
|
2237
|
-
} else {
|
|
2238
|
-
toolCalls.push(entry);
|
|
2239
|
-
}
|
|
2222
|
+
const parsedArgs = JSON.parse(event.args || "{}");
|
|
2240
2223
|
if (debug) {
|
|
2241
2224
|
console.log(
|
|
2242
2225
|
`[Copilot SDK] Tool args for ${currentToolCall.name}:`,
|
|
2243
2226
|
parsedArgs
|
|
2244
2227
|
);
|
|
2245
2228
|
}
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2229
|
+
toolCalls.push({
|
|
2230
|
+
id: currentToolCall.id,
|
|
2231
|
+
name: currentToolCall.name,
|
|
2232
|
+
args: parsedArgs,
|
|
2233
|
+
...currentToolCall.extra_content ? { extra_content: currentToolCall.extra_content } : {}
|
|
2234
|
+
});
|
|
2235
|
+
} catch (e) {
|
|
2236
|
+
console.error(
|
|
2237
|
+
"[Copilot SDK] Failed to parse tool args:",
|
|
2238
|
+
event.args,
|
|
2239
|
+
e
|
|
2240
|
+
);
|
|
2241
|
+
toolCalls.push({
|
|
2242
|
+
id: currentToolCall.id,
|
|
2243
|
+
name: currentToolCall.name,
|
|
2244
|
+
args: {},
|
|
2245
|
+
...currentToolCall.extra_content ? { extra_content: currentToolCall.extra_content } : {}
|
|
2246
|
+
});
|
|
2255
2247
|
}
|
|
2248
|
+
currentToolCall = null;
|
|
2256
2249
|
}
|
|
2257
2250
|
yield event;
|
|
2258
2251
|
break;
|
|
2259
2252
|
case "action:end": {
|
|
2260
|
-
currentToolCall = null;
|
|
2261
2253
|
const toolName = event.name;
|
|
2262
2254
|
const tool2 = toolName ? selectedToolMap.get(toolName) : void 0;
|
|
2263
2255
|
if (tool2?.location === "server" && tool2.handler) {
|
|
@@ -2467,7 +2459,7 @@ var Runtime = class {
|
|
|
2467
2459
|
const allTools = this.collectToolsForRequest(request);
|
|
2468
2460
|
const nativeToolSearch = this.resolveNativeToolSearchForRequest(request);
|
|
2469
2461
|
let toolSearchState = _toolSearchState;
|
|
2470
|
-
const systemPrompt =
|
|
2462
|
+
const systemPrompt = request.systemPrompt || this.config.systemPrompt || "";
|
|
2471
2463
|
let iteration = 0;
|
|
2472
2464
|
let conversationMessages = request.messages;
|
|
2473
2465
|
while (iteration < maxIterations) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { L as LanguageModel } from '../../types-
|
|
2
|
-
import { a as AnthropicProviderConfig, A as AIProvider } from '../../types-
|
|
1
|
+
import { L as LanguageModel } from '../../types-BkQCSiIt.mjs';
|
|
2
|
+
import { a as AnthropicProviderConfig, A as AIProvider } from '../../types-BSSiJW2o.mjs';
|
|
3
3
|
import 'zod';
|
|
4
|
-
import '../../base-
|
|
4
|
+
import '../../base-tNgbBaSo.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Anthropic Provider - Modern Pattern
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { L as LanguageModel } from '../../types-
|
|
2
|
-
import { a as AnthropicProviderConfig, A as AIProvider } from '../../types-
|
|
1
|
+
import { L as LanguageModel } from '../../types-BkQCSiIt.js';
|
|
2
|
+
import { a as AnthropicProviderConfig, A as AIProvider } from '../../types-BQ31QIsA.js';
|
|
3
3
|
import 'zod';
|
|
4
|
-
import '../../base-
|
|
4
|
+
import '../../base-C58Dsr9p.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Anthropic Provider - Modern Pattern
|