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

refactor(chat_open_ai): Harden do_process_response #21

Merged

Conversation

Cardosaum
Copy link
Contributor

This should fix #20.

@brainlid
Copy link
Owner

Nice! Good catch too. I haven't encountered that one yet, but I knew it was a possibility.

Can you change the returned message of "Failed to parse response from API" to something more like: "Received invalid JSON"?

The reason is, when we get bad JSON in a function call from the ChatGPT, we can just return the following example text to as the function response to ChatGPT.

"ERROR: Received invalid JSON"

Then ChatGPT will may try again with better formatted JSON. Optionally, we could include more of the error message so ChatGPT has a better chance of fixing the problem.

@Cardosaum
Copy link
Contributor Author

Oh, I see... Thanks for the additional context!

I have updated the error message as per your suggestion. Now it reads "Received invalid JSON: %Jason.DecodeError{...}".

Is there any other improvement or change you'd like to have implemented?

Copy link
Owner

@brainlid brainlid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! That looks good! I expect we may tweak the error message/handling more in the future when we test it more directly against ChatGPT.

Thanks!

@brainlid brainlid merged commit 0705b57 into brainlid:main Oct 20, 2023
@brainlid
Copy link
Owner

❤️💛💙💜

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

Successfully merging this pull request may close these issues.

do_process_response does not contain handling for all inputs.
2 participants