naman1102 commited on
Commit
d959c4d
·
1 Parent(s): eef9878

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -13,9 +13,14 @@ from state import AgentState
13
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
14
 
15
  SYSTEM_PROMPT = """
16
- You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER]. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.
 
 
17
 
18
  IMPORTANT: When using tools that require file access (such as audio_transcriber_tool, excel_tool, analyze_code_tool, or image_tool), ALWAYS use the task_id parameter only. Do NOT use any file names mentioned by the user - ignore them completely and only pass the task_id.
 
 
 
19
  """
20
 
21
 
@@ -40,7 +45,8 @@ class BasicAgent:
40
  # IMPORTANT: invoke() returns a **new** state instance (or an AddableValuesDict),
41
  # not the object we pass in. Use the returned value to fetch final_answer.
42
  out_state = self.graph.invoke(init_state, {"recursion_limit": 5})
43
- print("out_state: ", out_state,'\n\n\n\n')
 
44
 
45
  # Extract the final answer from the last message
46
  if out_state and "messages" in out_state:
@@ -48,6 +54,8 @@ class BasicAgent:
48
  if hasattr(last_message, 'content'):
49
  content = last_message.content
50
  # Look for FINAL ANSWER: pattern
 
 
51
  if "FINAL ANSWER:" in content:
52
  final_answer = content.split("FINAL ANSWER:")[-1].strip()
53
  return final_answer
 
13
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
14
 
15
  SYSTEM_PROMPT = """
16
+ You are a general AI assistant. I will ask you a question.
17
+ Report your thoughts in brief, and finish your answer with the following template:
18
+ FINAL ANSWER: [YOUR FINAL ANSWER]
19
 
20
  IMPORTANT: When using tools that require file access (such as audio_transcriber_tool, excel_tool, analyze_code_tool, or image_tool), ALWAYS use the task_id parameter only. Do NOT use any file names mentioned by the user - ignore them completely and only pass the task_id.
21
+
22
+ YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.
23
+ When using tools that require file access (such as audio_transcriber_tool, excel_tool, analyze_code_tool, or image_tool), ALWAYS use the task_id parameter only. Do NOT use any file names mentioned by the user - ignore them completely and only pass the task_id thats provided to you in the state.
24
  """
25
 
26
 
 
45
  # IMPORTANT: invoke() returns a **new** state instance (or an AddableValuesDict),
46
  # not the object we pass in. Use the returned value to fetch final_answer.
47
  out_state = self.graph.invoke(init_state, {"recursion_limit": 5})
48
+ # print("out_state: ", out_state,'\n\n\n\n')
49
+
50
 
51
  # Extract the final answer from the last message
52
  if out_state and "messages" in out_state:
 
54
  if hasattr(last_message, 'content'):
55
  content = last_message.content
56
  # Look for FINAL ANSWER: pattern
57
+ print("content: ", content)
58
+ print("\n\n\n\n")
59
  if "FINAL ANSWER:" in content:
60
  final_answer = content.split("FINAL ANSWER:")[-1].strip()
61
  return final_answer