Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -37,50 +37,51 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
37 |
@tool
|
38 |
def get_nba_matches() -> str:
|
39 |
"""
|
40 |
-
|
|
|
41 |
Returns:
|
42 |
-
|
43 |
"""
|
44 |
-
url = "https://api.apilayer.com/therundown/affiliates" #
|
45 |
headers = {
|
46 |
-
|
47 |
}
|
48 |
response = requests.get(url, headers=headers)
|
49 |
if response.status_code == 200:
|
50 |
events = response.json()
|
51 |
-
#
|
52 |
-
|
53 |
for event in events.get("events", []):
|
54 |
-
#
|
55 |
-
date = event.get("start_time", "
|
56 |
-
teams = event.get("teams", "
|
57 |
-
|
58 |
-
if
|
59 |
-
return "\n".join(
|
60 |
else:
|
61 |
-
return "
|
62 |
else:
|
63 |
-
return f"
|
64 |
|
65 |
@tool
|
66 |
def predict_nba_match(match_info: str) -> str:
|
67 |
"""
|
68 |
-
|
69 |
|
70 |
Args:
|
71 |
-
match_info:
|
72 |
|
73 |
Returns:
|
74 |
-
|
75 |
"""
|
76 |
import random
|
77 |
-
#
|
78 |
teams = match_info.split(" vs ")
|
79 |
if len(teams) == 2:
|
80 |
prediction = random.choice(teams)
|
81 |
-
return f"
|
82 |
else:
|
83 |
-
return "
|
84 |
|
85 |
|
86 |
final_answer = FinalAnswerTool()
|
|
|
37 |
@tool
|
38 |
def get_nba_matches() -> str:
|
39 |
"""
|
40 |
+
A tool that retrieves upcoming NBA games via TheRundown API.
|
41 |
+
|
42 |
Returns:
|
43 |
+
A string containing a human-readable list of upcoming games.
|
44 |
"""
|
45 |
+
url = "https://api.apilayer.com/therundown/affiliates" # Replace with the NBA-specific endpoint if available.
|
46 |
headers = {
|
47 |
+
"apikey": "7k4hKSUeWkbigKxZiNV5CQ8RSlEd72Cj"
|
48 |
}
|
49 |
response = requests.get(url, headers=headers)
|
50 |
if response.status_code == 200:
|
51 |
events = response.json()
|
52 |
+
# Suppose 'events' is a dictionary containing a list of games under the key "events"
|
53 |
+
games = []
|
54 |
for event in events.get("events", []):
|
55 |
+
# Extract relevant information: date, teams, etc.
|
56 |
+
date = event.get("start_time", "Unknown date")
|
57 |
+
teams = event.get("teams", "Game info not defined")
|
58 |
+
games.append(f"{date} : {teams}")
|
59 |
+
if games:
|
60 |
+
return "\n".join(games)
|
61 |
else:
|
62 |
+
return "No NBA games found in the response."
|
63 |
else:
|
64 |
+
return f"Error retrieving NBA games: {response.status_code}"
|
65 |
|
66 |
@tool
|
67 |
def predict_nba_match(match_info: str) -> str:
|
68 |
"""
|
69 |
+
A tool that generates a prediction for an NBA match.
|
70 |
|
71 |
Args:
|
72 |
+
match_info: A string containing the match details in the format "TeamA vs TeamB".
|
73 |
|
74 |
Returns:
|
75 |
+
A string with the prediction (e.g., "The prediction is that TeamA will win.").
|
76 |
"""
|
77 |
import random
|
78 |
+
# Assume match_info is in the format "TeamA vs TeamB"
|
79 |
teams = match_info.split(" vs ")
|
80 |
if len(teams) == 2:
|
81 |
prediction = random.choice(teams)
|
82 |
+
return f"The prediction is that {prediction} will win."
|
83 |
else:
|
84 |
+
return "Incorrect match_info format. Please provide teams in the format 'TeamA vs TeamB'."
|
85 |
|
86 |
|
87 |
final_answer = FinalAnswerTool()
|