Spaces:
Sleeping
Sleeping
Upload 157 files
Browse files- src/apis/controllers/__pycache__/destination_controller.cpython-311.pyc +0 -0
- src/apis/controllers/destination_controller.py +20 -5
- src/langgraph/tools/__pycache__/destination_tools.cpython-311.pyc +0 -0
- src/langgraph/tools/destination_tools.py +3 -4
- src/utils/__pycache__/helper.cpython-311.pyc +0 -0
- src/utils/helper.py +6 -4
src/apis/controllers/__pycache__/destination_controller.cpython-311.pyc
CHANGED
|
Binary files a/src/apis/controllers/__pycache__/destination_controller.cpython-311.pyc and b/src/apis/controllers/__pycache__/destination_controller.cpython-311.pyc differ
|
|
|
src/apis/controllers/destination_controller.py
CHANGED
|
@@ -54,16 +54,23 @@ async def destination_suggestion_controller(
|
|
| 54 |
raise HTTPException(status_code=500, detail=f"Request failed: {str(e)}")
|
| 55 |
|
| 56 |
|
| 57 |
-
async def destination_recommendation_func(query, top_k=5):
|
| 58 |
routing: RoutingRecommender = routing_recommender_chain.invoke({"query": query})
|
| 59 |
print("label", routing.label)
|
| 60 |
if routing.label == "characteristic":
|
| 61 |
output = await destination_suggestion_controller(query, top_k)
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
characteristic_extract_response: CharacteristicExtractor = (
|
| 64 |
await characteristic_extractor_chain.ainvoke({"query": query})
|
| 65 |
)
|
| 66 |
-
print("characterist", characteristic_extract_response)
|
| 67 |
lat, lon = get_lat_long_location(characteristic_extract_response.main_place)
|
| 68 |
response = get_places(
|
| 69 |
lat,
|
|
@@ -72,7 +79,15 @@ async def destination_recommendation_func(query, top_k=5):
|
|
| 72 |
available_categories.get(characteristic_extract_response.kind, None),
|
| 73 |
top_k,
|
| 74 |
)
|
| 75 |
-
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
return output
|
|
|
|
| 54 |
raise HTTPException(status_code=500, detail=f"Request failed: {str(e)}")
|
| 55 |
|
| 56 |
|
| 57 |
+
async def destination_recommendation_func(query, top_k=5, tool_chat=False):
|
| 58 |
routing: RoutingRecommender = routing_recommender_chain.invoke({"query": query})
|
| 59 |
print("label", routing.label)
|
| 60 |
if routing.label == "characteristic":
|
| 61 |
output = await destination_suggestion_controller(query, top_k)
|
| 62 |
+
if tool_chat:
|
| 63 |
+
return output
|
| 64 |
+
output = [
|
| 65 |
+
{
|
| 66 |
+
"name": i,
|
| 67 |
+
"map_url": "https://www.google.com/maps/search/109.23333,13.76667",
|
| 68 |
+
}
|
| 69 |
+
for i in output
|
| 70 |
+
]
|
| 71 |
characteristic_extract_response: CharacteristicExtractor = (
|
| 72 |
await characteristic_extractor_chain.ainvoke({"query": query})
|
| 73 |
)
|
|
|
|
| 74 |
lat, lon = get_lat_long_location(characteristic_extract_response.main_place)
|
| 75 |
response = get_places(
|
| 76 |
lat,
|
|
|
|
| 79 |
available_categories.get(characteristic_extract_response.kind, None),
|
| 80 |
top_k,
|
| 81 |
)
|
| 82 |
+
output = json.loads(response.body)
|
| 83 |
+
if tool_chat:
|
| 84 |
+
output = [
|
| 85 |
+
{
|
| 86 |
+
"name": i["name"],
|
| 87 |
+
"address": i["address"],
|
| 88 |
+
"distance_km": i["distance_km"],
|
| 89 |
+
}
|
| 90 |
+
for i in output
|
| 91 |
+
]
|
| 92 |
|
| 93 |
return output
|
src/langgraph/tools/__pycache__/destination_tools.cpython-311.pyc
CHANGED
|
Binary files a/src/langgraph/tools/__pycache__/destination_tools.cpython-311.pyc and b/src/langgraph/tools/__pycache__/destination_tools.cpython-311.pyc differ
|
|
|
src/langgraph/tools/destination_tools.py
CHANGED
|
@@ -29,7 +29,6 @@ async def destination_recommendation(query: str, config: RunnableConfig):
|
|
| 29 |
Using Vietnamese language for better results
|
| 30 |
"""
|
| 31 |
logger.info(f"Destination recommendation query: {query}")
|
| 32 |
-
|
| 33 |
-
logger.info(f"Destination recommendation output: {
|
| 34 |
-
return
|
| 35 |
-
|
|
|
|
| 29 |
Using Vietnamese language for better results
|
| 30 |
"""
|
| 31 |
logger.info(f"Destination recommendation query: {query}")
|
| 32 |
+
response = await destination_recommendation_func(query)
|
| 33 |
+
logger.info(f"Destination recommendation output: {response}")
|
| 34 |
+
return response
|
|
|
src/utils/__pycache__/helper.cpython-311.pyc
CHANGED
|
Binary files a/src/utils/__pycache__/helper.cpython-311.pyc and b/src/utils/__pycache__/helper.cpython-311.pyc differ
|
|
|
src/utils/helper.py
CHANGED
|
@@ -104,8 +104,8 @@ def format_geoapify_response(
|
|
| 104 |
if include_latnlong:
|
| 105 |
formatted_item["lat"] = place_lat
|
| 106 |
formatted_item["lon"] = place_lon
|
| 107 |
-
formatted_item["
|
| 108 |
-
formatted_item["
|
| 109 |
formatted_item["distance_km"] = str(round(distance, 2)) + " km"
|
| 110 |
|
| 111 |
if "contact" in feature["properties"]:
|
|
@@ -116,6 +116,7 @@ def format_geoapify_response(
|
|
| 116 |
|
| 117 |
if "accommodation" in feature["properties"]:
|
| 118 |
formatted_item["accommodation"] = feature["properties"]["accommodation"]
|
|
|
|
| 119 |
|
| 120 |
formatted_data.append(formatted_item)
|
| 121 |
|
|
@@ -302,5 +303,6 @@ def serialize_datetime(obj):
|
|
| 302 |
return str(obj)
|
| 303 |
return obj
|
| 304 |
|
| 305 |
-
|
| 306 |
-
|
|
|
|
|
|
| 104 |
if include_latnlong:
|
| 105 |
formatted_item["lat"] = place_lat
|
| 106 |
formatted_item["lon"] = place_lon
|
| 107 |
+
formatted_item["name"] = feature["properties"]["address_line1"]
|
| 108 |
+
formatted_item["address"] = feature["properties"]["formatted"]
|
| 109 |
formatted_item["distance_km"] = str(round(distance, 2)) + " km"
|
| 110 |
|
| 111 |
if "contact" in feature["properties"]:
|
|
|
|
| 116 |
|
| 117 |
if "accommodation" in feature["properties"]:
|
| 118 |
formatted_item["accommodation"] = feature["properties"]["accommodation"]
|
| 119 |
+
formatted_item["map_url"] = get_google_map_url(place_lat, place_lon)
|
| 120 |
|
| 121 |
formatted_data.append(formatted_item)
|
| 122 |
|
|
|
|
| 303 |
return str(obj)
|
| 304 |
return obj
|
| 305 |
|
| 306 |
+
|
| 307 |
+
def get_google_map_url(lat, long):
|
| 308 |
+
return f"https://www.google.com/maps/search/{lat},{long}"
|