Spaces:
Runtime error
Runtime error
Pavel Duchovny
commited on
Commit
·
199e228
1
Parent(s):
c63f1bb
init
Browse files
app.py
CHANGED
@@ -40,23 +40,23 @@ def get_restaurants(search, location, meters):
|
|
40 |
|
41 |
|
42 |
chat_response = openai_client.chat.completions.create(
|
43 |
-
model="gpt-3.5-turbo",
|
44 |
messages=[
|
45 |
-
{"role": "system", "content": "You are a helpful restaurant assistant."},
|
46 |
{ "role": "user", "content": f"Find me the 2 best restaurant and why based on {search} and {restaurant_docs}. explain trades offs and why I should go to each one. You can mention the third option as a possible alternative."}
|
47 |
]
|
48 |
)
|
49 |
|
50 |
trips_collection.delete_many({"searchTrip": newTrip})
|
|
|
|
|
51 |
|
52 |
first_restaurant = restaurant_docs[0]['restaurant_id']
|
53 |
second_restaurant = restaurant_docs[1]['restaurant_id']
|
54 |
third_restaurant = restaurant_docs[2]['restaurant_id']
|
|
|
55 |
|
56 |
-
|
57 |
-
return "No restaurants found", '<iframe style="background: #FFFFFF;border: none;border-radius: 2px;box-shadow: 0 2px 10px 0 rgba(70, 76, 79, .2);" width="640" height="480" src="https://charts.mongodb.com/charts-paveldev-wiumf/embed/charts?id=65c24b0c-2215-4e6f-829c-f484dfd8a90c&filter={\'restaurant_id\':\'\'}&maxDataAge=3600&theme=light&autoRefresh=true"></iframe>'
|
58 |
-
else:
|
59 |
-
restaurant_string = f"\'{first_restaurant}\', \'{second_restaurant}\', \'{third_restaurant}\'"
|
60 |
iframe = '<iframe style="background: #FFFFFF;border: none;border-radius: 2px;box-shadow: 0 2px 10px 0 rgba(70, 76, 79, .2);" width="640" height="480" src="https://charts.mongodb.com/charts-paveldev-wiumf/embed/charts?id=65c24b0c-2215-4e6f-829c-f484dfd8a90c&filter={\'restaurant_id\':{$in:[' + restaurant_string + ']}}&maxDataAge=3600&theme=light&autoRefresh=true"></iframe>'
|
61 |
|
62 |
return chat_response.choices[0].message.content, iframe,str(pre_agg), str(vectorQuery)
|
@@ -88,7 +88,7 @@ def pre_aggregate_meters(location, meters):
|
|
88 |
result = restaurants_collection.aggregate(pre_aggregate_pipeline);
|
89 |
|
90 |
print(trips_collection.count_documents({"searchTrip": tripId}));
|
91 |
-
sleep(
|
92 |
|
93 |
return tripId, pre_aggregate_pipeline
|
94 |
|
@@ -106,18 +106,18 @@ with gr.Blocks() as demo:
|
|
106 |
[
|
107 |
|
108 |
gr.Textbox(placeholder="What type of dinner are you looking for?"),
|
109 |
-
gr.Radio([("
|
110 |
"type": "Point",
|
111 |
"coordinates": [
|
112 |
-73.98527039999999,
|
113 |
40.7589099
|
114 |
]
|
115 |
-
}), ("
|
116 |
"type": "Point",
|
117 |
"coordinates": [
|
118 |
-74.013686, 40.701975
|
119 |
]
|
120 |
-
}), ("
|
121 |
"type": "Point",
|
122 |
"coordinates": [ -74.000468,40.720777
|
123 |
]
|
|
|
40 |
|
41 |
|
42 |
chat_response = openai_client.chat.completions.create(
|
43 |
+
model="gpt-3.5-turbo-0125",
|
44 |
messages=[
|
45 |
+
{"role": "system", "content": "You are a helpful restaurant assistant. You will get a context if the context is not relevat to the user query please address that and not provide by default the restaurants as is."},
|
46 |
{ "role": "user", "content": f"Find me the 2 best restaurant and why based on {search} and {restaurant_docs}. explain trades offs and why I should go to each one. You can mention the third option as a possible alternative."}
|
47 |
]
|
48 |
)
|
49 |
|
50 |
trips_collection.delete_many({"searchTrip": newTrip})
|
51 |
+
if len(restaurant_docs) == 0:
|
52 |
+
return "No restaurants found", '<iframe style="background: #FFFFFF;border: none;border-radius: 2px;box-shadow: 0 2px 10px 0 rgba(70, 76, 79, .2);" width="640" height="480" src="https://charts.mongodb.com/charts-paveldev-wiumf/embed/charts?id=65c24b0c-2215-4e6f-829c-f484dfd8a90c&filter={\'restaurant_id\':\'\'}&maxDataAge=3600&theme=light&autoRefresh=true"></iframe>', str(pre_agg), str(vectorQuery)
|
53 |
|
54 |
first_restaurant = restaurant_docs[0]['restaurant_id']
|
55 |
second_restaurant = restaurant_docs[1]['restaurant_id']
|
56 |
third_restaurant = restaurant_docs[2]['restaurant_id']
|
57 |
+
restaurant_string = f"'{first_restaurant}', '{second_restaurant}', '{third_restaurant}'"
|
58 |
|
59 |
+
|
|
|
|
|
|
|
60 |
iframe = '<iframe style="background: #FFFFFF;border: none;border-radius: 2px;box-shadow: 0 2px 10px 0 rgba(70, 76, 79, .2);" width="640" height="480" src="https://charts.mongodb.com/charts-paveldev-wiumf/embed/charts?id=65c24b0c-2215-4e6f-829c-f484dfd8a90c&filter={\'restaurant_id\':{$in:[' + restaurant_string + ']}}&maxDataAge=3600&theme=light&autoRefresh=true"></iframe>'
|
61 |
|
62 |
return chat_response.choices[0].message.content, iframe,str(pre_agg), str(vectorQuery)
|
|
|
88 |
result = restaurants_collection.aggregate(pre_aggregate_pipeline);
|
89 |
|
90 |
print(trips_collection.count_documents({"searchTrip": tripId}));
|
91 |
+
sleep(5)
|
92 |
|
93 |
return tripId, pre_aggregate_pipeline
|
94 |
|
|
|
106 |
[
|
107 |
|
108 |
gr.Textbox(placeholder="What type of dinner are you looking for?"),
|
109 |
+
gr.Radio([("Timesquare Manhattan",{
|
110 |
"type": "Point",
|
111 |
"coordinates": [
|
112 |
-73.98527039999999,
|
113 |
40.7589099
|
114 |
]
|
115 |
+
}), ("Westside Manhattan",{
|
116 |
"type": "Point",
|
117 |
"coordinates": [
|
118 |
-74.013686, 40.701975
|
119 |
]
|
120 |
+
}), ("Downtown Manhattan", {
|
121 |
"type": "Point",
|
122 |
"coordinates": [ -74.000468,40.720777
|
123 |
]
|