Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,6 +9,16 @@ import gradio as gr
|
|
| 9 |
|
| 10 |
@tool
|
| 11 |
def scrape_phones(budget: str, use_case: str) -> str:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
query = f"best phones under {budget} for {use_case} site:smartprix.com"
|
| 13 |
url = f"https://www.google.com/search?q={query}"
|
| 14 |
headers = {"User-Agent": "Mozilla/5.0"}
|
|
@@ -20,8 +30,18 @@ def scrape_phones(budget: str, use_case: str) -> str:
|
|
| 20 |
except Exception as e:
|
| 21 |
return f"Error occurred: {e}"
|
| 22 |
|
|
|
|
| 23 |
@tool
|
| 24 |
def compare_phones(phone_names: list[str]) -> str:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
dummy_db = {
|
| 26 |
"Redmi Note 13 Pro": "Good display, solid battery, mid gaming",
|
| 27 |
"iQOO Z9": "Fast processor, great gaming, average camera",
|
|
@@ -30,6 +50,7 @@ def compare_phones(phone_names: list[str]) -> str:
|
|
| 30 |
return "\n".join(f"{p}: {dummy_db.get(p, 'Specs not available')}" for p in phone_names)
|
| 31 |
|
| 32 |
|
|
|
|
| 33 |
# 🤖 MODEL + AGENT SETUP
|
| 34 |
|
| 35 |
class MobileAdvisorAgent:
|
|
|
|
| 9 |
|
| 10 |
@tool
|
| 11 |
def scrape_phones(budget: str, use_case: str) -> str:
|
| 12 |
+
"""
|
| 13 |
+
Search for smartphones under a given budget and use-case.
|
| 14 |
+
|
| 15 |
+
Args:
|
| 16 |
+
budget (str): The maximum budget in INR. Example: "15000"
|
| 17 |
+
use_case (str): The intended usage like "gaming", "camera", "battery", etc.
|
| 18 |
+
|
| 19 |
+
Returns:
|
| 20 |
+
str: A list of recommended phone names as a newline-separated string.
|
| 21 |
+
"""
|
| 22 |
query = f"best phones under {budget} for {use_case} site:smartprix.com"
|
| 23 |
url = f"https://www.google.com/search?q={query}"
|
| 24 |
headers = {"User-Agent": "Mozilla/5.0"}
|
|
|
|
| 30 |
except Exception as e:
|
| 31 |
return f"Error occurred: {e}"
|
| 32 |
|
| 33 |
+
|
| 34 |
@tool
|
| 35 |
def compare_phones(phone_names: list[str]) -> str:
|
| 36 |
+
"""
|
| 37 |
+
Compare given phone models using a dummy spec database.
|
| 38 |
+
|
| 39 |
+
Args:
|
| 40 |
+
phone_names (list[str]): A list of phone model names to compare.
|
| 41 |
+
|
| 42 |
+
Returns:
|
| 43 |
+
str: A comparison string showing specs or stating if not available.
|
| 44 |
+
"""
|
| 45 |
dummy_db = {
|
| 46 |
"Redmi Note 13 Pro": "Good display, solid battery, mid gaming",
|
| 47 |
"iQOO Z9": "Fast processor, great gaming, average camera",
|
|
|
|
| 50 |
return "\n".join(f"{p}: {dummy_db.get(p, 'Specs not available')}" for p in phone_names)
|
| 51 |
|
| 52 |
|
| 53 |
+
|
| 54 |
# 🤖 MODEL + AGENT SETUP
|
| 55 |
|
| 56 |
class MobileAdvisorAgent:
|