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
2 stars 0 forks source link

Analysis topic enforcement #118

Closed hiyaryan closed 5 months ago

hiyaryan commented 5 months ago

This PR enforces json enabled gpts to return all required analysis topics. There are three topics that form an analysis of a thought containing a cognitive distortion,

  1. A reframing or an example of what a healthy thought looks like in context
  2. A label and description of the cognitive distortion e.g. over-generalization, all-or-nothing thinking, etc.
  3. An assessment of the impact having that cognitive distortion may cause

If the thought does not contain a cognitive distortion, the gpt returns a single topic

  1. A positive affirmation or encouragement

This has been enabled through removing analyis_content from the instruction format and replaces it with reframed_thought, distortion_analysis, and impact_assessment used to form the analysis_content stored in the db on return. By concatenating these topics together, it was made possible to keep analysis_content, which is used throughout several places on the frontend and backend. So these changes only needed to occur in one spot, in the entryAnalysis model methods.

As a result of forming the analysis_content after retrieving the gpt content, json is being parsed within the entryAnalysis model methods previously parsed in the entry controllers. This required going through each of those controllers and removing the JSON parsing method.

This PR closes #93. See the discussion there for more information on how the prompt has been changed. Note that the prompt was slowly iterated over to form the current working one so not all prompt attempts have been shown there.