Skip to content

Commit

Permalink
Clear session on start (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
josejulio authored Dec 1, 2023
1 parent d989f95 commit 3139ff2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Components/AstroChat/useAstro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const messageProcessor = async (message: AssistantMessage | FeedbackMessage, pro

export interface AskOptions {
hideMessage: boolean;
hideResponse: boolean;
label: string;
waitResponses: boolean;
}
Expand All @@ -103,6 +104,7 @@ export const useAstro = (messageProcessors: Array<MessageProcessor>) => {
hideMessage: false,
label: message,
waitResponses: true,
hideResponse: false,
},
...options,
};
Expand All @@ -122,6 +124,10 @@ export const useAstro = (messageProcessors: Array<MessageProcessor>) => {
const postTalkResponse = postTalk(message);

const waitResponses = async () => {
if (options?.hideResponse) {
return;
}

await loadMessage(
From.ASSISTANT,
postTalkResponse.then((r) => r[0]),
Expand Down Expand Up @@ -152,6 +158,12 @@ export const useAstro = (messageProcessors: Array<MessageProcessor>) => {
if (status === Status.NOT_STARTED) {
setStatus(Status.LOADING);

await ask('/session_start', {
hideMessage: true,
hideResponse: true,
waitResponses: false,
});

await ask('/intent_core_session_start', {
hideMessage: true,
waitResponses: false,
Expand Down

0 comments on commit 3139ff2

Please sign in to comment.