Skip to content

Commit

Permalink
fix: resolve issue by using a better approach to display user message…
Browse files Browse the repository at this point in the history
…s during interrupt (#165)
  • Loading branch information
Onelevenvy authored Dec 26, 2024
1 parent 686b61c commit 28c2b8e
Showing 1 changed file with 12 additions and 25 deletions.
37 changes: 12 additions & 25 deletions web/src/components/Playground/ChatMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -334,19 +334,17 @@ const ChatMain = ({ isPlayground }: { isPlayground?: boolean }) => {
return;
}

// 只有在非中断情况下才添加用户消息
if (!data.interrupt) {
setMessages((prev: ChatResponse[]) => [
...prev,
{
type: "human",
id: v4(),
content: input,
imgdata: imageData,
name: "user",
},
]);
}
setMessages((prev: ChatResponse[]) => [
...prev,
{
type: "human",
// id: self.crypto.randomUUID(),
id: v4(),
content: data.messages[0].content,
imgdata: imageData,
name: "user",
},
]);

await stream(teamId, currentThreadId, data);
};
Expand Down Expand Up @@ -401,17 +399,6 @@ const ChatMain = ({ isPlayground }: { isPlayground?: boolean }) => {
*/
const onResumeHandler = useCallback(
(decision: InterruptDecision, tool_message?: string | null) => {
// 在mutation之前,先添加用户的响应消息
setMessages((prev) => [
...prev,
{
type: "human",
id: v4(),
content: tool_message || decision,
name: "user",
},
]);

mutation.mutate({
messages: [
{
Expand All @@ -422,7 +409,7 @@ const ChatMain = ({ isPlayground }: { isPlayground?: boolean }) => {
interrupt: { decision, tool_message },
});
},
[mutation, setMessages]
[mutation]
);

return (
Expand Down

0 comments on commit 28c2b8e

Please sign in to comment.