Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -42,14 +42,17 @@ def get_restaurants(search, location, meters):
|
|
| 42 |
|
| 43 |
restaurant_docs = list(trips_collection.aggregate([vectorQuery, {"$project": {"_id": 0, "embedding": 0}}]))
|
| 44 |
|
| 45 |
-
|
| 46 |
model="gpt-4o",
|
| 47 |
messages=[
|
| 48 |
{"role": "system", "content": "You are a helpful restaurant assistant. Answer shortly and quickly. You will get a context if the context is not relevant to the user query please address that and not provide by default the restaurants as is."},
|
| 49 |
{"role": "user", "content": f"Find me the 2 best restaurant and why based on {search} and {restaurant_docs}. Shortly explain trades offs and why I should go to each one. You can mention the third option as a possible alternative in one sentence."}
|
| 50 |
-
]
|
|
|
|
| 51 |
)
|
| 52 |
|
|
|
|
|
|
|
| 53 |
trips_collection.delete_many({"searchTrip": newTrip})
|
| 54 |
|
| 55 |
if len(restaurant_docs) == 0:
|
|
@@ -112,7 +115,7 @@ if st.button("Get Restaurants"):
|
|
| 112 |
location_value = location['value']
|
| 113 |
result, iframe, pre_agg, vectorQuery = get_restaurants(search, location_value, meters)
|
| 114 |
if result:
|
| 115 |
-
|
| 116 |
st.markdown(iframe, unsafe_allow_html=True)
|
| 117 |
st.json(pre_agg)
|
| 118 |
st.json(vectorQuery)
|
|
|
|
| 42 |
|
| 43 |
restaurant_docs = list(trips_collection.aggregate([vectorQuery, {"$project": {"_id": 0, "embedding": 0}}]))
|
| 44 |
|
| 45 |
+
stream_response = openai_client.chat.completions.create(
|
| 46 |
model="gpt-4o",
|
| 47 |
messages=[
|
| 48 |
{"role": "system", "content": "You are a helpful restaurant assistant. Answer shortly and quickly. You will get a context if the context is not relevant to the user query please address that and not provide by default the restaurants as is."},
|
| 49 |
{"role": "user", "content": f"Find me the 2 best restaurant and why based on {search} and {restaurant_docs}. Shortly explain trades offs and why I should go to each one. You can mention the third option as a possible alternative in one sentence."}
|
| 50 |
+
],
|
| 51 |
+
stream=True
|
| 52 |
)
|
| 53 |
|
| 54 |
+
chat_response = st.write_stream(stream_response)
|
| 55 |
+
|
| 56 |
trips_collection.delete_many({"searchTrip": newTrip})
|
| 57 |
|
| 58 |
if len(restaurant_docs) == 0:
|
|
|
|
| 115 |
location_value = location['value']
|
| 116 |
result, iframe, pre_agg, vectorQuery = get_restaurants(search, location_value, meters)
|
| 117 |
if result:
|
| 118 |
+
|
| 119 |
st.markdown(iframe, unsafe_allow_html=True)
|
| 120 |
st.json(pre_agg)
|
| 121 |
st.json(vectorQuery)
|