Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,34 +36,45 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
-
@tool
|
| 40 |
-
def
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
snippet = result.get('snippet', '').lower()
|
| 54 |
-
# Check if snippet contains match-related keywords
|
| 55 |
-
if ' vs ' in snippet or 'match' in snippet or 'result' in snippet:
|
| 56 |
-
# Split snippet into lines to parse each match
|
| 57 |
-
lines = result['snippet'].split('\n')
|
| 58 |
-
for line in lines:
|
| 59 |
-
# Look for lines indicating a match (e.g., containing 'vs' or dates)
|
| 60 |
-
if ' vs ' in line or (' vs. ' in line) or (' - ' in line and ('win' in line or 'draw' in line or 'loss' in line)):
|
| 61 |
-
match_info = line.strip()
|
| 62 |
-
matches.append(match_info)
|
| 63 |
-
if len(matches) >= 5:
|
| 64 |
-
break
|
| 65 |
-
if len(matches) >= 5:
|
| 66 |
-
break
|
| 67 |
|
| 68 |
if not matches:
|
| 69 |
return f"No recent matches found for the team."
|
|
@@ -99,7 +110,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 99 |
|
| 100 |
agent = CodeAgent(
|
| 101 |
model=model,
|
| 102 |
-
tools=[final_answer]
|
| 103 |
max_steps=6,
|
| 104 |
verbosity_level=1,
|
| 105 |
grammar=None,
|
|
|
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
+
# @tool
|
| 40 |
+
# def get_last_5_results(club_url):
|
| 41 |
+
# headers = {
|
| 42 |
+
# 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
|
| 43 |
+
# }
|
| 44 |
+
# from bs4 import BeautifulSoup
|
| 45 |
+
|
| 46 |
+
# try:
|
| 47 |
+
# response = requests.get(club_url, headers=headers)
|
| 48 |
+
# response.raise_for_status()
|
| 49 |
+
|
| 50 |
+
# soup = BeautifulSoup(response.text, 'html.parser')
|
| 51 |
+
# matches = soup.find_all('div', class_='styled__MatchStyled-sc-630jsf-1') # Contenedor principal
|
| 52 |
+
|
| 53 |
+
# results = []
|
| 54 |
+
# for match in matches[:5]:
|
| 55 |
+
# # Extraer fecha y hora
|
| 56 |
+
# date_time = match.find('div', class_=lambda x: x and 'DateTimeStyled' in x)
|
| 57 |
+
# full_date = date_time.get_text(strip=True) if date_time else "Fecha no disponible"
|
| 58 |
+
|
| 59 |
+
# # Equipos y resultado
|
| 60 |
+
# teams = match.find_all('span', class_=lambda x: x and 'TextRegular' in x)
|
| 61 |
+
# score = match.find('span', class_=lambda x: x and 'Scoreboard' in x)
|
| 62 |
+
|
| 63 |
+
# if len(teams) >= 2 and score:
|
| 64 |
+
# home_team = teams[0].get_text(strip=True)
|
| 65 |
+
# away_team = teams[1].get_text(strip=True)
|
| 66 |
+
# results.append({
|
| 67 |
+
# 'date': full_date,
|
| 68 |
+
# 'home_team': home_team,
|
| 69 |
+
# 'score': score.get_text(strip=True),
|
| 70 |
+
# 'away_team': away_team
|
| 71 |
+
# })
|
| 72 |
+
|
| 73 |
+
# return results
|
| 74 |
|
| 75 |
+
except Exception as e:
|
| 76 |
+
print(f"Error: {str(e)}")
|
| 77 |
+
return []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
if not matches:
|
| 80 |
return f"No recent matches found for the team."
|
|
|
|
| 110 |
|
| 111 |
agent = CodeAgent(
|
| 112 |
model=model,
|
| 113 |
+
tools=[final_answer], # get_last_match], ## add your tools here (don't remove final answer)
|
| 114 |
max_steps=6,
|
| 115 |
verbosity_level=1,
|
| 116 |
grammar=None,
|