Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -30,24 +30,25 @@ def scrape_restaurant_info(city, recipe):
|
|
| 30 |
st.title("Pakistani Famous Recipes Finder 🍛")
|
| 31 |
|
| 32 |
# User inputs city
|
| 33 |
-
city = st.text_input("Enter a Pakistani City (e.g., Lahore, Karachi, Islamabad)")
|
| 34 |
|
| 35 |
# Optional: User inputs recipe (not mandatory)
|
| 36 |
-
query = st.text_input("Enter a Recipe Name (Optional)")
|
| 37 |
|
| 38 |
if st.button("Find Recipes & Restaurants"):
|
| 39 |
if city:
|
| 40 |
if query:
|
| 41 |
# Retrieve specific recipe info from vector DB
|
| 42 |
query_embedding = model.encode(query).tolist()
|
| 43 |
-
results = collection.query(query_embedding, n_results=
|
| 44 |
|
| 45 |
-
if results["documents"]:
|
| 46 |
st.subheader(f"Famous {query} in {city}")
|
| 47 |
-
for
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
| 51 |
|
| 52 |
# Fetch restaurant data via scraping
|
| 53 |
restaurants = scrape_restaurant_info(city, query)
|
|
@@ -58,20 +59,21 @@ if st.button("Find Recipes & Restaurants"):
|
|
| 58 |
else:
|
| 59 |
st.write("No restaurant data found.")
|
| 60 |
else:
|
| 61 |
-
st.write("No matching recipes found.")
|
| 62 |
|
| 63 |
else:
|
| 64 |
# Retrieve all famous recipes in the city
|
| 65 |
city_embedding = model.encode(city).tolist()
|
| 66 |
results = collection.query(city_embedding, n_results=5)
|
| 67 |
|
| 68 |
-
if results["documents"]:
|
| 69 |
st.subheader(f"Famous Recipes in {city}")
|
| 70 |
-
for
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
|
|
|
| 74 |
else:
|
| 75 |
-
st.write("No famous recipes found for
|
| 76 |
else:
|
| 77 |
st.warning("Please enter a city name.")
|
|
|
|
| 30 |
st.title("Pakistani Famous Recipes Finder 🍛")
|
| 31 |
|
| 32 |
# User inputs city
|
| 33 |
+
city = st.text_input("Enter a Pakistani City (e.g., Lahore, Karachi, Islamabad)").strip()
|
| 34 |
|
| 35 |
# Optional: User inputs recipe (not mandatory)
|
| 36 |
+
query = st.text_input("Enter a Recipe Name (Optional)").strip()
|
| 37 |
|
| 38 |
if st.button("Find Recipes & Restaurants"):
|
| 39 |
if city:
|
| 40 |
if query:
|
| 41 |
# Retrieve specific recipe info from vector DB
|
| 42 |
query_embedding = model.encode(query).tolist()
|
| 43 |
+
results = collection.query(query_embedding, n_results=5)
|
| 44 |
|
| 45 |
+
if results and "documents" in results and results["documents"]:
|
| 46 |
st.subheader(f"Famous {query} in {city}")
|
| 47 |
+
for doc in results["documents"]:
|
| 48 |
+
for recipe in doc:
|
| 49 |
+
st.write(f"**Recipe:** {recipe['name']}")
|
| 50 |
+
st.image(recipe["image"], caption=recipe["name"], use_column_width=True)
|
| 51 |
+
st.write(f"Price: {recipe['price']} PKR")
|
| 52 |
|
| 53 |
# Fetch restaurant data via scraping
|
| 54 |
restaurants = scrape_restaurant_info(city, query)
|
|
|
|
| 59 |
else:
|
| 60 |
st.write("No restaurant data found.")
|
| 61 |
else:
|
| 62 |
+
st.write(f"No matching recipes found for '{query}' in {city}.")
|
| 63 |
|
| 64 |
else:
|
| 65 |
# Retrieve all famous recipes in the city
|
| 66 |
city_embedding = model.encode(city).tolist()
|
| 67 |
results = collection.query(city_embedding, n_results=5)
|
| 68 |
|
| 69 |
+
if results and "documents" in results and results["documents"]:
|
| 70 |
st.subheader(f"Famous Recipes in {city}")
|
| 71 |
+
for doc in results["documents"]:
|
| 72 |
+
for recipe in doc:
|
| 73 |
+
st.write(f"**Recipe:** {recipe['name']}")
|
| 74 |
+
st.image(recipe["image"], caption=recipe["name"], use_column_width=True)
|
| 75 |
+
st.write(f"Price: {recipe['price']} PKR")
|
| 76 |
else:
|
| 77 |
+
st.write(f"No famous recipes found for {city}.")
|
| 78 |
else:
|
| 79 |
st.warning("Please enter a city name.")
|