Diogogp24 commited on
Commit
9aedbf9
·
verified ·
1 Parent(s): bece47b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -30
app.py CHANGED
@@ -10,30 +10,15 @@ from Gradio_UI import GradioUI
10
  # --- FERRAMENTAS PERSONALIZADAS ---
11
 
12
  @tool
13
- def get_football_team_info(team_name: str, info_type: str) -> str:
14
- """A tool that fetches football team information (results or upcoming matches) from ZeroZero.
 
15
  Args:
16
- team_name: The name of the football team (e.g., 'Benfica', 'Sporting').
17
- info_type: Type of information to fetch: 'resultados' (past matches) or 'proximos' (future matches).
18
  """
19
- try:
20
- search_query = team_name.replace(" ", "+")
21
- base_url = "https://www.zerozero.pt"
22
- search_url = f"{base_url}/search.php?input_search={search_query}"
23
-
24
- headers = {
25
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
26
- }
27
-
28
- response = requests.get(search_url, headers=headers, timeout=10)
29
-
30
- if response.status_code == 200:
31
- return f"Encontrei informações para '{team_name}'. Podes consultar os {info_type} aqui: {response.url}"
32
- else:
33
- return f"O ZeroZero não permitiu o acesso direto (Status: {response.status_code}). Tenta usar a ferramenta de busca geral."
34
-
35
- except Exception as e:
36
- return f"Erro ao procurar a equipa: {str(e)}"
37
 
38
  @tool
39
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -70,16 +55,13 @@ agent = CodeAgent(
70
  model=model,
71
  tools=[
72
  final_answer,
73
- get_football_team_info,
74
- get_current_time_in_timezone,
75
- search_tool, # Agora já está definido!
76
- image_generation_tool
77
  ],
78
- max_steps=6,
79
  verbosity_level=1,
80
- name="FootballTimeAgent",
81
- description="Um agente que sabe horas e resultados de futebol.",
82
- prompt_templates=prompt_templates
83
  )
84
 
85
  if __name__ == "__main__":
 
10
  # --- FERRAMENTAS PERSONALIZADAS ---
11
 
12
  @tool
13
+ @tool
14
+ def get_football_info(query: str) -> str:
15
+ """Pesquisa informações atualizadas sobre futebol (jogos, resultados, classificações).
16
  Args:
17
+ query: O que queres saber (ex: 'próximo jogo benfica', 'resultado sporting ontem').
 
18
  """
19
+ # Esta tool agora serve apenas para dar contexto,
20
+ # o agente usará a search_tool para encontrar os dados reais.
21
+ return f"Vou pesquisar na web por: {query}. Por favor, analisa os resultados dos primeiros sites (Record, A Bola, ZeroZero ou Google)."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  @tool
24
  def get_current_time_in_timezone(timezone: str) -> str:
 
55
  model=model,
56
  tools=[
57
  final_answer,
58
+ search_tool, # A ferramenta MAIS importante aqui
59
+ get_football_info,
60
+ get_current_time_in_timezone
 
61
  ],
62
+ max_steps=10, # Mais fôlego para o agente
63
  verbosity_level=1,
64
+ # prompt_templates=prompt_templates <-- Comenta esta linha para evitar o KeyError
 
 
65
  )
66
 
67
  if __name__ == "__main__":