droid22 commited on
Commit
71b6a8b
·
verified ·
1 Parent(s): 05da41f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py CHANGED
@@ -10,6 +10,45 @@ from Gradio_UI import GradioUI
10
 
11
  base_search_tool = DuckDuckGoSearchTool()
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  @tool
14
  def custom_duckduckgo_search(query: str) -> str:
15
  """A tool that performs a web search using DuckDuckGo to find current information.
 
10
 
11
  base_search_tool = DuckDuckGoSearchTool()
12
 
13
+ @tool
14
+ def search_soccer_news(query: str) -> str:
15
+ """A tool that searches the web for the latest soccer news, live scores, and transfer rumors.
16
+ Args:
17
+ query: The soccer-related search query (e.g., 'Chelsea FC latest result', 'Premier League table').
18
+ """
19
+ try:
20
+ # We append keywords to ensure the search engine knows we want sports data
21
+ enhanced_query = f"{query} soccer football news live"
22
+ return str(base_search_tool(enhanced_query))
23
+ except Exception as e:
24
+ return f"Error performing search: {str(e)}"
25
+
26
+ @tool
27
+ def get_team_info(team_name: str) -> str:
28
+ """Fetches general information, stadium details, and history for a specific soccer team.
29
+ Args:
30
+ team_name: The name of the soccer team (e.g., 'Chelsea', 'Arsenal', 'Real Madrid').
31
+ """
32
+ try:
33
+ # Using the free tier of TheSportsDB API
34
+ url = f"https://www.thesportsdb.com/api/v1/json/3/searchteams.php?t={team_name}"
35
+ response = requests.get(url).json()
36
+
37
+ if response.get("teams"):
38
+ team = response["teams"][0]
39
+ name = team.get("strTeam")
40
+ stadium = team.get("strStadium")
41
+ capacity = team.get("intStadiumCapacity")
42
+ league = team.get("strLeague")
43
+ # Truncate the description so we don't overwhelm the LLM's context window
44
+ description = team.get("strDescriptionEN", "No description available.")[:600] + "..."
45
+
46
+ return f"Team: {name}\nLeague: {league}\nStadium: {stadium} (Capacity: {capacity})\nBackground: {description}"
47
+ else:
48
+ return f"Could not find information for team: {team_name}. Try being more specific."
49
+ except Exception as e:
50
+ return f"Error fetching team info: {str(e)}"
51
+
52
  @tool
53
  def custom_duckduckgo_search(query: str) -> str:
54
  """A tool that performs a web search using DuckDuckGo to find current information.