Find answers from the community

Updated 2 months ago

hello guys, i have a problem acccessing

hello guys, i have a problem acccessing agents prompts and changing them
Attachment
image.png
L
a
26 comments
you probably dont want to mess around too much with the react prompt
instead, you can add some context to it
ReActAgent.from_tools(..., context="Some extra context")
if you really want to change the react prompt, it looks like you are on the right track, it will be somewhere in that dict
all i wanna do is change the system prompt from it being so vague like that ,give it more personality and instructions
Attachment
image.png
ill try that context arg thank you
the thing for agents , that dict almost like hidden or private , theyre not accessible as u can see
yea if you follow the guide, theres an update_prompts method

i.e.
Plain Text
 query_engine.update_prompts(
    {"response_synthesizer:summary_template": new_summary_tmpl}
)
that one doesnt work for agents
worked for query engines and not the agents
works fine for me
>>> from llama_index.core.agent import ReActAgent
>>> agent = ReActAgent.from_tools([])

>>> agent.get_prompts()
{'agent_worker:system_prompt': PromptTemplate(metadata={'prompt_type': <PromptType.CUSTOM: 'custom'>}, template_vars=['tool_desc', 'tool_names'], kwargs={}, output_parser=None, template_var_mappings=None, function_mappings=None, template='You are designed to help with a variety of tasks, from answering questions to providing summaries to other types of analyses.\n\n## Tools\n\nYou have access to a wide variety of tools. You are re .... l you have enough information to answer the question without using any more tools. At that point, you MUST respond in the one of the following two formats:\n\n
Plain Text
\nThought: I can answer without using any more tools. I\'ll use the user\'s language to answer\nAnswer: [your answer here (In the same language as the user\'s question)]\n
\n\n
Plain Text
\nThought: I cannot answer the question with the provided tools.\nAnswer: [your answer here (In the same language as the user\'s question)]\n
\n\n## Current Conversation\n\nBelow is the current conversation consisting of interleaving human and assistant messages.\n')}

>>> prompt = agent.get_prompts()['agent_worker:system_prompt']
>>> agent.update_prompts({'agent_worker:system_prompt': prompt})
>>>
(truncated the pormpt in the middle so that it would send on discord)
i just tried it man
the context arg did the job tho , it worked
tho it wont be as efficient
since system prompt more influential
a missing lib right ?
response_synthesizer was just an example -- if you look above at my second example, I used the proper key
agent_worker:system_prompt
youd have to take the giant existing prompt, and modify it to what you need
(fyi the context is getting inserted into the existing system prompt, so its already in the system prompt actually)
Add a reply
Sign up and join the conversation on Discord