mirror of
https://github.com/hwchase17/langchain
synced 2024-11-06 03:20:49 +00:00
- 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: <!-- For a quicker response, figure out the right person to tag with @ @hwchase17 - project lead Tracing / Callbacks - @agola11 Async - @agola11 DataLoaders - @eyurtsev Models - @hwchase17 - @agola11 Agents / Tools / Toolkits - @hwchase17 VectorStores / Retrievers / Memory - @dev2049 -->
This commit is contained in:
parent
e64bafed3a
commit
1e0af59f69
@ -236,12 +236,15 @@ class OpenAIFunctionsAgent(BaseSingleActionAgent):
|
|||||||
llm: BaseLanguageModel,
|
llm: BaseLanguageModel,
|
||||||
tools: Sequence[BaseTool],
|
tools: Sequence[BaseTool],
|
||||||
callback_manager: Optional[BaseCallbackManager] = None,
|
callback_manager: Optional[BaseCallbackManager] = None,
|
||||||
|
system_message: Optional[SystemMessage] = SystemMessage(
|
||||||
|
content="You are a helpful AI assistant."
|
||||||
|
),
|
||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> BaseSingleActionAgent:
|
) -> BaseSingleActionAgent:
|
||||||
"""Construct an agent from an LLM and tools."""
|
"""Construct an agent from an LLM and tools."""
|
||||||
if not isinstance(llm, ChatOpenAI):
|
if not isinstance(llm, ChatOpenAI):
|
||||||
raise ValueError("Only supported with OpenAI models.")
|
raise ValueError("Only supported with OpenAI models.")
|
||||||
prompt = cls.create_prompt()
|
prompt = cls.create_prompt(system_message=system_message)
|
||||||
return cls(
|
return cls(
|
||||||
llm=llm,
|
llm=llm,
|
||||||
prompt=prompt,
|
prompt=prompt,
|
||||||
|
Loading…
Reference in New Issue
Block a user