AntonVoronko commited on
Commit
dbc0fe2
·
verified ·
1 Parent(s): 0b323d0

Prompt updated

Browse files
Files changed (1) hide show
  1. app.py +7 -6
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 ReActAgent
12
 
13
  from llama_index.tools.duckduckgo import DuckDuckGoSearchToolSpec
14
  from llama_index.tools.wikipedia import WikipediaToolSpec
@@ -30,9 +30,10 @@ class BasicAgent:
30
  arxiv_spec = ArxivToolSpec()
31
  arxiv_tool = FunctionTool.from_defaults(arxiv_spec.arxiv_query)
32
  llm = Groq(model="deepseek-r1-distill-llama-70b", api_key=api_key)
33
- self.agent = ReActAgent(tools=[search_tool, wiki_tool, arxiv_tool], llm=llm, system_prompt='''
34
  You are a general AI assistant.
35
  I will ask you a question. You can use the tools at your disposal to help you with an answer.
 
36
  Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER].
37
  YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
38
  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.
@@ -44,10 +45,10 @@ class BasicAgent:
44
  print(f"Agent received question (first 50 chars): {question[:50]}...")
45
  fixed_answer = await self.agent.run(question)
46
  result = fixed_answer.response.content
47
- # if "FINAL ANSWER:" in result:
48
- # result = result.split("FINAL ANSWER: ")[1]
49
- if "Answer" in result:
50
- result = result.split("Answer")[1]
51
  print(result)
52
  return result
53
 
 
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.tools.wikipedia import WikipediaToolSpec
 
30
  arxiv_spec = ArxivToolSpec()
31
  arxiv_tool = FunctionTool.from_defaults(arxiv_spec.arxiv_query)
32
  llm = Groq(model="deepseek-r1-distill-llama-70b", api_key=api_key)
33
+ self.agent = FunctionAgent(tools=[search_tool, wiki_tool, arxiv_tool], llm=llm, system_prompt='''
34
  You are a general AI assistant.
35
  I will ask you a question. You can use the tools at your disposal to help you with an answer.
36
+ After receiving a question identify relevant subtasks to complete before you can produce the final response.
37
  Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER].
38
  YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
39
  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.
 
45
  print(f"Agent received question (first 50 chars): {question[:50]}...")
46
  fixed_answer = await self.agent.run(question)
47
  result = fixed_answer.response.content
48
+ if "FINAL ANSWER:" in result:
49
+ result = result.split("FINAL ANSWER: ")[1]
50
+ # if "Answer" in result:
51
+ # result = result.split("Answer")[1]
52
  print(result)
53
  return result
54