From 7ab6c5fb4fd750fec08d3a0afa53a4271261d32e Mon Sep 17 00:00:00 2001 From: Stanislas Polu Date: Fri, 15 Nov 2024 14:39:43 +0100 Subject: [PATCH] stepByIndex --- front/lib/api/assistant/jit_actions.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/front/lib/api/assistant/jit_actions.ts b/front/lib/api/assistant/jit_actions.ts index ab49892a8a24..71dd1b1db1f6 100644 --- a/front/lib/api/assistant/jit_actions.ts +++ b/front/lib/api/assistant/jit_actions.ts @@ -90,7 +90,7 @@ export async function renderConversationForModelJIT({ // calls). Actions all have a step index which indicates how they should be grouped but some // actions injected by `getEmulatedAgentMessageActions` have a step index of `-1`. We // therefore group by index, then order and transform in a 2D array to present to the model. - const stepsByStepIndex = {} as Record< + const stepByStepIndex = {} as Record< string, { contents: string[]; @@ -105,27 +105,26 @@ export async function renderConversationForModelJIT({ ({ contents: [], actions: [], - }) satisfies (typeof stepsByStepIndex)[number]; + }) satisfies (typeof stepByStepIndex)[number]; for (const action of actions) { const stepIndex = action.step; - stepsByStepIndex[stepIndex] = - stepsByStepIndex[stepIndex] || emptyStep(); - stepsByStepIndex[stepIndex].actions.push({ + stepByStepIndex[stepIndex] = stepByStepIndex[stepIndex] || emptyStep(); + stepByStepIndex[stepIndex].actions.push({ call: action.renderForFunctionCall(), result: action.renderForMultiActionsModel(), }); } for (const content of m.rawContents) { - stepsByStepIndex[content.step] = - stepsByStepIndex[content.step] || emptyStep(); + stepByStepIndex[content.step] = + stepByStepIndex[content.step] || emptyStep(); if (content.content.trim()) { - stepsByStepIndex[content.step].contents.push(content.content); + stepByStepIndex[content.step].contents.push(content.content); } } - const steps = Object.entries(stepsByStepIndex) + const steps = Object.entries(stepByStepIndex) .sort(([a], [b]) => Number(a) - Number(b)) .map(([, step]) => step);