From 03c71ee89256138911c795698d48811460316300 Mon Sep 17 00:00:00 2001 From: Harish Mohan Raj Date: Fri, 24 Nov 2023 18:21:24 +0530 Subject: [PATCH] Send user answer to the agent --- src/client/components/ConversationWrapper.tsx | 1 + src/server/actions.ts | 4 +++- src/server/webSocket.js | 5 ++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/client/components/ConversationWrapper.tsx b/src/client/components/ConversationWrapper.tsx index 98bfa70..be5bea6 100644 --- a/src/client/components/ConversationWrapper.tsx +++ b/src/client/components/ConversationWrapper.tsx @@ -104,6 +104,7 @@ export default function ConversationWrapper() { const response = await getAgentResponse({ message: payload.conversations, conv_id: payload.conversation_id, + is_answer_to_agent_question: conversations.status === "pause", }); // 3. add agent response as new conversation in the table const openAIResponse = { diff --git a/src/server/actions.ts b/src/server/actions.ts index b92fea2..8718760 100644 --- a/src/server/actions.ts +++ b/src/server/actions.ts @@ -223,10 +223,11 @@ export const updateConversation: UpdateConversation< type AgentPayload = { message: any; conv_id: number; + is_answer_to_agent_question?: boolean; }; export const getAgentResponse: GetAgentResponse = async ( - { message, conv_id }, + { message, conv_id, is_answer_to_agent_question }, context ) => { if (!context.user) { @@ -237,6 +238,7 @@ export const getAgentResponse: GetAgentResponse = async ( message: message, conv_id: conv_id, user_id: context.user.id, + is_answer_to_agent_question: is_answer_to_agent_question, }; console.log("==========="); console.log("Payload to Python server"); diff --git a/src/server/webSocket.js b/src/server/webSocket.js index 05b25ae..d273948 100644 --- a/src/server/webSocket.js +++ b/src/server/webSocket.js @@ -43,7 +43,10 @@ export const webSocketFn = (io, context) => { } const conversation_status = json["status"]; - if (conversation_status === "ready") { + if ( + conversation_status === "completed" || + conversation_status === "pause" + ) { const updated_conversation = conversation.conversation.concat([ { role: "assistant", content: json["msg"] }, ]);