Open anantgupta129 opened 2 weeks ago
To use prompt templates with OpenAIAgent
and resolve the ValueError: Module agent_worker not found
error, follow these steps:
Define the Prompt Template:
from llama_index.core import PromptTemplate
REACT_SYSTEM_PROMPT = PromptTemplate(react_system_header_str)
Update Prompts:
Ensure that the keys used in the update_prompts
method do not contain the ":" character and are correctly prefixed by their sub-modules as "namespaces". For example, use agent:system_prompt
instead of agent_worker:system_prompt
.
agent.update_prompts({"agent:system_prompt": REACT_SYSTEM_PROMPT})
Check Available Prompts: Before updating, you can check the available prompts to ensure you are using the correct keys.
prompts = agent.get_prompts()
print(prompts)
This will help you identify the correct keys to use when updating prompts.
update_prompts
method cannot contain the ":" character [1].OpenAIAgent
may be faster than ReActAgent
due to differences in functionalities such as tool retrieval and query planning [2].By following these steps, you should be able to use prompt templates with OpenAIAgent
and avoid the ValueError
.
To continue talking to Dosu, mention @dosu.
@anantgupta129 there is no prompt template for an openai agent
It is just sending the chat history and list of tools through the openai client.
So in that sense, the only prompt is the chat history, and the schemas of tools
hey @logan-markewich follow-up questions
AzureOpenAI
is very slow as compared OpenAI
, there is about 10x delay in response generation. I have tried with both ReActAgent
& OpenAIAgent
llm = AzureOpenAI(
model=os.getenv("AOAI_COMPLETION_MODEL"),
deployment_name=os.getenv("AOAI_DEPLOYMENT_NAME_COMPLETION"),
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
azure_endpoint=os.getenv("AOAI_ENDPOINT"),
api_version=os.getenv("AOAI_API_VERSION"),
)
Question Validation
Question
How to use pormpt template in OpenAI agent
With this i also have some additional questions:
OpenAIAgent
is faster thenReActAgent