Langchain prompt not working as expected , it's not consistence and not able to understand examples
Labels: name: area: agent, name: auto:bug, name: area: models

### System Info

latest version of all modules 

### Who can help?


here's my PROMPT and code:




from langchain.prompts.chat import ChatPromptTemplate

updated_prompt = ChatPromptTemplate.from_messages(
    [
        ("system", 
         """
         You are a knowledgeable AI assistant specializing in extracting information from the 'inquiry' table in the MySQL Database. 
         Your primary task is to perform a single query on the schema of the 'inquiry' table and table and retrieve the data using SQL.

        
         When formulating SQL queries, keep the following context in mind:

         - Filter records based on exact column value matches.
         - If the user inquires about the Status of the inquiry fetch all these columns: status, name, and time values, and inform the user about these specific values.
         - Limit query results to a maximum of 3 unless the user specifies otherwise.
         - Only query necessary columns.
         - Avoid querying for non-existent columns.
         - Place the 'ORDER BY' clause after 'WHERE.'
         - Do not add a semicolon at the end of the SQL.

         If the query results in an empty set, respond with "information not found"

         Use this format:

         Question: The user's query
         Thought: Your thought process
         Action: SQL Query
         Action Input: SQL query
         Observation: Query results
         ... (repeat for multiple queries)
         Thought: Summarize what you've learned
         Final Answer: Provide the final answer

         Begin!
         """),
        ("user", "{question}\n ai: "),
    ]
)


llm = ChatOpenAI(model=os.getenv("OPENAI_CHAT_MODEL"), temperature=0)  # best result
sql_toolkit = SQLDatabaseToolkit(db=db, llm=llm)
sql_toolkit.get_tools()

sqldb_agent = create_sql_agent(
    llm=llm,
    toolkit=sql_toolkit,
    agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
    verbose=True,
    handle_parsing_errors=True,
)

sqldb_agent.run(updated_prompt.format(
        question="What is the status of inquiry 123?"
  ))


### Information

- [ ] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction


here's my PROMPT and code:




from langchain.prompts.chat import ChatPromptTemplate

updated_prompt = ChatPromptTemplate.from_messages(
    [
        ("system", 
         """
         You are a knowledgeable AI assistant specializing in extracting information from the 'inquiry' table in the MySQL Database. 
         Your primary task is to perform a single query on the schema of the 'inquiry' table and table and retrieve the data using SQL.

        
         When formulating SQL queries, keep the following context in mind:

         - Filter records based on exact column value matches.
         - If the user inquires about the Status of the inquiry fetch all these columns: status, name, and time values, and inform the user about these specific values.
         - Limit query results to a maximum of 3 unless the user specifies otherwise.
         - Only query necessary columns.
         - Avoid querying for non-existent columns.
         - Place the 'ORDER BY' clause after 'WHERE.'
         - Do not add a semicolon at the end of the SQL.

         If the query results in an empty set, respond with "information not found"

         Use this format:

         Question: The user's query
         Thought: Your thought process
         Action: SQL Query
         Action Input: SQL query
         Observation: Query results
         ... (repeat for multiple queries)
         Thought: Summarize what you've learned
         Final Answer: Provide the final answer

         Begin!
         """),
        ("user", "{question}\n ai: "),
    ]
)


llm = ChatOpenAI(model=os.getenv("OPENAI_CHAT_MODEL"), temperature=0) 


sql_toolkit = SQLDatabaseToolkit(db=db, llm=llm)
sql_toolkit.get_tools()

sqldb_agent = create_sql_agent(
    llm=llm,
    toolkit=sql_toolkit,
    agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
    verbose=True,
    handle_parsing_errors=True,
)

sqldb_agent.run(updated_prompt.format(
        question="What is the status of inquiry 123?"
  ))


### Expected behavior

t should be comprehensible and generate succinct results