Merge pull request #112 from hylkesybesma/fix-render-interrupt
fix: render interrupt after tool result
This commit is contained in:
@@ -65,6 +65,32 @@ function parseAnthropicStreamedToolCalls(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface InterruptProps {
|
||||||
|
interruptValue?: unknown;
|
||||||
|
isLastMessage: boolean;
|
||||||
|
hasNoAIOrToolMessages: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
function Interrupt({
|
||||||
|
interruptValue,
|
||||||
|
isLastMessage,
|
||||||
|
hasNoAIOrToolMessages,
|
||||||
|
}: InterruptProps) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{isAgentInboxInterruptSchema(interruptValue) &&
|
||||||
|
(isLastMessage || hasNoAIOrToolMessages) && (
|
||||||
|
<ThreadView interrupt={interruptValue} />
|
||||||
|
)}
|
||||||
|
{interruptValue &&
|
||||||
|
!isAgentInboxInterruptSchema(interruptValue) &&
|
||||||
|
isLastMessage ? (
|
||||||
|
<GenericInterruptView interrupt={interruptValue} />
|
||||||
|
) : null}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function AssistantMessage({
|
export function AssistantMessage({
|
||||||
message,
|
message,
|
||||||
isLoading,
|
isLoading,
|
||||||
@@ -114,64 +140,71 @@ export function AssistantMessage({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="group mr-auto flex items-start gap-2">
|
<div className="group mr-auto flex items-start gap-2">
|
||||||
{isToolResult ? (
|
<div className="flex flex-col gap-2">
|
||||||
<ToolResult message={message} />
|
{isToolResult ? (
|
||||||
) : (
|
<>
|
||||||
<div className="flex flex-col gap-2">
|
<ToolResult message={message} />
|
||||||
{contentString.length > 0 && (
|
<Interrupt
|
||||||
<div className="py-1">
|
interruptValue={threadInterrupt?.value}
|
||||||
<MarkdownText>{contentString}</MarkdownText>
|
isLastMessage={isLastMessage}
|
||||||
</div>
|
hasNoAIOrToolMessages={hasNoAIOrToolMessages}
|
||||||
)}
|
/>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
{contentString.length > 0 && (
|
||||||
|
<div className="py-1">
|
||||||
|
<MarkdownText>{contentString}</MarkdownText>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{!hideToolCalls && (
|
{!hideToolCalls && (
|
||||||
<>
|
<>
|
||||||
{(hasToolCalls && toolCallsHaveContents && (
|
{(hasToolCalls && toolCallsHaveContents && (
|
||||||
<ToolCalls toolCalls={message.tool_calls} />
|
<ToolCalls toolCalls={message.tool_calls} />
|
||||||
)) ||
|
|
||||||
(hasAnthropicToolCalls && (
|
|
||||||
<ToolCalls toolCalls={anthropicStreamedToolCalls} />
|
|
||||||
)) ||
|
)) ||
|
||||||
(hasToolCalls && <ToolCalls toolCalls={message.tool_calls} />)}
|
(hasAnthropicToolCalls && (
|
||||||
</>
|
<ToolCalls toolCalls={anthropicStreamedToolCalls} />
|
||||||
)}
|
)) ||
|
||||||
|
(hasToolCalls && (
|
||||||
|
<ToolCalls toolCalls={message.tool_calls} />
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
{message && (
|
{message && (
|
||||||
<CustomComponent
|
<CustomComponent
|
||||||
message={message}
|
message={message}
|
||||||
thread={thread}
|
thread={thread}
|
||||||
/>
|
/>
|
||||||
)}
|
|
||||||
{isAgentInboxInterruptSchema(threadInterrupt?.value) &&
|
|
||||||
(isLastMessage || hasNoAIOrToolMessages) && (
|
|
||||||
<ThreadView interrupt={threadInterrupt.value} />
|
|
||||||
)}
|
)}
|
||||||
{threadInterrupt?.value &&
|
<Interrupt
|
||||||
!isAgentInboxInterruptSchema(threadInterrupt.value) &&
|
interruptValue={threadInterrupt?.value}
|
||||||
isLastMessage ? (
|
isLastMessage={isLastMessage}
|
||||||
<GenericInterruptView interrupt={threadInterrupt.value} />
|
hasNoAIOrToolMessages={hasNoAIOrToolMessages}
|
||||||
) : null}
|
|
||||||
<div
|
|
||||||
className={cn(
|
|
||||||
"mr-auto flex items-center gap-2 transition-opacity",
|
|
||||||
"opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<BranchSwitcher
|
|
||||||
branch={meta?.branch}
|
|
||||||
branchOptions={meta?.branchOptions}
|
|
||||||
onSelect={(branch) => thread.setBranch(branch)}
|
|
||||||
isLoading={isLoading}
|
|
||||||
/>
|
/>
|
||||||
<CommandBar
|
<div
|
||||||
content={contentString}
|
className={cn(
|
||||||
isLoading={isLoading}
|
"mr-auto flex items-center gap-2 transition-opacity",
|
||||||
isAiMessage={true}
|
"opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",
|
||||||
handleRegenerate={() => handleRegenerate(parentCheckpoint)}
|
)}
|
||||||
/>
|
>
|
||||||
</div>
|
<BranchSwitcher
|
||||||
</div>
|
branch={meta?.branch}
|
||||||
)}
|
branchOptions={meta?.branchOptions}
|
||||||
|
onSelect={(branch) => thread.setBranch(branch)}
|
||||||
|
isLoading={isLoading}
|
||||||
|
/>
|
||||||
|
<CommandBar
|
||||||
|
content={contentString}
|
||||||
|
isLoading={isLoading}
|
||||||
|
isAiMessage={true}
|
||||||
|
handleRegenerate={() => handleRegenerate(parentCheckpoint)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user