Spaces:
Sleeping
Sleeping
agent logic
Browse files
agent.py
CHANGED
|
@@ -176,7 +176,7 @@ class BoomBot:
|
|
| 176 |
|
| 177 |
# Modify the system prompt
|
| 178 |
modified_prompt = replace_tool_mentions(agent.system_prompt)
|
| 179 |
-
agent.system_prompt = modified_prompt
|
| 180 |
|
| 181 |
return agent
|
| 182 |
|
|
@@ -258,12 +258,20 @@ class BoomBot:
|
|
| 258 |
Returns:
|
| 259 |
str: The agent's response
|
| 260 |
"""
|
| 261 |
-
|
|
|
|
|
|
|
|
|
|
| 262 |
|
| 263 |
-
#
|
| 264 |
if to_download:
|
| 265 |
-
|
| 266 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 267 |
|
| 268 |
# Run the agent with the given question
|
| 269 |
result = self.agent.generate_response(question)
|
|
|
|
| 176 |
|
| 177 |
# Modify the system prompt
|
| 178 |
modified_prompt = replace_tool_mentions(agent.system_prompt)
|
| 179 |
+
agent.system_prompt = modified_prompt
|
| 180 |
|
| 181 |
return agent
|
| 182 |
|
|
|
|
| 258 |
Returns:
|
| 259 |
str: The agent's response
|
| 260 |
"""
|
| 261 |
+
prompt = self._get_system_prompt()
|
| 262 |
+
# Task introduction
|
| 263 |
+
prompt += "\nHere is the Task you need to solve:\n\n"
|
| 264 |
+
prompt += f"Task: {question}\n\n"
|
| 265 |
|
| 266 |
+
# Include download instructions if applicable
|
| 267 |
if to_download:
|
| 268 |
+
link = f"https://agents-course-unit4-scoring.hf.space/files/{task_id}"
|
| 269 |
+
prompt += (
|
| 270 |
+
"IMPORTANT: Before solving the task, you must download a required file.\n"
|
| 271 |
+
f"Use the `download_file_from_link` tool with this link: {link}\n"
|
| 272 |
+
"After downloading, use the appropriate tool to read or process the file "
|
| 273 |
+
"before attempting to solve the task.\n\n"
|
| 274 |
+
)
|
| 275 |
|
| 276 |
# Run the agent with the given question
|
| 277 |
result = self.agent.generate_response(question)
|
app.py
CHANGED
|
@@ -4,7 +4,6 @@ import os
|
|
| 4 |
import gradio as gr
|
| 5 |
import pandas as pd
|
| 6 |
import requests
|
| 7 |
-
from traitlets import Bool # type: ignore
|
| 8 |
|
| 9 |
from agent import BoomBot
|
| 10 |
|
|
@@ -17,9 +16,9 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 17 |
class BasicAgent:
|
| 18 |
def __init__(self):
|
| 19 |
print("BasicAgent initialized.")
|
| 20 |
-
self.agent = BoomBot(provider="
|
| 21 |
|
| 22 |
-
def __call__(self, question: str, task_id: str, to_download
|
| 23 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 24 |
return self.agent.run(question, task_id, to_download)
|
| 25 |
|
|
|
|
| 4 |
import gradio as gr
|
| 5 |
import pandas as pd
|
| 6 |
import requests
|
|
|
|
| 7 |
|
| 8 |
from agent import BoomBot
|
| 9 |
|
|
|
|
| 16 |
class BasicAgent:
|
| 17 |
def __init__(self):
|
| 18 |
print("BasicAgent initialized.")
|
| 19 |
+
self.agent = BoomBot(provider="deepinfra")
|
| 20 |
|
| 21 |
+
def __call__(self, question: str, task_id: str, to_download) -> str:
|
| 22 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 23 |
return self.agent.run(question, task_id, to_download)
|
| 24 |
|