From bec31917f1332749c8b1a2b74cbe4251704650e2 Mon Sep 17 00:00:00 2001 From: Mayur Virendra Date: Mon, 8 Apr 2024 23:59:19 +0530 Subject: [PATCH] fix for polygon resolution --- services/AI.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/services/AI.js b/services/AI.js index 87996b6..687390a 100644 --- a/services/AI.js +++ b/services/AI.js @@ -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