ORromu commited on
Commit
b65bdf2
·
verified ·
1 Parent(s): 3592829

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -51
app.py CHANGED
@@ -14,52 +14,8 @@ model = OpenAIServerModel(
14
  api_base="https://generativelanguage.googleapis.com/v1beta/openai/"
15
  )
16
 
17
- # prompt = PromptTemplates(
18
- # system_prompt="""
19
- # You are a helpful assistant tasked with answering questions using a set of tools.
20
- # {{tool_descriptions}}
21
-
22
- # Now, I will ask you a question. Report your thoughts, and finish your answer with the following template:
23
-
24
- # FINAL ANSWER: [YOUR FINAL ANSWER].
25
-
26
- # YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
27
- # - If you are asked for a number, don't use commas or units like $ or %, unless explicitly required.
28
- # - If you are asked for a string, do not include articles or abbreviations, and write digits in full unless otherwise specified.
29
- # - If asked for a comma-separated list, apply the above rules depending on whether the list elements are numbers or strings.
30
-
31
- # Your answer should **only** start with `FINAL ANSWER: ` followed by the answer.
32
- # """,
33
-
34
- # planning="""
35
- # You have received the following task:
36
- # {{task_description}}
37
-
38
- # Think step-by-step about what tools or steps are needed to solve it. Plan clearly before proceeding.
39
- # """,
40
-
41
- # managed_agent="""
42
- # You are executing the following step:
43
- # {{step_description}}
44
-
45
- # Use available tools wisely. Think before acting, and ensure your actions follow the original instruction format.
46
-
47
- # Remember to ultimately return the answer in the format:
48
- # FINAL ANSWER: [YOUR FINAL ANSWER]
49
- # """,
50
-
51
- # final_answer="""
52
- # You have completed all steps.
53
-
54
- # Now, return your final response using the following format:
55
- # FINAL ANSWER: [YOUR FINAL ANSWER]
56
-
57
- # YOUR FINAL ANSWER should be a number, a few words, or a comma-separated list, following the formatting rules provided earlier.
58
- # """
59
- # )
60
-
61
- prompt = {
62
- 'system_prompt':"""
63
  You are a helpful assistant tasked with answering questions using a set of tools.
64
  {{tool_descriptions}}
65
 
@@ -75,14 +31,14 @@ YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma sepa
75
  Your answer should **only** start with `FINAL ANSWER: ` followed by the answer.
76
  """,
77
 
78
- 'planning':"""
79
  You have received the following task:
80
  {{task_description}}
81
 
82
  Think step-by-step about what tools or steps are needed to solve it. Plan clearly before proceeding.
83
  """,
84
 
85
- 'managed_agent':"""
86
  You are executing the following step:
87
  {{step_description}}
88
 
@@ -92,7 +48,7 @@ Remember to ultimately return the answer in the format:
92
  FINAL ANSWER: [YOUR FINAL ANSWER]
93
  """,
94
 
95
- 'final_answer':"""
96
  You have completed all steps.
97
 
98
  Now, return your final response using the following format:
@@ -100,7 +56,51 @@ FINAL ANSWER: [YOUR FINAL ANSWER]
100
 
101
  YOUR FINAL ANSWER should be a number, a few words, or a comma-separated list, following the formatting rules provided earlier.
102
  """
103
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
 
105
 
106
  # (Keep Constants as is)
@@ -115,8 +115,9 @@ class BasicAgent:
115
  tools = [DuckDuckGoSearchTool(), WikipediaSearchTool()],
116
  model = model,
117
  add_base_tools=True,
118
- system_prompt = prompt
119
  )
 
 
120
  print("BasicAgent initialized.")
121
  def __call__(self, question: str) -> str:
122
  print(f"Agent received question (first 50 chars): {question[:50]}...")
 
14
  api_base="https://generativelanguage.googleapis.com/v1beta/openai/"
15
  )
16
 
17
+ prompt = PromptTemplates(
18
+ system_prompt="""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  You are a helpful assistant tasked with answering questions using a set of tools.
20
  {{tool_descriptions}}
21
 
 
31
  Your answer should **only** start with `FINAL ANSWER: ` followed by the answer.
32
  """,
33
 
34
+ planning="""
35
  You have received the following task:
36
  {{task_description}}
37
 
38
  Think step-by-step about what tools or steps are needed to solve it. Plan clearly before proceeding.
39
  """,
40
 
41
+ managed_agent="""
42
  You are executing the following step:
43
  {{step_description}}
44
 
 
48
  FINAL ANSWER: [YOUR FINAL ANSWER]
49
  """,
50
 
51
+ final_answer="""
52
  You have completed all steps.
53
 
54
  Now, return your final response using the following format:
 
56
 
57
  YOUR FINAL ANSWER should be a number, a few words, or a comma-separated list, following the formatting rules provided earlier.
58
  """
59
+ )
60
+
61
+ # prompt = {
62
+ # 'system_prompt':"""
63
+ # You are a helpful assistant tasked with answering questions using a set of tools.
64
+ # {{tool_descriptions}}
65
+
66
+ # Now, I will ask you a question. Report your thoughts, and finish your answer with the following template:
67
+
68
+ # FINAL ANSWER: [YOUR FINAL ANSWER].
69
+
70
+ # YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
71
+ # - If you are asked for a number, don't use commas or units like $ or %, unless explicitly required.
72
+ # - If you are asked for a string, do not include articles or abbreviations, and write digits in full unless otherwise specified.
73
+ # - If asked for a comma-separated list, apply the above rules depending on whether the list elements are numbers or strings.
74
+
75
+ # Your answer should **only** start with `FINAL ANSWER: ` followed by the answer.
76
+ # """,
77
+
78
+ # 'planning':"""
79
+ # You have received the following task:
80
+ # {{task_description}}
81
+
82
+ # Think step-by-step about what tools or steps are needed to solve it. Plan clearly before proceeding.
83
+ # """,
84
+
85
+ # 'managed_agent':"""
86
+ # You are executing the following step:
87
+ # {{step_description}}
88
+
89
+ # Use available tools wisely. Think before acting, and ensure your actions follow the original instruction format.
90
+
91
+ # Remember to ultimately return the answer in the format:
92
+ # FINAL ANSWER: [YOUR FINAL ANSWER]
93
+ # """,
94
+
95
+ # 'final_answer':"""
96
+ # You have completed all steps.
97
+
98
+ # Now, return your final response using the following format:
99
+ # FINAL ANSWER: [YOUR FINAL ANSWER]
100
+
101
+ # YOUR FINAL ANSWER should be a number, a few words, or a comma-separated list, following the formatting rules provided earlier.
102
+ # """
103
+ # }
104
 
105
 
106
  # (Keep Constants as is)
 
115
  tools = [DuckDuckGoSearchTool(), WikipediaSearchTool()],
116
  model = model,
117
  add_base_tools=True,
 
118
  )
119
+
120
+ self.agent.prompt_templates["system_prompt"] = prompt
121
  print("BasicAgent initialized.")
122
  def __call__(self, question: str) -> str:
123
  print(f"Agent received question (first 50 chars): {question[:50]}...")