Skip to content

Add output contract adaptation for v0.2.2 - #11

Merged
HuRuilizhen merged 4 commits into
mainfrom
feat/0.2.2-output-contracts
Apr 13, 2026
Merged

Add output contract adaptation for v0.2.2#11
HuRuilizhen merged 4 commits into
mainfrom
feat/0.2.2-output-contracts

Conversation

@HuRuilizhen

Copy link
Copy Markdown
Owner

Summary

This PR is the second v0.2.2 slice for strengthening the LLM concept-extraction path.

The main goal is to make output shaping an explicit part of the provider contract so that llm extraction can adapt across stronger and weaker response-format capabilities without changing the downstream ConceptMention contract.

Included

  • adds explicit LLM output-contract modes

    • introduces auto, json_schema, json_object, and prompt_only
    • includes the selected output-contract mode in cache keys
    • keeps auto as the default behavior
  • adapts provider requests across contract modes

    • tries json_schema first in auto mode when a schema is available
    • falls back to json_object, then to prompt-only requests
    • also falls back when stronger contract modes return empty provider content
  • hardens extractor parsing across weaker contract modes

    • accepts fenced JSON blocks
    • can recover the last valid {"paragraphs": ...} object from free-form text
    • preserves the same downstream paragraph-aligned concept parsing contract
  • adds focused contract-mode coverage

    • provider tests cover explicit json_object and prompt_only modes
    • provider tests cover weaker-contract fallback after structured-output rejection
    • provider tests cover weaker-contract fallback after empty content
    • extractor tests cover fenced JSON and free-form reasoning text recovery

Validation

Repository checks:

  • ruff check .
  • pyright
  • pytest -q

Observed local-model check:

  • validated the contract fallback path against a local Ollama service
  • the current qwen3.5:4b model still does not reliably emit a usable JSON answer for the bundled example prompt, so this PR improves the compatibility layer but does not claim full local-model prompt stability yet

Notes

  • this PR intentionally focuses on output-contract adaptation and parser resilience; broader benchmark work remains the next 0.2.2 slice
  • local-only planning documents under docs/, along with local experiment material, remain intentionally untracked and are not part of this branch

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 75e54fc875

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/labelgen/extraction/llm_provider.py
@HuRuilizhen
HuRuilizhen merged commit 9f572d2 into main Apr 13, 2026
1 check passed
@HuRuilizhen
HuRuilizhen deleted the feat/0.2.2-output-contracts branch April 13, 2026 13:39
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