Skip to content

Enhancement: Format AI Q&A Response Using Structured Output Parser #7

@biswajit-debnath

Description

@biswajit-debnath

The askQuestion function in the AI utility returns unformatted responses that include extra AI-generated context and formatting. Unlike the analyze function which uses StructuredOutputParser to ensure clean, predictable output, the Q&A responses come with additional text from the AI model that makes the output inconsistent and less user-friendly.

📸 Current Behavior

  • Q&A responses include extra AI commentary and formatting
  • Responses are not structured or predictable
  • Raw AI output may contain unnecessary context or explanations
  • Inconsistent response format compared to the analysis feature

✅ Expected Behavior

  1. Structured Output: Use StructuredOutputParser with Zod schema for consistent formatting
  2. Clean Responses: Remove extra AI commentary and return only the relevant answer
  3. Consistent Format: Match the implementation pattern used in the analyze function
  4. Predictable Structure: Define a clear schema for Q&A responses

🔧 Technical Details
File to modify: [ai.ts]

Testing on Deployed Version

To test this issue on the live deployment, check the CONTRIBUTING.md file for:

  • 🔗 Deployed application URL
  • 🧪 Test account credentials with pre-filled journal entries
  • ⚠️ OpenAI API rate limiting information (15 calls per user)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions