Skip to content

Commit

Permalink
Added missing avoid points
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurvir committed Apr 11, 2024
1 parent 2502f69 commit 729d0a7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: []
}


6 changes: 3 additions & 3 deletions controllers/Bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand All @@ -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}`);

Expand Down
2 changes: 1 addition & 1 deletion services/AI.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions services/MapService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);

Expand Down Expand Up @@ -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: {},
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 729d0a7

Please sign in to comment.