Skip to content

Commit

Permalink
Added messages to users while AI process a user message
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurvir committed Apr 2, 2024
1 parent 578d29c commit 4930dd5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions controllers/Bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ async function process_text(req, res) {
session.text.push({ role: 'assistant', content: response.formatted });
}
else{
response = await process_action(ai.action, message, session.actions);
response = await process_action(ai.action, message, session.actions, sender);

// update actions
if(response.formatted && response.raw){
Expand Down Expand Up @@ -164,7 +164,7 @@ async function process_text(req, res) {
* @param {*} actions_context
* @returns
*/
async function process_action(action, text, actions_context){
async function process_action(action, text, actions_context, sender=null){
let ai = new AI();
let response = {
raw: null,
Expand All @@ -173,6 +173,8 @@ async function process_action(action, text, actions_context){

ai.action = action;

actionsService.send_message(sender, `_Please wait while we process your request through open networks..._`)

// Get schema
const schema = await ai.get_schema_by_action(action.action);

Expand All @@ -186,6 +188,7 @@ async function process_action(action, text, actions_context){
if(request.status){
// call api
const api_response = await actionsService.call_api(request.data.url, request.data.method, request.data.body, request.data.headers)
actionsService.send_message(sender, `_Your request is processed, generating a response..._`)
if(!api_response.status){
response.formatted = `Failed to call the API: ${api_response.error}`
}
Expand Down

0 comments on commit 4930dd5

Please sign in to comment.