Spaces:
Sleeping
Sleeping
Changed model and updated prompt
Browse files
app.py
CHANGED
|
@@ -25,12 +25,15 @@ image_captioner = pipeline(
|
|
| 25 |
|
| 26 |
|
| 27 |
@tool
|
| 28 |
-
def
|
| 29 |
-
"""Describes the image.
|
| 30 |
Args:
|
| 31 |
-
|
| 32 |
"""
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
| 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')]
|
| 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')]
|
| 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='
|
| 64 |
-
provider="
|
| 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,
|
| 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 |
-
|
|
|
|
| 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."""
|