How to stop openAI api from error when "" marks are in the JSON action

I have a chatbot and it works fine as long as “” marks are never involved in a question or response. I’ve tried formatting JSON safe, and breaks the chat bot. Screen shots of my workflow are attached. If the chatgpt returns any answer with “” marks in it (which happens frequently" the bot breaks because it can’t get past the “” marks. Does anyone know a way I can fix this?



Format as json safe always adds a quotation mark to the beginning and the end of the string. Just remove those and you should be good.

oh great, thanks @justin.hume that solved the problem when the response contained “” marks. I still can’t ask a question with “” marks if format for JSON is added. Will you look at this screenshot and see if you can tell why? If I don’t add format for JSON this works.

@iamjoshgreen

When you add formatted as JSON safe two things happen.

  1. Quotes are added to the beginning and end of the text as @justin.hume kindly indicated
  2. Inside the text additional corrections are made in case non-JSON characters are added like … quotation marks :sweat_smile:

When you combine hardcoded text along dynamic text with the JSON-safe operator you are adding these beginning and ending quotations to the second value pair in the above JSON. This is why things do not work.

In the example above when the GPT role is user why enter a combined hardcoded and dynamic string? … Just make it dynamic along with the :formatted as JSON-safe operator and you should be good to go.

Makes sense. To make it dynamic, would I do that in the API connector?

Here’s a screenshot of my api connector settings.

@cmarchan I tried to create a custom state with the prompt and set it to JSON safe and then followed that with the input and that doesn’t work either. I’m stuck. Any help would be sooooo appreciated.

@iamjoshgreen

What does one get if one adds quotation marks … twice? :wink:

@cmarchan I guess nothing, but I’m out of ideas.

@iamjoshgreen

1 Like

Actually you encoded as json safe the content twice. Use arbitrary text:encoded as json safe. In arbitrary text , setindex’s infoassitantprompt chat input value. Don’t encode them as json safe

2 Likes

@Jici Thanks for trying to help. It still doesn’t work. Here’s what the workflow looks like


Any ideas?

I somehow need one command with the whole prompt and it needs to be JSON safe. Any idea how to do that?

@iamjoshgreen

This is what @Jici kindly indicated:

CleanShot 2023-05-12 at 19.10.26
CleanShot 2023-05-12 at 19.10.34

Hope this helps!

1 Like

I tried arbitrary text but it didn’t work either. here’s what it looks like.


I really really appreciate the help, is there anyone that can tell me what I’m doing wrong?

I tried without the “” marks too and that doesn’t work either.

@iamjoshgreen

3 Likes

@cmarchan = hero. THANKS!

1 Like

@iamjoshgreen

Thank you but the real hero on this one is @Jici :smiley:

Glad to hear that things worked out!

2 Likes

This was sooo helpful! thanks a lot!!

This topic was automatically closed after 70 days. New replies are no longer allowed.