File size: 2,752 Bytes
8fe4c3d
 
 
807c861
c35c227
8fe4c3d
c35c227
8fe4c3d
 
39d7666
 
 
8fe4c3d
 
c35c227
24e52c2
 
 
 
 
 
 
 
 
807c861
24e52c2
 
 
 
 
 
 
 
 
 
c35c227
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8fe4c3d
 
c35c227
50671e9
e160cf6
50671e9
c35c227
50671e9
c35c227
 
 
 
 
 
 
 
 
8fe4c3d
c35c227
 
 
 
 
 
 
 
 
 
8fe4c3d
50671e9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import streamlit as st
import requests
import chromadb
import json
from sentence_transformers import SentenceTransformer

# Load Embedding Model
model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")

# Connect to ChromaDB (Persistent)
DB_PATH = "./recipe_db"
client = chromadb.PersistentClient(path=DB_PATH)
collection = client.get_or_create_collection("recipes")

# Function to Fetch Restaurant Data Using OpenStreetMap (Overpass API)
def get_restaurants(city):
    overpass_url = "http://overpass-api.de/api/interpreter"
    query = f"""
    [out:json];
    area[name="{city}"]->.searchArea;
    node["amenity"="restaurant"](area.searchArea);
    out;
    """
    response = requests.get(overpass_url, params={'data': query})
    
    if response.status_code == 200:
        data = response.json()
        restaurants = []
        for element in data.get("elements", []):
            name = element.get("tags", {}).get("name", "Unknown Restaurant")
            restaurants.append(name)
        return restaurants[:5]  # Return top 5 results
    else:
        return ["No restaurant data found."]

# Sample Food Dishes (You can expand this dataset)
food_data = {
    "Lahore": [
        {"name": "Nihari", "price": "800 PKR"},
        {"name": "Karahi", "price": "1200 PKR"},
        {"name": "Haleem", "price": "600 PKR"}
    ],
    "Karachi": [
        {"name": "Biryani", "price": "500 PKR"},
        {"name": "Haleem", "price": "700 PKR"},
        {"name": "Kebab Roll", "price": "300 PKR"}
    ],
    "Peshawar": [
        {"name": "Chapli Kebab", "price": "400 PKR"},
        {"name": "Dumpukht", "price": "1500 PKR"}
    ],
    "Multan": [
        {"name": "Sohan Halwa", "price": "1000 PKR"},
        {"name": "Saag", "price": "600 PKR"}
    ]
}

# Streamlit UI
st.title("Famous Pakistani Food Finder 🍛")

city = st.text_input("Enter a Pakistani City (e.g., Lahore, Karachi, Islamabad)").strip()

if st.button("Find Food & Restaurants"):
    if city:
        st.subheader(f"Famous Foods in {city}")

        # Retrieve food data for the city
        dishes = food_data.get(city, [])
        if dishes:
            for dish in dishes:
                st.write(f"**Dish:** {dish['name']}")
                st.write(f"**Price:** {dish['price']}")
                st.markdown("---")
        else:
            st.write("No data available for this city. Please add more dishes!")

        # Retrieve restaurant data
        st.subheader(f"Popular Restaurants in {city}")
        restaurants = get_restaurants(city)
        if restaurants:
            for r in restaurants:
                st.write(f"- {r}")
        else:
            st.write("No restaurant data found.")
    else:
        st.warning("Please enter a city name.")