Skip to content

Commit

Permalink
feat: added getConvo Api
Browse files Browse the repository at this point in the history
  • Loading branch information
VishalPawar1010 committed Jul 25, 2024
1 parent 907ca97 commit ea2b9dc
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/app/components/Copilot/Copilot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function CopilotChat(): React.JSX.Element {
setConversations(allConversations);
// console.log('allConversations', allConversations);
if (allConversations.length > 0) {
const { id, name } = allConversations[0];
const { id, name, messages } = allConversations[0];
GlobalConversationID = id;
setChatSelected(name);
}
Expand All @@ -103,6 +103,22 @@ export function CopilotChat(): React.JSX.Element {
if (selectedConversation) {
GlobalConversationID = selectedId;
setChatSelected(selectedConversation.name);
const getConversationMessage = async (selectedId) => {
try {
const {rawMessages} = await piecesClient.getConversation({
conversationId: selectedId,
includeRawMessages: true,
});
// console.log("getMessages === ",rawMessages);
if (rawMessages.length>1) {
setMessage(rawMessages[1].message)
}
else setMessage("No previous conversation history, please ask the question below.");
} catch (error) {
console.error('Error fetching conversations:', error);
}
}
getConversationMessage(selectedId);
}
};

Expand Down

0 comments on commit ea2b9dc

Please sign in to comment.