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

Error with Agent Component with JSON as input #5413

Open
drpriceless opened this issue Dec 23, 2024 · 1 comment
Open

Error with Agent Component with JSON as input #5413

drpriceless opened this issue Dec 23, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@drpriceless
Copy link

drpriceless commented Dec 23, 2024

Bug Description

I am having trouble with a simple flow in the playground and the issues appears to be related to the AGENT component and trying to get a JSON object into the user prompt.

If I create a simple flow with a PROMPT and Chat Input going into the OPENAI component and out to a Chat Output, I can paste in a JSON object into the user chat and get an expected output from the model.

However, if I replace the OpenAI component with an AGENT component (using the gpt-4o as the model), and do the same thing... I get an error in the Agent component

ERROR MESSAGE:

An error occured in the Agent Component, stopping your flow. See below for more details.
Error details:
KeyError
Details: Input to ChatPromptTemplate is missing variables {'\n "PtName"'}. Expected: ['\n "PtName"'] Received: ['input', 'chat_history', 'intermediate_steps', 'agent_scratchpad'] Note: if you intended { "PtName"} to be part of the string and not a variable, please escape it with double curly braces like: '{{ "PtName"}}'. For troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/INVALID_PROMPT_INPUT


If I try to escape the JSON with double curly braces that doesn't seem to help.

Interestingly if I then submit an empty user prompt after the error it works as expected.

Reproduction

Create a simple flow with input --> Agent Component --> output
Paste JSON into the user prompt in the playground
Agent Component Errors out

Expected behavior

Agent Component should accept the JSON input.

Who can help?

No response

Operating System

Datastax hosted

Langflow Version

1.1.1

Python Version

None

Screenshot

No response

Flow File

No response

@drpriceless drpriceless added the bug Something isn't working label Dec 23, 2024
Copy link

dosubot bot commented Dec 23, 2024

Hey @drpriceless! I'm here to help you with any bugs, questions, or contributions. Let's tackle this issue together!

The error you're encountering with the Agent Component when using JSON as input is related to the handling of variables within the ChatPromptTemplate. The error message indicates that the template is expecting a variable {"PtName"} but is not receiving it. This suggests that the JSON input is being interpreted as a variable rather than a string.

To resolve this issue, ensure that any curly braces in your JSON input are properly escaped. If {"PtName"} is intended to be part of the JSON string and not a variable, you should escape it with double curly braces like {{"PtName"}}. This tells the template to treat it as a literal string rather than a placeholder for a variable.

Additionally, verify that your prompt template is correctly set up to handle all required variables. The error message suggests that the expected variables are not being received, so double-check that your input includes all necessary variables and that they are correctly formatted.

If escaping the JSON with double curly braces doesn't help, consider reviewing the structure of your prompt template and the inputs being passed to ensure they align with the expected format. You might also want to inspect the inputs using debugging tools to ensure that all variables are correctly passed to the template.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant