Skip to content

Commit

Permalink
Update flow for conversational queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Amruth-Vamshi committed Dec 7, 2023
1 parent 9703113 commit 671fa8e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ export class AppController {
this.monitoringService.incrementTotalSessionsInEnglishCount();
break;
}
messageType = "final_response"
messageType = botFlowService.state.context.queryType == "convo" ? "convo_response" : "final_response"
if(botFlowService.state.context.isWadhwaniResponse == 'false'){
let resArray = result.text.split("\n")
let compareText = result.textInEnglish.split('\n')
Expand Down
2 changes: 1 addition & 1 deletion src/xstate/prompt/prompt.gaurds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ export const promptGuards = {

ifInvalidClassifier: (_,event) => event.data == "invalid",

ifConvoStarterOrEnder: (_,event) => event.data == "convo_starter" || event.data == "convo_ender"
ifConvoStarterOrEnder: (_,event) => event.data == "convo"

}
9 changes: 4 additions & 5 deletions src/xstate/prompt/prompt.machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -878,12 +878,11 @@ export const botFlowMachine3:any =
onDone: [
{
cond: "ifConvoStarterOrEnder",
target: "getUserQuestion",
target: "wadhwaniClassifier",
actions: [
assign({
response: () => engMessage["message.convoStarter"],
type:"pause",
isWadhwaniResponse: "false"
queryType: (_,event) => event.data,
isWadhwaniResponse: "true"
})
]
},
Expand All @@ -900,7 +899,7 @@ export const botFlowMachine3:any =
target: 'checkIfOTPHasBeenVerified',
actions: [
assign({
queryType: (_,event) => {console.log(`assigning queryType = ${event.data}`); return event.data},
queryType: (_,event) => event.data,
isWadhwaniResponse: "false"
})
]
Expand Down
3 changes: 3 additions & 0 deletions src/xstate/prompt/prompt.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export class PromptServices {
try{
let response: any = await this.aiToolsService.textClassification(context.query)
if (response.error) throw new Error(`${response.error}, please try again.`)
if (response == `"Invalid"`) return "convo"
if (response == `"convo_starter"`) return "convo"
if (response == `"convo_ender"`) return "convo"
if (response == `"Installment not received"`) return "payment"
else {
return "invalid"
Expand Down

0 comments on commit 671fa8e

Please sign in to comment.