FunctionTool
, the output appears to be hallucinated. Thought: The user has provided his preference. I can use the select_game tool to find the appropriate game for him. Action: select_game Action Input: {"preference_description": "racing"} Observation: {"game_name": "Forza Horizon"}
select_game
will never give the above ToolOutput
.Functiontool.fn
as it's Observation
?tools = [] def select_game(preference_description: str) -> Dict[str, str]: """Use the user's description of his preference to select a game for him.""" return random.choice([{ "game_name": "Final Fantasy", "webpage": "http://ff7.game", }, { "game_name": "Call of Duty", "webpage": "http://cod.game", }]) tools.append(FunctionTool.from_defaults(fn=select_game)) agent = ReActAgent.from_tools(tools, llm=llm, verbose=True)
Action Input
and Observation
, so maybe this causes the react steps to be part of the agent response...sql_database = SQLDatabase(engine, include_tables=table_names) sql_query_engine = NLSQLTableQueryEngine(sql_database=sql_database) sql_tool = QueryEngineTool.from_defaults( query_engine=sql_query_engine, description=( "Useful for translating a natural language query into an SQL query over tables containing:" "exam_scores, containing information about student's grades in an exam. " # and descriptions of more tables... ), )
def alpha(num_unique_subjects: int) -> int: return num_unique_subjects * num_unique_subjects alpha_tool = FunctionTool.from_defaults(fn=alpha)
query_engine_tools = [sql_tool, alpha_tool] agent = OpenAIAgent.from_tools(query_engine_tools, verbose=True) agent.chat_repl()
alpha
formula passing in a hallucinated value for num_unique_subjects
.from llama_index.core.prompts import PromptTemplate from llama_index.core.prompts.system import SHAKESPEARE_WRITING_ASSISTANT from llama_index.core.agent import ReActAgent SHAKESPEARE_WRITING_ASSISTANT = PromptTemplate(SHAKESPEARE_WRITING_ASSISTANT) # just a random example agent = ReActAgent.from_tools( [], llm=llm, verbose=True, ) agent.update_prompts({"agent_worker:system_prompt": SHAKESPEARE_WRITING_ASSISTANT})
File "/home/x/anaconda3/envs/foo/lib/python3.10/site-packages/llama_index/core/prompts/mixin.py", line 75, in update_prompts raise ValueError(f"Module {module_name} not found.") ValueError: Module agent_worker not found.
FunctionTool
s named foo_tool
and bar_tool
that I want to use in a QueryPlanTool
which only accepts QueryEngineTool
s.def foo(): return "foo" def bar(): return "bar" foo_tool = FunctionTool.from_defaults(fn=foo) bar_tool = FunctionTool.from_defaults(fn=bar)
FunctionTool
to QueryEngineTool
? Or create QueryEngineTool
with the same logic as foo
and bar
?