Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -182,7 +182,29 @@ class BasicAgent:
|
|
| 182 |
return question + "\n\nBelow is the .png image in base64 format:\n\n```base64\n" + base64_str + "\n```\n"
|
| 183 |
|
| 184 |
|
| 185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
|
| 187 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 188 |
"""
|
|
|
|
| 182 |
return question + "\n\nBelow is the .png image in base64 format:\n\n```base64\n" + base64_str + "\n```\n"
|
| 183 |
|
| 184 |
|
| 185 |
+
def enrich_question_with_associated_file_details(self, task_id:str, question: str, file_name: str) -> str:
|
| 186 |
+
api_url = DEFAULT_API_URL
|
| 187 |
+
get_associated_files_url = f"{api_url}/files/{task_id}"
|
| 188 |
+
response = requests.get(get_associated_files_url, timeout=15)
|
| 189 |
+
response.raise_for_status()
|
| 190 |
+
|
| 191 |
+
if file_name.endswith(".mp3"):
|
| 192 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
|
| 193 |
+
tmp_file.write(response.content)
|
| 194 |
+
file_path = tmp_file.name
|
| 195 |
+
return question + "\n\nMentioned .mp3 file local path is: " + file_path
|
| 196 |
+
elif file_name.endswith(".py"):
|
| 197 |
+
file_content = response.text
|
| 198 |
+
return question + "\n\nBelow is mentioned Python file:\n\n```python\n" + file_content + "\n```\n"
|
| 199 |
+
elif file_name.endswith(".xlsx"):
|
| 200 |
+
xlsx_io = BytesIO(response.content)
|
| 201 |
+
df = pd.read_excel(xlsx_io)
|
| 202 |
+
file_content = df.to_csv(index=False)
|
| 203 |
+
return question + "\n\nBelow is mentioned excel file in CSV format:\n\n```csv\n" + file_content + "\n```\n"
|
| 204 |
+
elif file_name.endswith(".png"):
|
| 205 |
+
base64_str = base64.b64encode(response.content).decode('utf-8')
|
| 206 |
+
return question + "\n\nBelow is the .png image in base64 format:\n\n```base64\n" + base64_str + "\n```\n"
|
| 207 |
+
|
| 208 |
|
| 209 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 210 |
"""
|