Update app.py
Browse filesadded system prompt
app.py
CHANGED
|
@@ -17,6 +17,19 @@ class BasicAgent:
|
|
| 17 |
# Initialize the DuckDuckGo search tool
|
| 18 |
search_tool = DuckDuckGoSearchTool()
|
| 19 |
wiki_search = WikipediaSearchTool()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
# Instantiate the agent
|
| 21 |
self.agent = CodeAgent(
|
| 22 |
tools=[search_tool, wiki_search],
|
|
@@ -25,9 +38,9 @@ class BasicAgent:
|
|
| 25 |
)
|
| 26 |
def __call__(self, question: str) -> str:
|
| 27 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 28 |
-
|
| 29 |
-
print(f"Agent returning answer: {
|
| 30 |
-
return
|
| 31 |
|
| 32 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 33 |
"""
|
|
|
|
| 17 |
# Initialize the DuckDuckGo search tool
|
| 18 |
search_tool = DuckDuckGoSearchTool()
|
| 19 |
wiki_search = WikipediaSearchTool()
|
| 20 |
+
SYSTEM_PROMPT = """You are a general AI assistant. I will ask you a question. Report your thoughts, and
|
| 21 |
+
finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER].
|
| 22 |
+
YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated
|
| 23 |
+
list of numbers and/or strings.
|
| 24 |
+
If you are asked for a number, don't use comma to write your number neither use units such as $ or
|
| 25 |
+
percent sign unless specified otherwise.
|
| 26 |
+
If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the
|
| 27 |
+
digits in plain text unless specified otherwise.
|
| 28 |
+
If you are asked for a comma separated list, apply the above rules depending of whether the element
|
| 29 |
+
to be put in the list is a number or a string.
|
| 30 |
+
"""
|
| 31 |
+
self.agent.prompt_templates["system_prompt"] = self.agent.prompt_templates["system_prompt"] + SYSTEM_PROMPT
|
| 32 |
+
|
| 33 |
# Instantiate the agent
|
| 34 |
self.agent = CodeAgent(
|
| 35 |
tools=[search_tool, wiki_search],
|
|
|
|
| 38 |
)
|
| 39 |
def __call__(self, question: str) -> str:
|
| 40 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 41 |
+
final_answer = self.agent.run(question)
|
| 42 |
+
print(f"Agent returning answer: {final_answer}")
|
| 43 |
+
return final_answer
|
| 44 |
|
| 45 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 46 |
"""
|