hiyaryan / the-cdj

The Cognitive Distortion Journal (CDJ) is a smart journaling tool that helps remedy distorted thinking. It can feel impossible to follow the CBT technique of labeling distorted thinking and finding alternative modes of thought (i.e. reframing) while cognitive distortions are occurring. The CDJ does that work for you. -- The CDJ is in beta testing!!
https://thecdj.app
3 stars 0 forks source link

Completion error handling and updating entries. #24

Closed hiyaryan closed 9 months ago

hiyaryan commented 9 months ago

Add error handling to external chat and analysis completion API calls on the backend.

When a response is returned from an OpenAI completion endpoint, if the response contains an error, throw the error up to controller and attach the error to an Error property in the response header.

Once dialog (or flash) messages are integrated into the frontend, this error message should be displayed to the user along with other messages.

This PR also includes updating the analysis when a user updates an entry. Note that the chat history may need to be removed. Otherwise, a new chat log should be started and that should be added to a chat history of some sort as the messages in the chat completion will likely confuse the LLM and/or produce hallucinations.