Srj-ai commited on
Commit
bcd231c
·
verified ·
1 Parent(s): 7ed7164

Changed model and updated prompt

Browse files
Files changed (1) hide show
  1. app.py +16 -11
app.py CHANGED
@@ -25,12 +25,15 @@ image_captioner = pipeline(
25
 
26
 
27
  @tool
28
- def describe_image(path: str) -> str:
29
- """Describes the image. requires image path. return image description.
30
  Args:
31
- path: Path to the image file to analyze.
32
  """
33
- return image_captioner(path)[0]["generated_text"]
 
 
 
34
 
35
  @tool
36
  def audio_to_text_tool(directory: str = "/tmp") -> str:
@@ -39,7 +42,7 @@ def audio_to_text_tool(directory: str = "/tmp") -> str:
39
  directory: Temporary directory where .mp3 file are stored as input
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)
@@ -51,7 +54,7 @@ def excel_reader(directory: str = "/tmp") -> str:
51
  directory: Temporary directory where .xlsx file are stored 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
 
@@ -60,13 +63,13 @@ class BasicAgent:
60
  print("Srj's Agent initialized.")
61
  self.model = InferenceClientModel(max_tokens=2096,
62
  temperature=0.5,
63
- model_id='meta-llama/Meta-Llama-3-8B-Instruct',
64
- provider="novita"
65
 
66
  )
67
  self.agent = CodeAgent(
68
  model=self.model,
69
- tools=[final_answer, web_search,audio_to_text_tool,wikipedia_search,python_code_executor,excel_reader, describe_image], # add your tools here (don't remove final_answer)
70
  max_steps=7,
71
  verbosity_level=1,
72
  planning_interval=None,
@@ -92,12 +95,14 @@ CRITICAL RULES (Follow EXACTLY):
92
  5. Spell out numbers in words when asked for text
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."""
 
25
 
26
 
27
  @tool
28
+ def image_tool(directory: str = "/tmp") -> str:
29
+ """Describes the image. Requires the temporary directory file. Returns image description.
30
  Args:
31
+ directory: Temporary directory where .jpg file are stored as input
32
  """
33
+ files = os.listdir('/tmp')
34
+ image = [f for f in files if f.endswith('.jpg')]
35
+ audio_file_path = f"/tmp/{image}"
36
+ return image_captioner(audio_file_path)[0]["generated_text"]
37
 
38
  @tool
39
  def audio_to_text_tool(directory: str = "/tmp") -> str:
 
42
  directory: Temporary directory where .mp3 file are stored as input
43
  """
44
  files = os.listdir('/tmp')
45
+ audio_file = [f for f in files if f.endswith('.mp3')]
46
  audio_file_path = f"/tmp/{audio_file}"
47
  output = SpeechToTextTool()
48
  return output(audio_file_path)
 
54
  directory: Temporary directory where .xlsx file are stored as input
55
  """
56
  files = os.listdir('/tmp')
57
+ excel_file = [f for f in files if f.endswith('.xlsx')]
58
  df = pd.read_excel(f"/tmp/{excel_file}")
59
  return f"Rows: {len(df)}, Columns: {list(df.columns)}, Description: {df.describe()}"
60
 
 
63
  print("Srj's Agent initialized.")
64
  self.model = InferenceClientModel(max_tokens=2096,
65
  temperature=0.5,
66
+ model_id='google/gemma-3n-E4B-it',
67
+ provider="together"
68
 
69
  )
70
  self.agent = CodeAgent(
71
  model=self.model,
72
+ tools=[final_answer, web_search,audio_to_text_tool,wikipedia_search,python_code_executor,excel_reader, image_tool], # add your tools here (don't remove final_answer)
73
  max_steps=7,
74
  verbosity_level=1,
75
  planning_interval=None,
 
95
  5. Spell out numbers in words when asked for text
96
  6. For cities: full name, no abbreviations (Los Angeles, not LA)
97
 
98
+ 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. You might need to do multiple searches to answer a question. For. eg. Question -> search -> clue -> search again with clue in consideration -> better clue -> result.
99
+
100
+ When handling with files (Format: .xlxs, .mp3, .jpg) received in the question. You can consider the following steps:
101
  1. GAIA files are at /tmp/task_*/filename
102
  2. List files: import os; print(os.listdir('/tmp'))
103
  3. Use REAL paths from os.listdir()
104
  4. Paths start with /tmp/task_
105
+
106
  Question: {question}
107
 
108
  Respond with ONLY the result."""