Srj-ai commited on
Commit
e8bbbcc
·
verified ·
1 Parent(s): 81b44eb

update the tools to check for temporary files and extract file paths

Browse files
Files changed (1) hide show
  1. app.py +17 -8
app.py CHANGED
@@ -33,21 +33,26 @@ def describe_image(path: str) -> str:
33
  return image_captioner(path)[0]["generated_text"]
34
 
35
  @tool
36
- def audio_to_text_tool(audio_file_path:str) -> str:
37
  """Converts audio file to text. requires audio file path. return transcribed text.
38
  Args:
39
  audio_file_path: path of audio data file
40
  """
 
 
 
41
  output = SpeechToTextTool()
42
  return output(audio_file_path)
43
 
44
  @tool
45
- def excel_reader(file_path:str) -> str:
46
- """ reads an excel file. Requires the file path as input. Return information on rows and columns and description of the file.
47
  Args:
48
- file_path: file path as input
49
  """
50
- df= pd.read_excel(file_path)
 
 
51
  return f"Rows: {len(df)}, Columns: {list(df.columns)}, Description: {df.describe()}"
52
 
53
  class BasicAgent:
@@ -67,7 +72,7 @@ class BasicAgent:
67
  planning_interval=None,
68
  name=None,
69
  description=None,
70
- additional_authorized_imports = [ 'cv2','PIL','time', 'math', 'stat', 're', 'queue', 'statistics', 'unicodedata', 'datetime', 'collections', 'itertools', 'random','json','numpy']
71
  )
72
 
73
  #self.model = InferenceClientModel(model= "Qwen/Qwen2.5-7B-Instruct",)
@@ -88,10 +93,14 @@ CRITICAL RULES (Follow EXACTLY):
88
  6. For cities: full name, no abbreviations (Los Angeles, not LA)
89
 
90
  Important: Do not hallucinate. Try to keep your answers based on facts as much as you can. You will be asked a question, make sure you only give the answer asked in the question. Do a web search first and then wikipediasearch.
91
-
 
 
 
 
92
  Question: {question}
93
 
94
- Respond with ONLY the final answer."""
95
 
96
  output = self.agent.run(prompt)
97
  return str(output).strip()
 
33
  return image_captioner(path)[0]["generated_text"]
34
 
35
  @tool
36
+ def audio_to_text_tool(directory: str = "/tmp") -> str:
37
  """Converts audio file to text. requires audio file path. return transcribed text.
38
  Args:
39
  audio_file_path: path of audio data file
40
  """
41
+ files = os.listdir('/tmp')
42
+ audio_file = [f for f in files if f.endswith('.mp3')][0]
43
+ audio_file_path = f"/tmp/{audio_file}"
44
  output = SpeechToTextTool()
45
  return output(audio_file_path)
46
 
47
  @tool
48
+ def excel_reader(directory: str = "/tmp") -> str:
49
+ """ reads an excel file. Requires the temporary file. Return information on rows and columns and description of the file.
50
  Args:
51
+ /tmp: file path as input
52
  """
53
+ files = os.listdir('/tmp')
54
+ excel_file = [f for f in files if f.endswith('.xlsx')][0]
55
+ df = pd.read_excel(f"/tmp/{excel_file}")
56
  return f"Rows: {len(df)}, Columns: {list(df.columns)}, Description: {df.describe()}"
57
 
58
  class BasicAgent:
 
72
  planning_interval=None,
73
  name=None,
74
  description=None,
75
+ additional_authorized_imports = [ 'os','cv2','PIL','time', 'math', 'stat', 're', 'queue', 'statistics', 'unicodedata', 'datetime', 'collections', 'itertools', 'random','json','numpy']
76
  )
77
 
78
  #self.model = InferenceClientModel(model= "Qwen/Qwen2.5-7B-Instruct",)
 
93
  6. For cities: full name, no abbreviations (Los Angeles, not LA)
94
 
95
  Important: Do not hallucinate. Try to keep your answers based on facts as much as you can. You will be asked a question, make sure you only give the answer asked in the question. Do a web search first and then wikipediasearch.
96
+ CRITICAL:
97
+ 1. GAIA files are at /tmp/task_*/filename
98
+ 2. List files: import os; print(os.listdir('/tmp'))
99
+ 3. Use REAL paths from os.listdir()
100
+ 4. Paths start with /tmp/task_"""
101
  Question: {question}
102
 
103
+ Respond with ONLY the result."""
104
 
105
  output = self.agent.run(prompt)
106
  return str(output).strip()