diff --git a/config/constants.js b/config/constants.js index 7886446..b927e2b 100644 --- a/config/constants.js +++ b/config/constants.js @@ -67,7 +67,8 @@ export const EMPTY_SESSION = { routes:[], orders:[], last_action:false, - beckn_transaction : EMPTY_BECKN_TRANSACTION + beckn_transaction : EMPTY_BECKN_TRANSACTION, + avoid_point: [] } diff --git a/controllers/Bot.js b/controllers/Bot.js index db65d21..31802f7 100644 --- a/controllers/Bot.js +++ b/controllers/Bot.js @@ -102,7 +102,7 @@ async function process_text(req, res) { if(ai.action?.action === 'get_routes'){ const routes = await mapService.generate_routes(message, session.text, session.avoid_point|| []); - const formatting_response = await ai.format_response(routes.data?.routes_formatted || routes.errors, [{ role: 'user', content: message },...session.text]); + const formatting_response = await ai.format_response(routes.data?.routes_formatted || routes.errors, [{ role: 'user', content: message }]); response.formatted = formatting_response.message; session.routes = routes.data?.routes || session.routes; logger.info(`AI response: ${response.formatted}`); @@ -128,8 +128,8 @@ async function process_text(req, res) { } session.routes=[]; // reset routes } - const formatting_response = await ai.format_response(route_response, [{ role: 'user', content: message },...session.text]); - response.formatted = formatting_response.message; + // const formatting_response = await ai.format_response(route_response, [{ role: 'user', content: message },...session.text]); + response.formatted = route_response.message; logger.info(`AI response: ${response.formatted}`); diff --git a/services/AI.js b/services/AI.js index 2d3e7f7..390a254 100644 --- a/services/AI.js +++ b/services/AI.js @@ -287,7 +287,7 @@ class AI { try{ // Assuming you have a function to abstract the API call const response = await openai.chat.completions.create({ - model: process.env.OPENAI_MODEL_ID, //'gpt-4-0125-preview', + model: 'gpt-4-0125-preview', messages: messages, tools: tools, tool_choice: "auto", // auto is default, but we'll be explicit diff --git a/services/MapService.js b/services/MapService.js index 6df0153..22a04f9 100644 --- a/services/MapService.js +++ b/services/MapService.js @@ -27,6 +27,7 @@ class MapsService { if(!status) routes.push(route) } + const path = this.get_static_image_path(routes); logger.info(`Static image path for routes: ${path}`); @@ -68,7 +69,7 @@ class MapsService { return encodeURIComponent(color); } - async generate_routes(message, context=[]) { + async generate_routes(message, context=[], avoid_point=[]) { let response = { status:false, data: {}, @@ -106,7 +107,7 @@ class MapsService { } else{ // generate routes - const routes = await this.getRoutes(`${source_gps.lat},${source_gps.lng}`, `${destination_gps.lat},${destination_gps.lng}`); + const routes = await this.getRoutes(`${source_gps.lat},${source_gps.lng}`, `${destination_gps.lat},${destination_gps.lng}`, avoid_point); response.data.routes = routes.map(route=>{ return { overview_polyline: route.overview_polyline,