u
This commit is contained in:
@@ -90,7 +90,7 @@ class LLMOrbiter {
|
|||||||
throw new TypeError('run({ messages }): messages must be an array, or omit it for a fresh conversation');
|
throw new TypeError('run({ messages }): messages must be an array, or omit it for a fresh conversation');
|
||||||
}
|
}
|
||||||
|
|
||||||
const { onLLMCall, onUsage, onToolCall, onToolError, onToolResult, onStatus, onContent, onReasoning } = this;
|
const { onLLMCall, onUsage, onToolCall, onToolError, onToolResult, onStatus, onContent, onReasoning, onAssistantMessage } = this;
|
||||||
|
|
||||||
// Keep an internal controller so callers can cancel a run through orbiter.abort().
|
// Keep an internal controller so callers can cancel a run through orbiter.abort().
|
||||||
// The external signal remains supported and is forwarded into the same controller.
|
// The external signal remains supported and is forwarded into the same controller.
|
||||||
@@ -214,6 +214,13 @@ class LLMOrbiter {
|
|||||||
...(completion.reasoning ? { reasoning: completion.reasoning } : {}),
|
...(completion.reasoning ? { reasoning: completion.reasoning } : {}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await call(onAssistantMessage, {
|
||||||
|
content: content || null,
|
||||||
|
tool_calls: hasToolCalls ? toolCalls : undefined,
|
||||||
|
reasoning_details: completion.reasoning_details,
|
||||||
|
reasoning: completion.reasoning,
|
||||||
|
});
|
||||||
|
|
||||||
// No tool calls → done
|
// No tool calls → done
|
||||||
if (!hasToolCalls) {
|
if (!hasToolCalls) {
|
||||||
finalContent = content;
|
finalContent = content;
|
||||||
|
|||||||
@@ -193,11 +193,22 @@ class OpenRouterProvider {
|
|||||||
if (!result.reasoning_details) result.reasoning_details = [];
|
if (!result.reasoning_details) result.reasoning_details = [];
|
||||||
let detailsText = '';
|
let detailsText = '';
|
||||||
for (const rd of choice.delta.reasoning_details) {
|
for (const rd of choice.delta.reasoning_details) {
|
||||||
const slot = result.reasoning_details[rd.index] ||= { type: rd.type, format: rd.format, text: '' };
|
const idx = rd.index != null ? rd.index : result.reasoning_details.length;
|
||||||
|
const slot = result.reasoning_details[idx] ||= {};
|
||||||
|
if (rd.type) slot.type = rd.type;
|
||||||
|
if (rd.format) slot.format = rd.format;
|
||||||
|
if (rd.id) slot.id = rd.id;
|
||||||
|
if (rd.index != null) slot.index = rd.index;
|
||||||
if (rd.text) {
|
if (rd.text) {
|
||||||
slot.text += rd.text;
|
slot.text = (slot.text || '') + rd.text;
|
||||||
detailsText += rd.text;
|
detailsText += rd.text;
|
||||||
}
|
}
|
||||||
|
if (rd.summary) {
|
||||||
|
slot.summary = (slot.summary || '') + rd.summary;
|
||||||
|
}
|
||||||
|
if (rd.data) {
|
||||||
|
slot.data = (slot.data || '') + rd.data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!reasoningText && detailsText) {
|
if (!reasoningText && detailsText) {
|
||||||
reasoningText = detailsText;
|
reasoningText = detailsText;
|
||||||
|
|||||||
Reference in New Issue
Block a user