Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,6 +14,7 @@ from langchain_tavily import TavilySearch
|
|
| 14 |
from tools import (
|
| 15 |
download_task_file,
|
| 16 |
read_attached_text_file,
|
|
|
|
| 17 |
answer_excel_question,
|
| 18 |
answer_python_question,
|
| 19 |
get_youtube_transcript,
|
|
@@ -45,11 +46,12 @@ class BasicAgent:
|
|
| 45 |
temperature=0,
|
| 46 |
timeout=30,
|
| 47 |
max_retries=1,
|
| 48 |
-
max_tokens=
|
| 49 |
)
|
| 50 |
self.tools = [
|
| 51 |
download_task_file,
|
| 52 |
read_attached_text_file,
|
|
|
|
| 53 |
answer_excel_question,
|
| 54 |
answer_python_question,
|
| 55 |
get_youtube_transcript,
|
|
@@ -97,10 +99,27 @@ class BasicAgent:
|
|
| 97 |
print(f"Agent error: {e}", flush=True)
|
| 98 |
return ""
|
| 99 |
def assistant(self, state: AgentState):
|
| 100 |
-
sys_msg = SystemMessage(content=
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
""")
|
| 105 |
return {
|
| 106 |
"messages": [self.chat_with_tools.invoke([sys_msg] + state["messages"])],
|
|
|
|
| 14 |
from tools import (
|
| 15 |
download_task_file,
|
| 16 |
read_attached_text_file,
|
| 17 |
+
answer_image_question,
|
| 18 |
answer_excel_question,
|
| 19 |
answer_python_question,
|
| 20 |
get_youtube_transcript,
|
|
|
|
| 46 |
temperature=0,
|
| 47 |
timeout=30,
|
| 48 |
max_retries=1,
|
| 49 |
+
max_tokens=1024,
|
| 50 |
)
|
| 51 |
self.tools = [
|
| 52 |
download_task_file,
|
| 53 |
read_attached_text_file,
|
| 54 |
+
answer_image_question,
|
| 55 |
answer_excel_question,
|
| 56 |
answer_python_question,
|
| 57 |
get_youtube_transcript,
|
|
|
|
| 99 |
print(f"Agent error: {e}", flush=True)
|
| 100 |
return ""
|
| 101 |
def assistant(self, state: AgentState):
|
| 102 |
+
sys_msg = SystemMessage(content="""
|
| 103 |
+
You are a precise question-answering agent.
|
| 104 |
+
|
| 105 |
+
Use tools aggressively when the question involves:
|
| 106 |
+
- attached files
|
| 107 |
+
- images or screenshots
|
| 108 |
+
- spreadsheets
|
| 109 |
+
- Python code files
|
| 110 |
+
- YouTube videos
|
| 111 |
+
- web lookup
|
| 112 |
+
|
| 113 |
+
Tool policy:
|
| 114 |
+
- For image, screenshot, chess position, chart image, diagram, or visual counting questions, use answer_image_question.
|
| 115 |
+
- For Excel or CSV questions, use answer_excel_question.
|
| 116 |
+
- For Python-code-output questions, use answer_python_question.
|
| 117 |
+
- For plain text attachments, use read_attached_text_file.
|
| 118 |
+
- For YouTube speech/transcript questions, use get_youtube_transcript.
|
| 119 |
+
- For current or external factual lookup, use web search.
|
| 120 |
+
|
| 121 |
+
Answer directly and concisely.
|
| 122 |
+
Return only the final answer unless explanation is necessary.
|
| 123 |
""")
|
| 124 |
return {
|
| 125 |
"messages": [self.chat_with_tools.invoke([sys_msg] + state["messages"])],
|