Skip to content

feat: implement structured JSON schema for LLM response #26 - #30

Closed
devangpratap wants to merge 3 commits into
ruxailab:mainfrom
devangpratap:main
Closed

feat: implement structured JSON schema for LLM response #26#30
devangpratap wants to merge 3 commits into
ruxailab:mainfrom
devangpratap:main

Conversation

@devangpratap

@devangpratap devangpratap commented Mar 2, 2026

Copy link
Copy Markdown

Overview

Following the documentation and roadmap updates in #24, this PR provides the necessary technical refactor to align the LLM evaluation pipeline with modern production standards. It resolves the mismatch between the enforced response format and the internal parsing logic.

Resolved Issue


Technical Changes

1. Structured JSON Enforcement

  • Strict Schema Implementation: Replaced the generic json_object format with a dedicated json_schema using strict: True in _evaluate_with_llm().
  • Data Integrity: The schema explicitly defines a root "violations" key. Each item in the array is constrained to five required fields: criterion_id, severity (enum), description, recommendation, and affected_elements.
  • Prompt Synchronization: Adjusted the system prompt to instruct the model to wrap findings in the new object structure, ensuring 100% compatibility with the schema.

2. Code Simplification & Cleanup

  • Removal of Defensive Logic: Deleted the legacy block that manually iterated through potential keys like 'findings', 'results', or 'issues'.
  • Direct Parsing: The engine now directly loads the verified "violations" key, reducing cyclomatic complexity and eliminating "key-guessing" failures.

Critical Dependency Check

  • OpenAI SDK Requirements: This refactor utilizes json_schema strict mode, which requires OpenAI SDK v1.40.0+.
  • Current Pin: The project currently pins openai>=1.3.7.
  • Action Item: While fresh installs will pull the latest version, I recommend the maintainers consider bumping the minimum version in requirements.txt to 1.40.0 to prevent runtime errors in older environments.

Verification

  • AST parse is clean for app/services/heuristic_engine.py.
  • Python syntax verified; FastAPI service initializes correctly.

devangpratap and others added 3 commits March 2, 2026 16:06
Expanded Nielsen's Heuristics mapping from H1-H3 to H1-H10 and added detailed descriptions for H4-H10. Updated future enhancements to specify phases for implementation.
@devangpratap devangpratap changed the title Docs: Comprehensive roadmap update and heuristic alignment #24 feat: implement structured JSON schema for LLM response #26 Mar 2, 2026
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.

[Enhancement]: Align LLM response_format with expected JSON array structure in heuristic evaluation

1 participant