Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -53,14 +53,8 @@ def get_nba_matches(target_date: str = None) -> str:
|
|
53 |
}
|
54 |
|
55 |
try:
|
56 |
-
print(f"Fetching NBA matches for {target_date}...") # Debug log
|
57 |
response = requests.get(url, headers=headers, params=params)
|
58 |
-
|
59 |
-
# Print debug information
|
60 |
-
print(f"URL: {response.url}")
|
61 |
-
print(f"Status Code: {response.status_code}")
|
62 |
-
|
63 |
-
response.raise_for_status() # Raise an exception for bad status codes
|
64 |
|
65 |
data = response.json()
|
66 |
if not data.get("events"):
|
@@ -92,7 +86,7 @@ def get_nba_matches(target_date: str = None) -> str:
|
|
92 |
# Extract basic game info
|
93 |
teams = event.get("teams_normalized", [])
|
94 |
if not teams:
|
95 |
-
teams = event.get("teams", [])
|
96 |
|
97 |
if len(teams) < 2:
|
98 |
continue
|
@@ -105,7 +99,7 @@ def get_nba_matches(target_date: str = None) -> str:
|
|
105 |
|
106 |
# Try different bookmakers in order of preference
|
107 |
bookmaker = None
|
108 |
-
for bookmaker_id in ["3", "2", "12", "22", "23"]:
|
109 |
if bookmaker_id in lines:
|
110 |
bookmaker = lines[bookmaker_id]
|
111 |
break
|
@@ -183,9 +177,16 @@ def get_nba_matches(target_date: str = None) -> str:
|
|
183 |
matches.append("\n".join(game_info))
|
184 |
|
185 |
if matches:
|
186 |
-
|
187 |
-
|
188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
else:
|
190 |
return f"No NBA matches found with complete information for {target_date}."
|
191 |
|
@@ -233,12 +234,15 @@ agent = CodeAgent(
|
|
233 |
model=model,
|
234 |
tools=[final_answer, get_current_time_in_timezone, get_nba_matches, predict_nba_match],
|
235 |
max_steps=6,
|
236 |
-
verbosity_level=
|
237 |
grammar=None,
|
238 |
planning_interval=None,
|
239 |
name=None,
|
240 |
description=None,
|
241 |
-
prompt_templates=prompt_templates
|
|
|
242 |
)
|
243 |
|
244 |
-
|
|
|
|
|
|
53 |
}
|
54 |
|
55 |
try:
|
|
|
56 |
response = requests.get(url, headers=headers, params=params)
|
57 |
+
response.raise_for_status()
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
data = response.json()
|
60 |
if not data.get("events"):
|
|
|
86 |
# Extract basic game info
|
87 |
teams = event.get("teams_normalized", [])
|
88 |
if not teams:
|
89 |
+
teams = event.get("teams", [])
|
90 |
|
91 |
if len(teams) < 2:
|
92 |
continue
|
|
|
99 |
|
100 |
# Try different bookmakers in order of preference
|
101 |
bookmaker = None
|
102 |
+
for bookmaker_id in ["3", "2", "12", "22", "23"]:
|
103 |
if bookmaker_id in lines:
|
104 |
bookmaker = lines[bookmaker_id]
|
105 |
break
|
|
|
177 |
matches.append("\n".join(game_info))
|
178 |
|
179 |
if matches:
|
180 |
+
# Create a detailed response with all match information
|
181 |
+
response = [
|
182 |
+
f"\n🏀 NBA Schedule for {target_date} - {event_type} 🏀",
|
183 |
+
"=" * 80,
|
184 |
+
"", # Empty line for better readability
|
185 |
+
"\n\n".join(matches) # All match details
|
186 |
+
]
|
187 |
+
matches_str = "\n".join(response)
|
188 |
+
print(matches_str) # Print for execution logs
|
189 |
+
return matches_str
|
190 |
else:
|
191 |
return f"No NBA matches found with complete information for {target_date}."
|
192 |
|
|
|
234 |
model=model,
|
235 |
tools=[final_answer, get_current_time_in_timezone, get_nba_matches, predict_nba_match],
|
236 |
max_steps=6,
|
237 |
+
verbosity_level=2, # Increased verbosity to show more details
|
238 |
grammar=None,
|
239 |
planning_interval=None,
|
240 |
name=None,
|
241 |
description=None,
|
242 |
+
prompt_templates=prompt_templates,
|
243 |
+
include_execution_details=True
|
244 |
)
|
245 |
|
246 |
+
# Configure Gradio UI to display full match details
|
247 |
+
gradio_ui = GradioUI(agent)
|
248 |
+
gradio_ui.launch()
|