Update app.py
Browse files
app.py
CHANGED
|
@@ -114,7 +114,7 @@ class ReActAgent:
|
|
| 114 |
|
| 115 |
def _llm(self, messages: list[dict]) -> str:
|
| 116 |
if not self.token:
|
| 117 |
-
return "Error: HF_TOKEN not set. Add your
|
| 118 |
url = f"https://api-inference.huggingface.co/models/{self.model}"
|
| 119 |
headers = {"Authorization": f"Bearer {self.token}", "Content-Type": "application/json"}
|
| 120 |
payload = {"inputs": self._messages_to_prompt(messages), "parameters": {"max_new_tokens": 512, "return_full_text": False}}
|
|
@@ -165,7 +165,7 @@ class ReActAgent:
|
|
| 165 |
def __call__(self, question: str) -> str:
|
| 166 |
print(f"ReAct agent received question (first 50 chars): {question[:50]}...")
|
| 167 |
if not self.token:
|
| 168 |
-
return "HF_TOKEN not set.
|
| 169 |
system = (
|
| 170 |
"You are a ReAct agent. For each turn you must either:\n"
|
| 171 |
"1. Output: Thought: <reasoning> then Action: <tool_name> then Action Input: <input>\n"
|
|
@@ -325,7 +325,8 @@ with gr.Blocks() as demo:
|
|
| 325 |
gr.Markdown(
|
| 326 |
"""
|
| 327 |
**Multi-step ReAct agent:** Plan β Act (tools) β Observe β Reflect. The agent has access to:
|
| 328 |
-
**DuckDuckGo search**, **web page view**, and **code agent** (safe Python).
|
|
|
|
| 329 |
1. Log in with the button below. 2. Click 'Run Evaluation & Submit All Answers'. Submission can take a while while the agent runs on all questions.
|
| 330 |
"""
|
| 331 |
)
|
|
|
|
| 114 |
|
| 115 |
def _llm(self, messages: list[dict]) -> str:
|
| 116 |
if not self.token:
|
| 117 |
+
return "Error: HF_TOKEN not set. Add it in your Space: Settings β Variables and secrets β New secret (name: HF_TOKEN)."
|
| 118 |
url = f"https://api-inference.huggingface.co/models/{self.model}"
|
| 119 |
headers = {"Authorization": f"Bearer {self.token}", "Content-Type": "application/json"}
|
| 120 |
payload = {"inputs": self._messages_to_prompt(messages), "parameters": {"max_new_tokens": 512, "return_full_text": False}}
|
|
|
|
| 165 |
def __call__(self, question: str) -> str:
|
| 166 |
print(f"ReAct agent received question (first 50 chars): {question[:50]}...")
|
| 167 |
if not self.token:
|
| 168 |
+
return "HF_TOKEN not set. In your Hugging Face Space go to Settings β Variables and secrets, add a secret named HF_TOKEN with your token."
|
| 169 |
system = (
|
| 170 |
"You are a ReAct agent. For each turn you must either:\n"
|
| 171 |
"1. Output: Thought: <reasoning> then Action: <tool_name> then Action Input: <input>\n"
|
|
|
|
| 325 |
gr.Markdown(
|
| 326 |
"""
|
| 327 |
**Multi-step ReAct agent:** Plan β Act (tools) β Observe β Reflect. The agent has access to:
|
| 328 |
+
**DuckDuckGo search**, **web page view**, and **code agent** (safe Python).
|
| 329 |
+
**Token:** In this Space go to **Settings β Variables and secrets** (Secrets), add a secret named **HF_TOKEN** with your Hugging Face token so the LLM can run.
|
| 330 |
1. Log in with the button below. 2. Click 'Run Evaluation & Submit All Answers'. Submission can take a while while the agent runs on all questions.
|
| 331 |
"""
|
| 332 |
)
|