mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
⏳ fix: Async Model End Events, Await Tool Call and Dispatch Handling (#10552)
This commit is contained in:
parent
49c57b27fd
commit
bdc47dbe47
1 changed files with 6 additions and 6 deletions
|
|
@ -39,9 +39,9 @@ class ModelEndHandler {
|
||||||
* @param {ModelEndData | undefined} data
|
* @param {ModelEndData | undefined} data
|
||||||
* @param {Record<string, unknown> | undefined} metadata
|
* @param {Record<string, unknown> | undefined} metadata
|
||||||
* @param {StandardGraph} graph
|
* @param {StandardGraph} graph
|
||||||
* @returns
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
handle(event, data, metadata, graph) {
|
async handle(event, data, metadata, graph) {
|
||||||
if (!graph || !metadata) {
|
if (!graph || !metadata) {
|
||||||
console.warn(`Graph or metadata not found in ${event} event`);
|
console.warn(`Graph or metadata not found in ${event} event`);
|
||||||
return;
|
return;
|
||||||
|
|
@ -79,7 +79,7 @@ class ModelEndHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isGoogle || streamingDisabled || hasUnprocessedToolCalls) {
|
if (isGoogle || streamingDisabled || hasUnprocessedToolCalls) {
|
||||||
handleToolCalls(toolCalls, metadata, graph);
|
await handleToolCalls(toolCalls, metadata, graph);
|
||||||
}
|
}
|
||||||
|
|
||||||
const usage = data?.output?.usage_metadata;
|
const usage = data?.output?.usage_metadata;
|
||||||
|
|
@ -101,7 +101,7 @@ class ModelEndHandler {
|
||||||
const stepKey = graph.getStepKey(metadata);
|
const stepKey = graph.getStepKey(metadata);
|
||||||
const message_id = getMessageId(stepKey, graph) ?? '';
|
const message_id = getMessageId(stepKey, graph) ?? '';
|
||||||
if (message_id) {
|
if (message_id) {
|
||||||
graph.dispatchRunStep(stepKey, {
|
await graph.dispatchRunStep(stepKey, {
|
||||||
type: StepTypes.MESSAGE_CREATION,
|
type: StepTypes.MESSAGE_CREATION,
|
||||||
message_creation: {
|
message_creation: {
|
||||||
message_id,
|
message_id,
|
||||||
|
|
@ -111,7 +111,7 @@ class ModelEndHandler {
|
||||||
const stepId = graph.getStepIdByKey(stepKey);
|
const stepId = graph.getStepIdByKey(stepKey);
|
||||||
const content = data.output.content;
|
const content = data.output.content;
|
||||||
if (typeof content === 'string') {
|
if (typeof content === 'string') {
|
||||||
graph.dispatchMessageDelta(stepId, {
|
await graph.dispatchMessageDelta(stepId, {
|
||||||
content: [
|
content: [
|
||||||
{
|
{
|
||||||
type: 'text',
|
type: 'text',
|
||||||
|
|
@ -120,7 +120,7 @@ class ModelEndHandler {
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
} else if (content.every((c) => c.type?.startsWith('text'))) {
|
} else if (content.every((c) => c.type?.startsWith('text'))) {
|
||||||
graph.dispatchMessageDelta(stepId, {
|
await graph.dispatchMessageDelta(stepId, {
|
||||||
content,
|
content,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue