Pash1986 commited on
Commit
8513c8e
·
verified ·
1 Parent(s): 5a46de1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
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("Geo 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,10 +40,11 @@ def get_restaurants(search, location, meters):
40
  "filter": {"searchTrip": newTrip}
41
  }
42
  }
 
 
43
 
44
- restaurant_docs = list(trips_collection.aggregate([vectorQuery, {"$project": {"_id": 0, "embedding": 0}}]))
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."},