Martin Bär commited on
Commit
2fa94b3
·
1 Parent(s): 82d14b3

Update sys prompt and requirements

Browse files
Files changed (2) hide show
  1. basic_agent.py +14 -8
  2. requirements.txt +1 -0
basic_agent.py CHANGED
@@ -9,7 +9,7 @@ from llama_index.readers.web import SimpleWebPageReader
9
  from llama_index.core.tools.ondemand_loader_tool import OnDemandLoaderTool
10
  from langfuse.llama_index import LlamaIndexInstrumentor
11
  from llama_index.llms.ollama import Ollama
12
- from llama_index.core.agent.workflow import ReActAgent
13
 
14
  class BasicAgent:
15
  def __init__(self, ollama=False, langfuse=True):
@@ -48,15 +48,21 @@ class BasicAgent:
48
  description="A tool for loading the content of a webpage and querying it for information",
49
  )
50
 
51
- # Create Alfred with all the tools
52
- self.agent = AgentWorkflow.from_tools_or_functions( # ReActAgent(
53
- wiki_spec.to_tool_list() + [search_tool], # webpage_tool does not work properly - cookies etc
54
  llm=llm,
55
  verbose=True,
56
  system_prompt = (
57
- "You are a helpful assistant that can search the web and wikipedia for information.\n"
58
- "Only output the shortest possible answer to the question. "
59
- "Avoid additional information or explanations."
 
 
 
 
 
 
 
60
  )
61
  )
62
 
@@ -68,4 +74,4 @@ class BasicAgent:
68
  if self.langfuse:
69
  self.instrumentor.flush()
70
 
71
- return response.response.content.strip()
 
9
  from llama_index.core.tools.ondemand_loader_tool import OnDemandLoaderTool
10
  from langfuse.llama_index import LlamaIndexInstrumentor
11
  from llama_index.llms.ollama import Ollama
12
+ from llama_index.core.agent.workflow import ReActAgent, FunctionAgent
13
 
14
  class BasicAgent:
15
  def __init__(self, ollama=False, langfuse=True):
 
48
  description="A tool for loading the content of a webpage and querying it for information",
49
  )
50
 
51
+ self.agent = AgentWorkflow.from_tools_or_functions( # ReActAgent(
52
+ tools=[search_tool], # webpage_tool does not work properly - cookies etc
 
53
  llm=llm,
54
  verbose=True,
55
  system_prompt = (
56
+ "You are a general AI assistant. I will ask you a question. "
57
+ "Report your thoughts, and finish your answer with the following template: "
58
+ "FINAL ANSWER: [YOUR FINAL ANSWER]. YOUR FINAL ANSWER should be a number "
59
+ "OR as few words as possible OR a comma separated list of numbers and/or "
60
+ "strings. If you are asked for a number, don't use comma to write your "
61
+ "number neither use units such as $ or percent sign unless specified otherwise. "
62
+ "If you are asked for a string, don't use articles, neither abbreviations (e.g. "
63
+ "for cities), and write the digits in plain text unless specified otherwise. If "
64
+ "you are asked for a comma separated list, apply the above rules depending of "
65
+ "whether the element to be put in the list is a number or a string."
66
  )
67
  )
68
 
 
74
  if self.langfuse:
75
  self.instrumentor.flush()
76
 
77
+ return response.response.content.replace("FINAL ANSWER:", "").strip()
requirements.txt CHANGED
@@ -6,4 +6,5 @@ llama_index-tools-duckduckgo
6
  llama_index-tools-wikipedia
7
  llama-index-embeddings-huggingface
8
  llama-index-readers-web
 
9
  langfuse
 
6
  llama_index-tools-wikipedia
7
  llama-index-embeddings-huggingface
8
  llama-index-readers-web
9
+ llama-index-llms-ollama
10
  langfuse