jseb4s commited on
Commit
d56e9c7
·
verified ·
1 Parent(s): ae7a494

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -8
app.py CHANGED
@@ -7,16 +7,44 @@ from tools.final_answer import FinalAnswerTool
7
 
8
  from Gradio_UI import GradioUI
9
 
10
- # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
- def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
- #Keep this format for the description / args / args description but feel free to modify the tool
14
- """A tool that does nothing yet
15
  Args:
16
- arg1: the first argument
17
- arg2: the second argument
18
  """
19
- return "What magic will you build ?"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -55,7 +83,7 @@ with open("prompts.yaml", 'r') as stream:
55
 
56
  agent = CodeAgent(
57
  model=model,
58
- tools=[final_answer], ## add your tools here (don't remove final answer)
59
  max_steps=6,
60
  verbosity_level=1,
61
  grammar=None,
 
7
 
8
  from Gradio_UI import GradioUI
9
 
10
+ ##############
11
  @tool
12
+ def compare_tennis_players(player1_name: str, player2_name: str) -> str:
13
+ """A tool that compares statistics between two tennis players.
 
14
  Args:
15
+ player1_name: The name of the first tennis player.
16
+ player2_name: The name of the second tennis player.
17
  """
18
+ base_url = "https://api.openligadb.de" # API gratuita para datos de deportes
19
+
20
+ try:
21
+ # Obtener datos de partidos (esto es un ejemplo, ajusta según la API)
22
+ matches_response = requests.get(f"{base_url}/getmatchdata/tennis")
23
+ matches_data = matches_response.json()
24
+
25
+ # Filtrar partidos de los jugadores
26
+ player1_matches = [match for match in matches_data if player1_name in match["team1"]["teamName"] or player1_name in match["team2"]["teamName"]]
27
+ player2_matches = [match for match in matches_data if player2_name in match["team1"]["teamName"] or player2_name in match["team2"]["teamName"]]
28
+
29
+ # Calcular estadísticas básicas (victorias, derrotas, etc.)
30
+ player1_wins = sum(1 for match in player1_matches if player1_name in match["winner"]["teamName"])
31
+ player1_losses = len(player1_matches) - player1_wins
32
+
33
+ player2_wins = sum(1 for match in player2_matches if player2_name in match["winner"]["teamName"])
34
+ player2_losses = len(player2_matches) - player2_wins
35
+
36
+ # Formatear la respuesta
37
+ result = f"Comparación entre {player1_name} y {player2_name}:\n"
38
+ result += f"{player1_name} - Victorias: {player1_wins}, Derrotas: {player1_losses}\n"
39
+ result += f"{player2_name} - Victorias: {player2_wins}, Derrotas: {player2_losses}\n"
40
+
41
+ return result
42
+
43
+ except Exception as e:
44
+ return f"Error al comparar jugadores: {str(e)}"
45
+
46
+
47
+ ###############
48
 
49
  @tool
50
  def get_current_time_in_timezone(timezone: str) -> str:
 
83
 
84
  agent = CodeAgent(
85
  model=model,
86
+ tools=[final_answer, compare_tennis_players], ## add your tools here (don't remove final answer)
87
  max_steps=6,
88
  verbosity_level=1,
89
  grammar=None,