Spaces:
Sleeping
Sleeping
Add comments for LLM proxy usage and enhance task instructions
Browse files- basic_agent.py +22 -14
basic_agent.py
CHANGED
|
@@ -56,6 +56,7 @@ class BasicAgent:
|
|
| 56 |
api_key=os.getenv("GROQ_API_KEY")
|
| 57 |
)
|
| 58 |
|
|
|
|
| 59 |
model = LiteLLMModel(
|
| 60 |
model_id="groq/deepseek-r1-distill-llama-70b",
|
| 61 |
api_base="http://127.0.0.1:4000"
|
|
@@ -95,22 +96,29 @@ class BasicAgent:
|
|
| 95 |
Your primary goal is to accurately and concisely answer the provided question using your available tools and any supplied information.
|
| 96 |
|
| 97 |
Key Instructions:
|
| 98 |
-
1. **Understand the Task**: Carefully read the entire question.
|
| 99 |
-
2. **Select Tools
|
| 100 |
-
* Choose the
|
| 101 |
-
* For web research, use
|
| 102 |
-
* **Working with Local Files**: If the "File Information" section provides a local file path
|
| 103 |
-
*
|
| 104 |
-
*
|
| 105 |
-
* For general calculations, data analysis
|
| 106 |
-
3. **
|
| 107 |
-
*
|
| 108 |
-
*
|
| 109 |
-
*
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
* Provide only the final, concise answer to the question.
|
| 112 |
* Do not include your reasoning steps, apologies, self-correction narratives, or any conversational filler in the final answer.
|
| 113 |
-
* If, after a thorough investigation
|
| 114 |
|
| 115 |
--- Start of Question & File Information ---
|
| 116 |
{question_to_llm}
|
|
|
|
| 56 |
api_key=os.getenv("GROQ_API_KEY")
|
| 57 |
)
|
| 58 |
|
| 59 |
+
# use LLM proxy server to avoid rate limits issues
|
| 60 |
model = LiteLLMModel(
|
| 61 |
model_id="groq/deepseek-r1-distill-llama-70b",
|
| 62 |
api_base="http://127.0.0.1:4000"
|
|
|
|
| 96 |
Your primary goal is to accurately and concisely answer the provided question using your available tools and any supplied information.
|
| 97 |
|
| 98 |
Key Instructions:
|
| 99 |
+
1. **Understand the Task**: Carefully read the entire question. Pay close attention to the "File Information" section provided below the question; it states if a local file is available and its path.
|
| 100 |
+
2. **Strategize and Select Tools**:
|
| 101 |
+
* Choose the most appropriate tool(s) based on the question, file details, and tool capabilities.
|
| 102 |
+
* For web research, use `web_search` or `wikipedia_search`. Use `visit_webpage` to get content from specific URLs found or given.
|
| 103 |
+
* **Working with Local Files**: If the "File Information" section provides a local file path *and that file's content is needed*:
|
| 104 |
+
* The primary tool to access this local file is the `PythonInterpreterTool`.
|
| 105 |
+
* Generate Python code for this tool to open the file (using its full, exact local path from "File Information"), then read, process, or execute its content as required.
|
| 106 |
+
* For general calculations, data analysis not involving a mentioned local file, or other Python tasks, use `PythonInterpreterTool`.
|
| 107 |
+
3. **Information Analysis & Verification**:
|
| 108 |
+
* When examining content from web pages or files, critically evaluate the information.
|
| 109 |
+
* **Pay specific attention to details like names, dates, and roles (e.g., distinguish between a nominator, a promoter, an author, etc.).**
|
| 110 |
+
* Synthesize information from multiple steps or tools if necessary.
|
| 111 |
+
* Base your final answer *only* on confirmed facts from the information gathered. Do not make assumptions.
|
| 112 |
+
4. **Handling Tool Errors**:
|
| 113 |
+
* If a tool call results in an error (e.g., PythonInterpreterTool syntax error, file not found by a tool):
|
| 114 |
+
a. **Analyze the error message.**
|
| 115 |
+
b. **Do not immediately retry the exact same tool call with the exact same arguments.**
|
| 116 |
+
c. Instead, try to **correct the input to the tool** (e.g., fix the Python code, verify a URL or file path).
|
| 117 |
+
d. If correction isn't obvious or fails, consider if a different tool or a different approach is more suitable.
|
| 118 |
+
5. **Formulate Your Response**:
|
| 119 |
* Provide only the final, concise answer to the question.
|
| 120 |
* Do not include your reasoning steps, apologies, self-correction narratives, or any conversational filler in the final answer.
|
| 121 |
+
* If, after a thorough investigation and attempts to use tools effectively (including handling errors), you cannot determine a definitive answer, respond with the exact phrase 'I don't know'.
|
| 122 |
|
| 123 |
--- Start of Question & File Information ---
|
| 124 |
{question_to_llm}
|