mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +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 {Record<string, unknown> | undefined} metadata
|
||||
* @param {StandardGraph} graph
|
||||
* @returns
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
handle(event, data, metadata, graph) {
|
||||
async handle(event, data, metadata, graph) {
|
||||
if (!graph || !metadata) {
|
||||
console.warn(`Graph or metadata not found in ${event} event`);
|
||||
return;
|
||||
|
|
@ -79,7 +79,7 @@ class ModelEndHandler {
|
|||
}
|
||||
}
|
||||
if (isGoogle || streamingDisabled || hasUnprocessedToolCalls) {
|
||||
handleToolCalls(toolCalls, metadata, graph);
|
||||
await handleToolCalls(toolCalls, metadata, graph);
|
||||
}
|
||||
|
||||
const usage = data?.output?.usage_metadata;
|
||||
|
|
@ -101,7 +101,7 @@ class ModelEndHandler {
|
|||
const stepKey = graph.getStepKey(metadata);
|
||||
const message_id = getMessageId(stepKey, graph) ?? '';
|
||||
if (message_id) {
|
||||
graph.dispatchRunStep(stepKey, {
|
||||
await graph.dispatchRunStep(stepKey, {
|
||||
type: StepTypes.MESSAGE_CREATION,
|
||||
message_creation: {
|
||||
message_id,
|
||||
|
|
@ -111,7 +111,7 @@ class ModelEndHandler {
|
|||
const stepId = graph.getStepIdByKey(stepKey);
|
||||
const content = data.output.content;
|
||||
if (typeof content === 'string') {
|
||||
graph.dispatchMessageDelta(stepId, {
|
||||
await graph.dispatchMessageDelta(stepId, {
|
||||
content: [
|
||||
{
|
||||
type: 'text',
|
||||
|
|
@ -120,7 +120,7 @@ class ModelEndHandler {
|
|||
],
|
||||
});
|
||||
} else if (content.every((c) => c.type?.startsWith('text'))) {
|
||||
graph.dispatchMessageDelta(stepId, {
|
||||
await graph.dispatchMessageDelta(stepId, {
|
||||
content,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue