Find answers from the community

Updated 2 months ago

how do i add a system prompt to an instance of ReactAgentWorker

how do i add a system prompt to an instance of ReactAgentWorker
k
2 comments
Please stand by @tomi as I search the knowledge base. I normally take about 20 seconds or so. :wave:
----------------------
To add a system prompt to an instance of ReActAgentWorker, you can follow these steps:

  1. First, you need to create a PromptTemplate with your desired system prompt string. The PromptTemplate class is part of the llama_index.core module. Here is an example of how to create a PromptTemplate:
Plain Text
from llama_index.core import PromptTemplate
react_system_header_str = "Your desired system prompt here"
react_system_prompt = PromptTemplate(react_system_header_str)

Source ()

  1. Once you have your PromptTemplate, you can use the update_prompts method of the ReActAgentWorker instance to add your system prompt. Here is an example:
Plain Text
agent.update_prompts({"agent_worker:system_prompt": react_system_prompt})

Source ()

Please note that the update_prompts method updates the prompts of the ReActAgentWorker instance. If you want to check the current prompts, you can use the get_prompts method:

Plain Text
agent.get_prompts()

Source ()

Remember to replace agent with your instance of ReActAgentWorker.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Add a reply
Sign up and join the conversation on Discord