rtferraz commited on
Commit
e58b50f
·
verified ·
1 Parent(s): f063425

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -1
app.py CHANGED
@@ -3,6 +3,7 @@ import datetime
3
  import requests
4
  import pytz
5
  import yaml
 
6
  from tools.final_answer import FinalAnswerTool
7
 
8
  from Gradio_UI import GradioUI
@@ -29,6 +30,26 @@ def get_random_joke()-> str: #it's import to specify the return type
29
  # Return an error message if the request fails
30
  return f"Failed to retrieve joke. Status code: {response.status_code}"
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  @tool
33
  def get_current_time_in_timezone(timezone: str) -> str:
34
  """A tool that fetches the current local time in a specified timezone.
@@ -66,7 +87,7 @@ with open("prompts.yaml", 'r') as stream:
66
 
67
  agent = CodeAgent(
68
  model=model,
69
- tools=[get_random_joke,final_answer], ## add your tools here (don't remove final answer)
70
  max_steps=6,
71
  verbosity_level=1,
72
  grammar=None,
 
3
  import requests
4
  import pytz
5
  import yaml
6
+ import pandas as pd
7
  from tools.final_answer import FinalAnswerTool
8
 
9
  from Gradio_UI import GradioUI
 
30
  # Return an error message if the request fails
31
  return f"Failed to retrieve joke. Status code: {response.status_code}"
32
 
33
+ @tool
34
+ def get_user_row(user_name: str) -> str:
35
+ """A tool that fetches more information about the user in a .csv file.
36
+ Args:
37
+ user_name: A string that's the user name.
38
+ """
39
+
40
+ # Load the CSV file into a DataFrame
41
+ df = pd.read_csv("data.csv", encoding="utf-8")
42
+
43
+ # Filter the DataFrame to find rows where the CLIENTE column matches the username
44
+ client_row = df[df["CLIENTE:"].str.strip().str.lower() == username.strip().lower()]
45
+
46
+ # If no rows are found, return None
47
+ if client_row.empty:
48
+ return f"Didn't find any information for CLIENTE: {user_name}"
49
+
50
+ # Return the row(s) as a dictionary (or DataFrame if preferred)
51
+ return client_row.to_dict(orient="records")
52
+
53
  @tool
54
  def get_current_time_in_timezone(timezone: str) -> str:
55
  """A tool that fetches the current local time in a specified timezone.
 
87
 
88
  agent = CodeAgent(
89
  model=model,
90
+ tools=[get_user_row,get_random_joke,final_answer], ## add your tools here (don't remove final answer)
91
  max_steps=6,
92
  verbosity_level=1,
93
  grammar=None,