mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-19 09:50:15 +01:00
⚙️ refactor: OAuth Flow Signal, Type Safety, Tool Progress & Updated Packages (#6752)
* chore: bump @librechat/agents and related packages * refactor: update message state for tool calls run step, in case no tool call chunks are received * fix: avoid combining finalized args createContentAggregator for tool calls * chore: bump @librechat/agents to version 2.3.99 * feat: add support for aborting flows with AbortSignal in createFlow methods * fix: improve handling of tool call arguments in useStepHandler * chore: bump @librechat/agents to version 2.4.0 * fix: update flow identifier format for OAuth login in createActionTool to allow uniqueness per run * fix: improve error message handling for aborted flows in FlowStateManager * refactor: allow possible multi-agent cross-over for oauth login * fix: add type safety for Sandpack files in ArtifactCodeEditor
This commit is contained in:
parent
ac35b8490c
commit
9b0678da16
6 changed files with 953 additions and 981 deletions
|
|
@ -123,11 +123,14 @@ export default function useStepHandler({
|
|||
} else if (contentType === ContentTypes.TOOL_CALL && 'tool_call' in contentPart) {
|
||||
const existingContent = updatedContent[index] as Agents.ToolCallContent | undefined;
|
||||
const existingToolCall = existingContent?.tool_call;
|
||||
const toolCallArgs = (contentPart.tool_call.args as unknown as string | undefined) ?? '';
|
||||
|
||||
const args = finalUpdate
|
||||
? contentPart.tool_call.args
|
||||
: (existingToolCall?.args ?? '') + toolCallArgs;
|
||||
const toolCallArgs = (contentPart.tool_call as Agents.ToolCall).args;
|
||||
/** When args are a valid object, they are likely already invoked */
|
||||
const args =
|
||||
finalUpdate ||
|
||||
typeof existingToolCall?.args === 'object' ||
|
||||
typeof toolCallArgs === 'object'
|
||||
? contentPart.tool_call.args
|
||||
: (existingToolCall?.args ?? '') + (toolCallArgs ?? '');
|
||||
|
||||
const id = getNonEmptyValue([contentPart.tool_call.id, existingToolCall?.id]) ?? '';
|
||||
const name = getNonEmptyValue([contentPart.tool_call.name, existingToolCall?.name]) ?? '';
|
||||
|
|
@ -195,12 +198,31 @@ export default function useStepHandler({
|
|||
|
||||
// Store tool call IDs if present
|
||||
if (runStep.stepDetails.type === StepTypes.TOOL_CALLS) {
|
||||
runStep.stepDetails.tool_calls.forEach((toolCall) => {
|
||||
let updatedResponse = { ...response };
|
||||
(runStep.stepDetails.tool_calls as Agents.ToolCall[]).forEach((toolCall) => {
|
||||
const toolCallId = toolCall.id ?? '';
|
||||
if ('id' in toolCall && toolCallId) {
|
||||
toolCallIdMap.current.set(runStep.id, toolCallId);
|
||||
}
|
||||
|
||||
const contentPart: Agents.MessageContentComplex = {
|
||||
type: ContentTypes.TOOL_CALL,
|
||||
tool_call: {
|
||||
name: toolCall.name ?? '',
|
||||
args: toolCall.args,
|
||||
id: toolCallId,
|
||||
},
|
||||
};
|
||||
|
||||
updatedResponse = updateContent(updatedResponse, runStep.index, contentPart);
|
||||
});
|
||||
|
||||
messageMap.current.set(responseMessageId, updatedResponse);
|
||||
const updatedMessages = messages.map((msg) =>
|
||||
msg.messageId === runStep.runId ? updatedResponse : msg,
|
||||
);
|
||||
|
||||
setMessages(updatedMessages);
|
||||
}
|
||||
} else if (event === 'on_agent_update') {
|
||||
const { agent_update } = data as Agents.AgentUpdate;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue