Skip to content

Updated request/response models#1

Open
rajshekarm wants to merge 3 commits intomainfrom
feature/flash-v2
Open

Updated request/response models#1
rajshekarm wants to merge 3 commits intomainfrom
feature/flash-v2

Conversation

@rajshekarm
Copy link
Copy Markdown
Owner

@rajshekarm rajshekarm commented Feb 18, 2026

  • FillApplicationFormRequest now uses only questions (no form_fields). Added model_config = ConfigDict(extra="forbid") at models.py so legacy payload keys like form_fields are rejected. models.py

  • FillApplicationFormResponse now matches new contract: question_id

    field_id
    field_ids
    question
    answer
    confidence (float)
    sources (list of strings)
    via FilledQuestionAnswer at models.py

  • Updated endpoint handler/service logic
    router.py
    Rewrote fill_application_form to process one logical question at a time. Uses prompt, question_type, options, profile data, and job context (QuestionContext) for QA fallback. Type-specific rules implemented in _normalize_answer_for_type: single_choice at router.py
    multi_choice at router.py
    free_text default path in the same normalizer
    date at router.py (line 800) (normalized to YYYY-MM-DD) boolean at router.py (true / false)
    file at router.py (line 793) (manual upload placeholder) Optional questions:
    If insufficient context, returns low-confidence empty answer with explicit source tags like insufficient_context_optional, without failing the request. Confidence:
    Per-answer confidence preserved and clamped 0..1.
    Overall confidence is averaged at router.py

models.py (line 541)
FillApplicationFormRequest now uses only questions (no form_fields).
Added model_config = ConfigDict(extra="forbid") at models.py (line 543) so legacy payload keys like form_fields are rejected.
models.py (line 568)
FillApplicationFormResponse now matches  new contract:
question_id
field_id
field_ids
question
answer
confidence (float)
sources (list of strings)
via FilledQuestionAnswer at models.py (line 571).

Updated endpoint handler/service logic
router.py (line 599)
Rewrote fill_application_form to process one logical question at a time.
Uses prompt, question_type, options, profile data, and job context (QuestionContext) for QA fallback.
Type-specific rules implemented in _normalize_answer_for_type:
single_choice at router.py (line 805)
multi_choice at router.py (line 810)
free_text default path in the same normalizer
date at router.py (line 800) (normalized to YYYY-MM-DD)
boolean at router.py (line 795) (true / false)
file at router.py (line 793) (manual upload placeholder)
Optional questions:
If insufficient context, returns low-confidence empty answer with explicit source tags like insufficient_context_optional, without failing the request.
Confidence:
Per-answer confidence preserved and clamped 0..1.
Overall confidence is averaged at router.py (line 885).
In router.py:

Added:
from sqlalchemy.exc import IntegrityError
In /auth/register:
After db.add(user), added await db.flush() so flash_users row is inserted before token insert.
Added except IntegrityError with rollback and clearer 400 response.
In /auth/login:
Added await db.flush() before commit after adding refresh token.
Added except IntegrityError with rollback and clearer error.
Why this fixes your error
Your failure was FK violation on flash_refresh_tokens.user_id -> flash_users.id.
flush() forces SQLAlchemy to execute pending INSERTs in dependency order before commit, so the user row exists before token row validation.
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.

1 participant