Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when LLM generates invalid json in agentConvo #103

Open
coconutpalms opened this issue Jul 11, 2023 · 2 comments
Open

Issue when LLM generates invalid json in agentConvo #103

coconutpalms opened this issue Jul 11, 2023 · 2 comments

Comments

@coconutpalms
Copy link

Any prompt that will get the conversational agent to make a list with newlines inside json strings will cause the error.

From logs:

LLM Response:
ellapsed: 22.495 sec.

{
    "action": "Final Answer",
    "action_input": "Here are some potential impacts of the announcement on supply and demand:

1. **Supply Disruptions**: The conflict in Ukraine could potentially disrupt oil supplies, especially if it affects regions with significant oil production or transportation infrastructure. This could reduce the overall supply of oil, leading to higher prices.

2. **Increased Demand**: The announcement could lead to increased demand for oil, especially if it leads to increased military activity that requires oil for vehicles and other equipment. This could also lead to higher prices.

3. **Speculation**: The announcement could lead to speculation in the oil markets, with traders buying up oil in anticipation of future price increases. This could increase demand in the short term, leading to higher prices.

4. **Changes in Production**: In response to the announcement, other oil-producing countries could decide to increase or decrease their own production. This could have a variety of effects on supply and demand, depending on the decisions made by these countries.

5. **Long-Term Shifts**: If the conflict in Ukraine leads to long-term instability in the region, it could potentially lead to long-term shifts in the global oil market. This could affect both supply and demand in ways that are difficult to predict."
}

Error parsing JSON SyntaxError: Bad control character in string literal in JSON at position 126
at JSON.parse ()
at parseResult (webpack-internal:///(api)/./agent/agentConvo.ts:156:23)
at executeReactAgent (webpack-internal:///(api)/./agent/agentConvo.ts:134:20)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async handler (webpack-internal:///(api)/./pages/api/planningconv.ts:40:24)
Error: Error parsing JSON
at parseResult (webpack-internal:///(api)/./agent/agentConvo.ts:160:15)
at executeReactAgent (webpack-internal:///(api)/./agent/agentConvo.ts:134:20)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async handler (webpack-internal:///(api)/./pages/api/planningconv.ts:40:24)

@coconutpalms
Copy link
Author

To reproduce the error - Start a conversation in "chat" mode with a custom prompt, and ask a question or two. Then, select "conversational agent" mode using the button on the left of the text input, and give any prompt that will generate multiple lines of output in the json.

I have created a gist with the logs and chat history to reproduce the issue

@nic-foma
Copy link

Also experiencing this very frequently for Google and Wikipedia plugins.
Example below (note I've escaped the backticks that are from the log)

USER'S INPUT
--------------------

Okay, so what is the response to my original question? If using information from tools, you must say it explicitly - I have forgotten all TOOL RESPONSES! Remember to respond with a markdown code snippet of a json blob with a single action, and NOTHING else.
LLM Response:
ellapsed: 20.945 sec.
\```json
{
    "action": "Final Answer",
    "action_input": "Knowledge Graphs are a powerful tool for organizing and interpreting complex sets of data. They capture entities and their relationships, providing a structured representation of data that can be used for many downstream applications. The data in a Knowledge Graph is organized as a graph, which allows for flexibility and ease of querying. The meaning of the data is provided in the form of an ontology, which accompanies the data and makes it easier to understand and interpret. 

In addition to providing a structured representation of data, Knowledge Graphs also facilitate inference. This means that they can be used to derive implicit information from the explicit data that they contain. This is achieved through the use of various graph-computing techniques, which can analyze the structure of the graph and the relationships between entities to draw conclusions and make predictions.

In summary, Knowledge Graphs are a powerful tool for data organization and interpretation. They provide a structured representation of data, facilitate easy querying, and enable inference of implicit information. Their use spans many applications, from improving search engine results to enabling advanced research in fields like artificial intelligence and bioinformatics."
}
\```

Error parsing JSON SyntaxError: Bad control character in string literal in JSON at position 534
    at JSON.parse (<anonymous>)
    at parseResult (/app/.next/server/pages/api/planningconv.js:309:23)
    at executeReactAgent (/app/.next/server/pages/api/planningconv.js:294:20)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async handler (/app/.next/server/pages/api/planningconv.js:459:24)
Error: Error parsing JSON
    at parseResult (/app/.next/server/pages/api/planningconv.js:312:15)
    at executeReactAgent (/app/.next/server/pages/api/planningconv.js:294:20)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async handler (/app/.next/server/pages/api/planningconv.js:459:24)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants