Skip to content

Commit

Permalink
Integrate Captn agent (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
harishmohanraj authored Nov 14, 2023
2 parents 1d16006 + b19fbe0 commit 9fca95e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/client/ChatPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ export default function ChatPage(props) {
}
await updateConversation(payload)
// 2. call backend python server to get agent response
const response = await getAgentResponse({conversation: payload.conversations})
const response = await getAgentResponse({
message: userQuery,
conv_id: payload.conversation_id,
})
// 3. add agent response as new conversation in the table
const openAIPayload = {
conversation_id: conversations.id,
Expand Down
7 changes: 4 additions & 3 deletions src/server/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,18 +202,19 @@ export const updateConversation: UpdateConversation<UpdateConversationPayload, C
}

type AgentPayload = {
conversation: any;
message: string;
conv_id: number;
};

export const getAgentResponse: GetAgentResponse<AgentPayload> = async (
{ conversation },
{ message, conv_id },
context
) => {
if (!context.user) {
throw new HttpError(401);
}

const payload = { conversation: conversation };
const payload = { message: message, conv_id: conv_id, user_id: context.user.id };
try {
const response = await fetch(`${ADS_SERVER_URL}/chat`, {
method: 'POST',
Expand Down

0 comments on commit 9fca95e

Please sign in to comment.