@tinyweb_dev/agent-framework-llm 0.3.0 → 0.4.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/index.cjs +29 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -11
- package/dist/index.js.map +1 -1
- package/dist/protocols/openai-chat.cjs +30 -11
- package/dist/protocols/openai-chat.cjs.map +1 -1
- package/dist/protocols/openai-chat.d.ts +25 -0
- package/dist/protocols/openai-chat.d.ts.map +1 -1
- package/dist/protocols/openai-chat.js +30 -12
- package/dist/protocols/openai-chat.js.map +1 -1
- package/dist/protocols/openai-compatible-chat.cjs +28 -11
- package/dist/protocols/openai-compatible-chat.cjs.map +1 -1
- package/dist/protocols/openai-compatible-chat.js +28 -11
- package/dist/protocols/openai-compatible-chat.js.map +1 -1
- package/dist/providers/openai-compatible.cjs +28 -11
- package/dist/providers/openai-compatible.cjs.map +1 -1
- package/dist/providers/openai-compatible.js +28 -11
- package/dist/providers/openai-compatible.js.map +1 -1
- package/dist/providers/openai.cjs +28 -11
- package/dist/providers/openai.cjs.map +1 -1
- package/dist/providers/openai.js +28 -11
- package/dist/providers/openai.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -2051,6 +2051,7 @@ __export(openai_chat_exports, {
|
|
|
2051
2051
|
bodyFields: () => bodyFields,
|
|
2052
2052
|
httpTransport: () => httpTransport,
|
|
2053
2053
|
model: () => model2,
|
|
2054
|
+
normaliseTextDelta: () => normaliseTextDelta,
|
|
2054
2055
|
protocol: () => protocol,
|
|
2055
2056
|
route: () => route
|
|
2056
2057
|
});
|
|
@@ -2284,6 +2285,14 @@ var OpenAIChatToolCallDelta = effect$1.Schema.Struct({
|
|
|
2284
2285
|
});
|
|
2285
2286
|
var OpenAIChatDelta = effect$1.Schema.Struct({
|
|
2286
2287
|
content: optionalNull(effect$1.Schema.String),
|
|
2288
|
+
/**
|
|
2289
|
+
* Thinking / chain-of-thought stream. DeepSeek + MiniMax native and
|
|
2290
|
+
* LiteLLM-normalized gateways use `reasoning_content`; OpenRouter (and some
|
|
2291
|
+
* Grok mirrors) use `reasoning`. Either must become `reasoning-delta` so
|
|
2292
|
+
* UIs are not stuck on a pre-text thinking spinner while the wire is live.
|
|
2293
|
+
*/
|
|
2294
|
+
reasoning_content: optionalNull(effect$1.Schema.String),
|
|
2295
|
+
reasoning: optionalNull(effect$1.Schema.String),
|
|
2287
2296
|
tool_calls: optionalNull(effect$1.Schema.Array(OpenAIChatToolCallDelta))
|
|
2288
2297
|
});
|
|
2289
2298
|
var OpenAIChatChoice = effect$1.Schema.Struct({
|
|
@@ -2440,16 +2449,17 @@ var mapUsage = (usage) => {
|
|
|
2440
2449
|
providerMetadata: { openai: usage }
|
|
2441
2450
|
});
|
|
2442
2451
|
};
|
|
2443
|
-
var normaliseTextDelta = (prev, incoming) => {
|
|
2444
|
-
if (!incoming) return { emit: "", textAcc: prev };
|
|
2445
|
-
if (
|
|
2446
|
-
|
|
2447
|
-
|
|
2452
|
+
var normaliseTextDelta = (prev, incoming, mode = "unknown") => {
|
|
2453
|
+
if (!incoming) return { emit: "", textAcc: prev, mode };
|
|
2454
|
+
if (mode === "unknown") {
|
|
2455
|
+
if (prev.length === 0) return { emit: incoming, textAcc: incoming, mode };
|
|
2456
|
+
mode = incoming.length > prev.length && incoming.startsWith(prev) ? "cumulative" : "incremental";
|
|
2448
2457
|
}
|
|
2449
|
-
if (
|
|
2450
|
-
return { emit:
|
|
2458
|
+
if (mode === "cumulative") {
|
|
2459
|
+
if (incoming.startsWith(prev)) return { emit: incoming.slice(prev.length), textAcc: incoming, mode };
|
|
2460
|
+
if (prev.startsWith(incoming)) return { emit: "", textAcc: prev, mode };
|
|
2451
2461
|
}
|
|
2452
|
-
return { emit: incoming, textAcc: prev + incoming };
|
|
2462
|
+
return { emit: incoming, textAcc: prev + incoming, mode };
|
|
2453
2463
|
};
|
|
2454
2464
|
var step = (state, event) => effect$1.Effect.gen(function* () {
|
|
2455
2465
|
const events = [];
|
|
@@ -2460,9 +2470,15 @@ var step = (state, event) => effect$1.Effect.gen(function* () {
|
|
|
2460
2470
|
const toolDeltas = delta?.tool_calls ?? [];
|
|
2461
2471
|
let tools = state.tools;
|
|
2462
2472
|
let textAcc = state.textAcc;
|
|
2473
|
+
let textMode = state.textMode;
|
|
2474
|
+
const reasoningChunk = delta?.reasoning_content ?? delta?.reasoning;
|
|
2475
|
+
if (reasoningChunk) {
|
|
2476
|
+
events.push(LLMEvent.reasoningDelta({ id: "reasoning-0", text: reasoningChunk }));
|
|
2477
|
+
}
|
|
2463
2478
|
if (delta?.content) {
|
|
2464
|
-
const normalised = normaliseTextDelta(textAcc, delta.content);
|
|
2479
|
+
const normalised = normaliseTextDelta(textAcc, delta.content, textMode);
|
|
2465
2480
|
textAcc = normalised.textAcc;
|
|
2481
|
+
textMode = normalised.mode;
|
|
2466
2482
|
if (normalised.emit) {
|
|
2467
2483
|
events.push(LLMEvent.textDelta({ id: "text-0", text: normalised.emit }));
|
|
2468
2484
|
}
|
|
@@ -2486,7 +2502,8 @@ var step = (state, event) => effect$1.Effect.gen(function* () {
|
|
|
2486
2502
|
toolCallEvents: finished?.events ?? state.toolCallEvents,
|
|
2487
2503
|
usage,
|
|
2488
2504
|
finishReason,
|
|
2489
|
-
textAcc
|
|
2505
|
+
textAcc,
|
|
2506
|
+
textMode
|
|
2490
2507
|
},
|
|
2491
2508
|
events
|
|
2492
2509
|
];
|
|
@@ -2507,7 +2524,8 @@ var protocol = protocol_exports.make({
|
|
|
2507
2524
|
initial: () => ({
|
|
2508
2525
|
tools: tool_stream_exports.empty(),
|
|
2509
2526
|
toolCallEvents: [],
|
|
2510
|
-
textAcc: ""
|
|
2527
|
+
textAcc: "",
|
|
2528
|
+
textMode: "unknown"
|
|
2511
2529
|
}),
|
|
2512
2530
|
step,
|
|
2513
2531
|
onHalt: finishEvents
|