Skip to content

Commit

Permalink
fix for polygon resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurvir committed Apr 8, 2024
1 parent b55c946 commit bec3191
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions services/AI.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,15 +324,19 @@ class AI {
});
const responseMessage = JSON.parse(response.choices[0].message?.tool_calls[0]?.function?.arguments) || null;
logger.info(`Got beckn message from instruction : ${JSON.stringify(responseMessage)}`);
if(this.action?.action=='search' && polygon && responseMessage?.intent?.fulfillment?.stops[0]?.location){
responseMessage.intent.fulfillment.stops[0].location.polygon = polygon;
const route_image = `https://maps.googleapis.com/maps/api/staticmap?size=300x300&path=color:%231d3b65|weight:5|enc:${polygon}&key=${process.env.GOOGLE_MAPS_API_KEY}`;
logger.info(`Map url for request : ${route_image}`)
// temp
delete responseMessage.intent.fulfillment.stops[0].location.gps;
if(this.action?.action=='search' && responseMessage?.intent?.fulfillment?.stops[0]?.location){
if(polygon){
responseMessage.intent.fulfillment.stops[0].location.polygon = polygon;
const route_image = `https://maps.googleapis.com/maps/api/staticmap?size=300x300&path=color:%231d3b65|weight:5|enc:${polygon}&key=${process.env.GOOGLE_MAPS_API_KEY}`;
logger.info(`Map url for request : ${route_image}`)
// temp
delete responseMessage.intent.fulfillment.stops[0].location.gps;
}
else delete responseMessage.intent.fulfillment.stops[0].location.polygon;

}
else{
delete responseMessage.intent.fulfillment.stops[0].location.polygon

}

return responseMessage
Expand Down

0 comments on commit bec3191

Please sign in to comment.