Skip to content

feat(extraction): add IncidentReport schema and harden LLM extraction#332

Open
Fadhili5 wants to merge 1 commit intofireform-core:mainfrom
Fadhili5:feat/yaml-template-engine
Open

feat(extraction): add IncidentReport schema and harden LLM extraction#332
Fadhili5 wants to merge 1 commit intofireform-core:mainfrom
Fadhili5:feat/yaml-template-engine

Conversation

@Fadhili5
Copy link

  • Add src/schemas/incident_report.py: canonical Pydantic model covering all fields needed across Cal Fire FIRESCOPE, EMS, and law enforcement forms (identity, location, timestamps, personnel, casualties, wildfire, narrative, law enforcement sections)
  • Add model_validator that auto-populates requires_review for any core field left null after extraction, so responders can spot gaps before PDF submission
  • Add llm_schema_hint() classmethod that returns the JSON schema minus requires_review, used to build the structured Ollama system prompt
  • Refactor LLM class: replace per-field prompt loop with a single structured request using Ollama format="json" and Mistral instruction format ([INST]...[/INST])
  • LLM now returns IncidentReport via get_report() in addition to the existing get_data() dict accessor for backward compatibility
  • Fix test_submit_form: replace stub with a working integration test that creates a template then mocks Controller to assert the full POST /forms/fill response shape

- Add src/schemas/incident_report.py: canonical Pydantic model covering
  all fields needed across Cal Fire FIRESCOPE, EMS, and law enforcement
  forms (identity, location, timestamps, personnel, casualties, wildfire,
  narrative, law enforcement sections)
- Add model_validator that auto-populates requires_review for any core
  field left null after extraction, so responders can spot gaps before
  PDF submission
- Add llm_schema_hint() classmethod that returns the JSON schema minus
  requires_review, used to build the structured Ollama system prompt
- Refactor LLM class: replace per-field prompt loop with a single
  structured request using Ollama format="json" and Mistral instruction
  format ([INST]...[/INST])
- LLM now returns IncidentReport via get_report() in addition to the
  existing get_data() dict accessor for backward compatibility
- Fix test_submit_form: replace stub with a working integration test
  that creates a template then mocks Controller to assert the full
  POST /forms/fill response shape
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