Open chemistrywow31 opened 14 hours ago
Hello, @chemistrywow31! I'm here to help you with any bugs, questions, or contributions. Let's tackle this issue together!
The issue with the ReActAgent
function tools not working after calling .update_prompts()
in llama-index-core-0.11.14
appears to be a bug. The provided code indicates that the ReActAgent
does not explicitly specify prompts and would need a refactor to expose those prompts.
Supporting evidence from the code:
def _get_prompts(self) -> PromptDictType:
"""Get prompts."""
# TODO: the ReAct formatter does not explicitly specify PromptTemplate
# objects, but wrap it in this to obey the interface
sys_header = self._react_chat_formatter.system_header
return {"system_prompt": PromptTemplate(sys_header)}
This comment suggests that the current implementation does not handle prompts correctly for the ReActAgent
, which could lead to issues when calling .update_prompts()
. Additionally, the ReActAgentWorker
class relies on the ReActChatFormatter
to format prompts, but it does not explicitly manage or expose these prompts, which further supports the likelihood of a bug [1][2][3].
For a workaround, you might want to ensure that the system prompt is correctly formatted and updated. Here is how the update_prompts
method works internally:
def _update_prompts(self, prompts: PromptDictType) -> None:
"""Update prompts."""
if "system_prompt" in prompts:
sys_prompt = cast(PromptTemplate, prompts["system_prompt"])
self._react_chat_formatter.system_header = sys_prompt.template
This method checks if the prompts
dictionary contains a key "system_prompt"
. If it does, it casts the corresponding value to a PromptTemplate
and updates the system_header
attribute of the ReActChatFormatter
with the template
attribute of the PromptTemplate
[4].
Additionally, there are specific examples in the codebase that demonstrate the correct usage of update_prompts
with ReActAgent
. You can refer to the ReAct Agent notebook which showcases the ReAct agent over simple calculator tools. This notebook includes setting up tools, running queries, and customizing prompts [5].
For more advanced usage, you can refer to the Agent Runner with HyDE for PDFs notebook [6].
To continue talking to Dosu, mention @dosu.
Bug Description
The agent function tools are not working after calling .update_prompts().
Is this an error in my usage, or is it a bug?
Thank you in advance for your response.
Version
llama-index-core-0.11.14
Steps to Reproduce
Relevant Logs/Tracbacks