Skip to content

Commit

Permalink
Send user answer to the agent
Browse files Browse the repository at this point in the history
  • Loading branch information
harishmohanraj committed Nov 24, 2023
1 parent 2fe3ca5 commit 03c71ee
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/client/components/ConversationWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 3 additions & 1 deletion src/server/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AgentPayload> = async (
{ message, conv_id },
{ message, conv_id, is_answer_to_agent_question },
context
) => {
if (!context.user) {
Expand All @@ -237,6 +238,7 @@ export const getAgentResponse: GetAgentResponse<AgentPayload> = 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");
Expand Down
5 changes: 4 additions & 1 deletion src/server/webSocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"] },
]);
Expand Down

0 comments on commit 03c71ee

Please sign in to comment.