How to adjust the output format when using the structured chat agent from langchain

45 views Asked by At

I am using a structured chat agent with an openai model to work with my SQL database, querying data using the sql database query tool found in the SQLDatabaseToolKit.

I am setting the verbose to true to check how the agent processes the query and outputs the data.

The problem is that the agent is not displaying the “Observation” and is just spitting out the raw data. It also sometimes cuts off the “Question” and “Thought”. I am indicating the format instructions in the prompt but it doesn’t seem to follow them.

What can I do?

I want the data to be formatted in this way:

Question:
Thought:
Action:
Action Input:
Observation: data retrieved from the query
Thought:
Final Answer:

rather than

Entering new AgentExecutor chain... Action:

{
  "action": "tavily_search_results_json",
  "action_input": {"query": "LangChain"}
}
```[{'url': 'https://www.ibm.com/topics/langchain', 'content': 'LangChain is essentially a library of abstractions for Python and Javascript, representing common steps and concepts  LangChain is an open source orchestration framework for the development of applications using large language models  other LangChain features, like the eponymous chains.  LangChain provides integrations for over 25 different embedding methods, as well as for over 50 different vector storesLangChain is a tool for building applications using large language models (LLMs) like chatbots and virtual agents. It simplifies the process of programming and integration with external data sources and software workflows. It supports Python and Javascript languages and supports various LLM providers, including OpenAI, Google, and IBM.'}]Action:

I tried setting the stop_sequence to False but then it invents the data rather then displaying the real queried results.

I also changed the format instructions multiple times but no significant changes were made in the agent’s output.

0

There are 0 answers