langchain icon indicating copy to clipboard operation
langchain copied to clipboard

- Fix pass system_message argument in new feature openai_functions_agent

Open lyntcelec opened this issue 2 years ago • 1 comments

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:

lyntcelec avatar Jun 16 '23 16:06 lyntcelec

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchain ❌ Failed (Inspect) Jun 16, 2023 4:06pm

vercel[bot] avatar Jun 16 '23 16:06 vercel[bot]

can you help me review it @hwchase17

lyntcelec avatar Jun 17 '23 00:06 lyntcelec

Still can not pass a system message to model. here is my code:

llm = AzureChatOpenAI(
     deployment_name=OPENAI_DEPLOYMENT_NAME,
     model_name="gpt-3.5",
     temperature=0.0,
    
 )
python_agent = create_csv_agent(
                            llm,
                            './device_data.csv',
                            verbose=True,
                            agent_executor_kwargs={"handle_parsing_errors": True},
                             agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
                      )

tools = [Tool(
                name="PythonREPL",
                func=python_agent.run,
                description="useful for when you need to run python code in a REPL to answer questions, for example for more complex calculations or other code executions necessary to be able to answer correctly. Input should be clear python code, nothing else. You should always use a final print() statement for the final result to be able to read the outputs."
                ),]

system_message = """you are a data analyst assistant
            
            [instructions for query answering]:
            In the Action Input section, always excute the Print function.
            In the Action Input section, don't convert the result to json format.
            
            If you find no data or Empty DataFrame, do not adjust the query,don't do any other thing that the query is not asking, 
            and reply 'There is no related data to answer your query'
            """

agent = initialize_agent(
          tools,
          llm,
          agent=AgentType.OPENAI_FUNCTIONS,
          system_message=system_message,
          agent_kwargs={
             "system_message": system_message
            },
      )

It is not working. what should I modify to make it work?

leiyeah avatar Nov 20 '23 19:11 leiyeah