Skip to content

Declaring and Open AI Functions Agent with memory and system message #11417

Closed Answered by dosubot bot
rlnasuti asked this question in Q&A
Discussion options

You must be logged in to vote

🤖

Hello,

Based on the information you provided and the context from the LangChain repository, it seems you want to instantiate an OpenAI Functions Agent with both memory and a custom system message.

To achieve this, you can include the system message in the agent_kwargs when initializing the agent. Here's how you can do it:

system_message = SystemMessage(content="You are Jelly.")

agent_kwargs = {
    "extra_prompt_messages": [MessagesPlaceholder(variable_name="memory")],
    "system_message": system_message,
}

open_ai_agent = initialize_agent(
    tools,
    llm,
    agent=AgentType.OPENAI_FUNCTIONS,
    verbose=True,
    agent_kwargs=agent_kwargs,
    memory=memory,
)

This solution was…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@haesleinhuepf
Comment options

Answer selected by rlnasuti
Comment options

You must be logged in to vote
2 replies
@rlnasuti
Comment options

@dosubot
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants