Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Captn agent #25

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading