Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,16 +21,16 @@ def get_restaurants(search, location, meters):
|
|
| 21 |
return None, None, None, None
|
| 22 |
|
| 23 |
try:
|
| 24 |
-
with st.status("
|
| 25 |
newTrip, pre_agg = pre_aggregate_meters(restaurants_collection, location, meters)
|
| 26 |
|
| 27 |
-
|
| 28 |
input=search,
|
| 29 |
model="text-embedding-3-small",
|
| 30 |
dimensions=256
|
| 31 |
-
|
| 32 |
|
| 33 |
-
|
| 34 |
"$vectorSearch": {
|
| 35 |
"index": "vector_index",
|
| 36 |
"queryVector": response.data[0].embedding,
|
|
@@ -40,10 +40,11 @@ def get_restaurants(search, location, meters):
|
|
| 40 |
"filter": {"searchTrip": newTrip}
|
| 41 |
}
|
| 42 |
}
|
|
|
|
|
|
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
stream_response = openai_client.chat.completions.create(
|
| 47 |
model="gpt-4o",
|
| 48 |
messages=[
|
| 49 |
{"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."},
|
|
|
|
| 21 |
return None, None, None, None
|
| 22 |
|
| 23 |
try:
|
| 24 |
+
with st.status("Search data..."):
|
| 25 |
newTrip, pre_agg = pre_aggregate_meters(restaurants_collection, location, meters)
|
| 26 |
|
| 27 |
+
response = openai_client.embeddings.create(
|
| 28 |
input=search,
|
| 29 |
model="text-embedding-3-small",
|
| 30 |
dimensions=256
|
| 31 |
+
)
|
| 32 |
|
| 33 |
+
vectorQuery = {
|
| 34 |
"$vectorSearch": {
|
| 35 |
"index": "vector_index",
|
| 36 |
"queryVector": response.data[0].embedding,
|
|
|
|
| 40 |
"filter": {"searchTrip": newTrip}
|
| 41 |
}
|
| 42 |
}
|
| 43 |
+
st.write("Vector query")
|
| 44 |
+
restaurant_docs = list(trips_collection.aggregate([vectorQuery, {"$project": {"_id": 0, "embedding": 0}}]))
|
| 45 |
|
| 46 |
+
st.write("RAG...")
|
| 47 |
+
stream_response = openai_client.chat.completions.create(
|
|
|
|
| 48 |
model="gpt-4o",
|
| 49 |
messages=[
|
| 50 |
{"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."},
|