Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,6 @@ import requests
|
|
3 |
import chromadb
|
4 |
from sentence_transformers import SentenceTransformer
|
5 |
import json
|
6 |
-
import googlemaps
|
7 |
|
8 |
# Initialize embedding model
|
9 |
model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")
|
@@ -13,10 +12,6 @@ DB_PATH = "./recipe_db"
|
|
13 |
client = chromadb.PersistentClient(path=DB_PATH)
|
14 |
collection = client.get_or_create_collection("recipes")
|
15 |
|
16 |
-
# Google Places API Key (Replace with your key)
|
17 |
-
GOOGLE_API_KEY = "YOUR_GOOGLE_PLACES_API_KEY"
|
18 |
-
gmaps = googlemaps.Client(key=GOOGLE_API_KEY)
|
19 |
-
|
20 |
# Predefined Recipe Categories
|
21 |
recipe_categories = {
|
22 |
"Desi": ["Nihari", "Karahi", "Biryani", "Haleem", "Saag"],
|
@@ -44,18 +39,28 @@ if not collection.count():
|
|
44 |
)
|
45 |
print("Sample data added to ChromaDB")
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
59 |
|
60 |
# Streamlit UI
|
61 |
st.title("Pakistani Famous Recipes Finder 🍛")
|
@@ -86,7 +91,7 @@ if st.button("Find Recipes & Restaurants"):
|
|
86 |
st.write(f"Price: {recipe['price']} PKR")
|
87 |
|
88 |
# Fetch restaurant data
|
89 |
-
restaurants = get_restaurants(city
|
90 |
if restaurants:
|
91 |
st.subheader("Available at These Restaurants:")
|
92 |
for r in restaurants:
|
@@ -111,11 +116,10 @@ if st.button("Find Recipes & Restaurants"):
|
|
111 |
st.write(f"Price: {recipe['price']} PKR")
|
112 |
|
113 |
# Fetch restaurant data for multiple recipes
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
st.write(f"- {r}")
|
120 |
else:
|
121 |
st.warning("Please enter a city name.")
|
|
|
3 |
import chromadb
|
4 |
from sentence_transformers import SentenceTransformer
|
5 |
import json
|
|
|
6 |
|
7 |
# Initialize embedding model
|
8 |
model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")
|
|
|
12 |
client = chromadb.PersistentClient(path=DB_PATH)
|
13 |
collection = client.get_or_create_collection("recipes")
|
14 |
|
|
|
|
|
|
|
|
|
15 |
# Predefined Recipe Categories
|
16 |
recipe_categories = {
|
17 |
"Desi": ["Nihari", "Karahi", "Biryani", "Haleem", "Saag"],
|
|
|
39 |
)
|
40 |
print("Sample data added to ChromaDB")
|
41 |
|
42 |
+
|
43 |
+
# Function to fetch restaurant data using Overpass API
|
44 |
+
def get_restaurants(city):
|
45 |
+
overpass_url = "http://overpass-api.de/api/interpreter"
|
46 |
+
query = f"""
|
47 |
+
[out:json];
|
48 |
+
area[name="{city}"]->.searchArea;
|
49 |
+
node["amenity"="restaurant"](area.searchArea);
|
50 |
+
out;
|
51 |
+
"""
|
52 |
+
response = requests.get(overpass_url, params={'data': query})
|
53 |
|
54 |
+
if response.status_code == 200:
|
55 |
+
data = response.json()
|
56 |
+
restaurants = []
|
57 |
+
for element in data.get("elements", []):
|
58 |
+
name = element.get("tags", {}).get("name", "Unknown Restaurant")
|
59 |
+
restaurants.append(name)
|
60 |
+
return restaurants[:5] # Return top 5 results
|
61 |
+
else:
|
62 |
+
return ["No restaurant data found."]
|
63 |
+
|
64 |
|
65 |
# Streamlit UI
|
66 |
st.title("Pakistani Famous Recipes Finder 🍛")
|
|
|
91 |
st.write(f"Price: {recipe['price']} PKR")
|
92 |
|
93 |
# Fetch restaurant data
|
94 |
+
restaurants = get_restaurants(city)
|
95 |
if restaurants:
|
96 |
st.subheader("Available at These Restaurants:")
|
97 |
for r in restaurants:
|
|
|
116 |
st.write(f"Price: {recipe['price']} PKR")
|
117 |
|
118 |
# Fetch restaurant data for multiple recipes
|
119 |
+
restaurants = get_restaurants(city)
|
120 |
+
if restaurants:
|
121 |
+
st.subheader("Popular Restaurants in This City:")
|
122 |
+
for r in restaurants:
|
123 |
+
st.write(f"- {r}")
|
|
|
124 |
else:
|
125 |
st.warning("Please enter a city name.")
|