tuan3335 commited on
Commit
6bef95f
·
1 Parent(s): c5208b6

feat: improve tool selection prompt (English), log wiki and audio transcript results for debugging

Browse files
Files changed (1) hide show
  1. agent.py +15 -2
agent.py CHANGED
@@ -83,6 +83,12 @@ class AIBrain:
83
 
84
  prompt = f"""<instruction>
85
  Analyze this question and determine the correct tool approach. Return ONLY valid JSON.
 
 
 
 
 
 
86
  </instruction>
87
 
88
  <question>{question}</question>
@@ -90,10 +96,10 @@ Analyze this question and determine the correct tool approach. Return ONLY valid
90
 
91
  <classification_rules>
92
  - YouTube URLs (youtube.com, youtu.be): "youtube"
93
- - Images, photos, chess positions, visual content: "image"
94
  - Audio files, voice, sound, mp3: "audio"
95
  - Excel, CSV, documents, file uploads: "file"
96
- - Wikipedia searches, historical facts, people info: "wiki"
97
  - Math calculations, logic, text analysis: "text"
98
  </classification_rules>
99
 
@@ -200,6 +206,13 @@ def process_with_tools_node(state: AgentState) -> AgentState:
200
  tool_results = process_question_with_tools(question, task_id)
201
  state["tool_processing_result"] = tool_results
202
 
 
 
 
 
 
 
 
203
  successful_tools = [result.tool_name for result in tool_results.get("tool_results", []) if result.success]
204
  if successful_tools:
205
  print(f"✅ Successful tools: {successful_tools}")
 
83
 
84
  prompt = f"""<instruction>
85
  Analyze this question and determine the correct tool approach. Return ONLY valid JSON.
86
+
87
+ - If the question is about an event in the past or future (e.g., "when was", "in what year", "has ever", "will happen", "history", "prediction"), choose "wiki".
88
+ - If the question asks about a specific topic, person, place, object, or event (e.g., "who is", "what is", "where is", "when is", "why", "how"), choose "wiki".
89
+ - If the data source is unclear or you are not sure, prefer "wiki".
90
+ - Other types: youtube (if there is a link/video), image (if there is an image), audio (if there is an audio file), file (if there is an attachment), text (if it is text analysis or math).
91
+
92
  </instruction>
93
 
94
  <question>{question}</question>
 
96
 
97
  <classification_rules>
98
  - YouTube URLs (youtube.com, youtu.be): "youtube"
99
+ - Images, photos, chess positions, visual content: "image"
100
  - Audio files, voice, sound, mp3: "audio"
101
  - Excel, CSV, documents, file uploads: "file"
102
+ - Wikipedia searches, historical facts, people info, events, future/past, specific topics: "wiki"
103
  - Math calculations, logic, text analysis: "text"
104
  </classification_rules>
105
 
 
206
  tool_results = process_question_with_tools(question, task_id)
207
  state["tool_processing_result"] = tool_results
208
 
209
+ # Log response từ wiki nếu có
210
+ for result in tool_results.get("tool_results", []):
211
+ if result.tool_name == "wiki_search":
212
+ print(f"[DEBUG] Wiki tool response: {result.result}")
213
+ if result.tool_name == "audio_transcript":
214
+ print(f"[DEBUG] Audio transcript: {result.result}")
215
+
216
  successful_tools = [result.tool_name for result in tool_results.get("tool_results", []) if result.success]
217
  if successful_tools:
218
  print(f"✅ Successful tools: {successful_tools}")