AntonVoronko commited on
Commit
09dca78
·
verified ·
1 Parent(s): 3993723

Prompt changes

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -8,7 +8,7 @@ import asyncio
8
  from llama_index.core import SimpleDirectoryReader
9
 
10
  from llama_index.llms.groq import Groq
11
- from llama_index.core.agent.workflow import FunctionAgent
12
 
13
  from llama_index.tools.duckduckgo import DuckDuckGoSearchToolSpec
14
  from llama_index.core.tools import FunctionTool
@@ -24,13 +24,15 @@ class BasicAgent:
24
  tool_spec = DuckDuckGoSearchToolSpec()
25
  search_tool = FunctionTool.from_defaults(tool_spec.duckduckgo_full_search)
26
  llm = Groq(model="deepseek-r1-distill-llama-70b", api_key=api_key)
27
- self.agent = FunctionAgent(tools=[search_tool], llm=llm, system_prompt='''You are a helpful assistant that has access to a seach tool to retrieve appropriate information to fulfill a task.
28
- Also, if needed, you can generate code and execute it to verify.
29
- After receiving a request from a customer identify relevant subtasks to complete before you can produce the final response.
30
- If you cannot derive information from the context provided within a request, use the search tool.
31
- Process each subtask separately and then aggregate the final response.
32
- Respond as concisely as possible.
33
- Always follow the instructions about the final response provided in a customer's request.''')
 
 
34
  print("BasicAgent initialized.")
35
  async def __call__(self, question: str) -> str:
36
  print(f"Agent received question (first 50 chars): {question[:50]}...")
 
8
  from llama_index.core import SimpleDirectoryReader
9
 
10
  from llama_index.llms.groq import Groq
11
+ from llama_index.core.agent.workflow import ReActAgent
12
 
13
  from llama_index.tools.duckduckgo import DuckDuckGoSearchToolSpec
14
  from llama_index.core.tools import FunctionTool
 
24
  tool_spec = DuckDuckGoSearchToolSpec()
25
  search_tool = FunctionTool.from_defaults(tool_spec.duckduckgo_full_search)
26
  llm = Groq(model="deepseek-r1-distill-llama-70b", api_key=api_key)
27
+ self.agent = ReActAgent(tools=[search_tool], llm=llm, system_prompt='''
28
+ You are a general AI assistant.
29
+ I will ask you a question. You can use the search tool to help you with an answer.
30
+ Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER].
31
+ YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
32
+ 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.
33
+ 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.
34
+ 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.'''
35
+ )
36
  print("BasicAgent initialized.")
37
  async def __call__(self, question: str) -> str:
38
  print(f"Agent received question (first 50 chars): {question[:50]}...")