From 1e0af59f69b280bf087e19fc28ae51f9232e6312 Mon Sep 17 00:00:00 2001 From: Ly Nguyen Date: Mon, 19 Jun 2023 07:54:00 +0700 Subject: [PATCH] - Fix pass system_message argument in new feature openai_functions_agent (#6297) can't pass system_message argument, the prompt always show default message "System: You are a helpful AI assistant." ``` system_message = SystemMessage( content="You are an AI that provides information to Human regarding documentation." ) agent = initialize_agent( tools, llm=openai_llm_chat, agent=AgentType.OPENAI_FUNCTIONS, system_message=system_message, agent_kwargs={ "system_message": system_message, }, verbose=False, ) ``` #### Who can review? Tag maintainers/contributors who might be interested: --- langchain/agents/openai_functions_agent/base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/langchain/agents/openai_functions_agent/base.py b/langchain/agents/openai_functions_agent/base.py index 4b91bbb2..b8407d49 100644 --- a/langchain/agents/openai_functions_agent/base.py +++ b/langchain/agents/openai_functions_agent/base.py @@ -236,12 +236,15 @@ class OpenAIFunctionsAgent(BaseSingleActionAgent): llm: BaseLanguageModel, tools: Sequence[BaseTool], callback_manager: Optional[BaseCallbackManager] = None, + system_message: Optional[SystemMessage] = SystemMessage( + content="You are a helpful AI assistant." + ), **kwargs: Any, ) -> BaseSingleActionAgent: """Construct an agent from an LLM and tools.""" if not isinstance(llm, ChatOpenAI): raise ValueError("Only supported with OpenAI models.") - prompt = cls.create_prompt() + prompt = cls.create_prompt(system_message=system_message) return cls( llm=llm, prompt=prompt,