Skip to content

Add Clairic extraction and Pydantic structured agents (v0.4.3) - #91

Merged
CollierKing merged 5 commits into
mainfrom
feat/clef-omni
Oct 21, 2026
Merged

CollierKing merged 5 commits into
mainfrom
feat/clef-omni

Conversation

@CollierKing

@CollierKing CollierKing commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Add Clairic extraction and Pydantic structured output for native Workers AI models, including direct LangChain agent use, and prepare version 0.4.3.

  1. Add CloudflareWorkersAIExtractionModel for native text/image extraction through sync/async REST and Python Worker AI bindings. Preserve native values, spans, confidence, truncation, and usage through the shared native transport.
  2. Both Clairic and Clef support with_structured_output(MySchema) and direct create_agent(model=native_model, tools=[], response_format=MySchema). Mixed schemas configure an explicit companion model; both receive the original input with predefined schema-derived fields/questions. Clef does not automatically validate Clairic's extracted values. Agents return the original Pydantic type in structured_response. Automatic, provider-format, and single-schema tool-format strategies support text/images, sync/async calls, and batches.
  3. Reuse the same native schema compiler and model operations for both interfaces. Fixed nested models, aliases, constraints, validators, optional decisions, and native evidence are supported. Unsupported schema shapes and executable application tools are rejected before inference. System instructions and structured-output validation feedback stay separate from source facts.
  4. Fix list-span association in the combined example and shared test assertions: group occurrence spans by their exact source substrings, permit multiple spans per unique value, and reject unsupported spans or unanchored values. Add a deterministic 3-value/8-span regression and malformed-evidence checks. Candidate qualification explicitly follows Clairic extracts candidates → build questions about those candidates → Clef evaluates. Native transport is unchanged.
  5. Update the extraction notebook, README, Worker examples, and changelog. Include LangChain in the test/notebook environments so agent tests execute. Production dependencies and the existing Worker runtime remain unchanged. Version/lock metadata is 0.4.3; dependency PRs chore(deps): bump langgraph-sdk from 0.4.2 to 0.4.4 in /libs/langgraph-checkpoint-cloudflare-d1 #87–chore(deps): bump multidict from 6.7.0 to 6.9.1 in /libs/langmem-cloudflare-vectorize #89 were merged first and this branch was rebased onto their merged result.

Validation:

  1. 477 unit tests passed, 2 skipped locally on Python 3.11 and in CI on Python 3.10/3.12, including 14 new example/evidence regression cases. These use controlled native binding responses, not live model inference. Ruff, formatting, mypy, pre-commit, diff checks, and wheel/source builds passed.

  2. Direct create_agent live tests: all 12 REST and 8 Python Worker cases passed, checking the actual Pydantic structured_response type and exact values. Coverage includes extraction-only, decisions, mixed schemas, explicit strategies, both image message encodings, batch, and abatch. REST uses LangChain 1.4.6/core 1.6.12; Workers retain the existing LangChain 1.0/core 1.1 stack.

  3. Model-level structured-output live tests passed 6 REST and 3 Worker cases. Earlier native vision coverage passed 4 REST and 4 Worker tests using the existing chat vision PNG. The explicit combined announcement example passed 2 REST and 2 Worker cases.

  4. The notebook's extraction, vision, combined, model-level Pydantic, and direct agent examples were executed with exact result assertions. Saved outputs are cleared. No generative-model fallback or output repair is used.

  5. Current-head CI passed Python 3.10/3.12 unit tests and lint, pre-commit, build selection, dependency security check, Semgrep, and CI Success.

  6. CI's non-blocking integration step lacks Cloudflare credentials and reports setup failures/errors; it is not successful live-integration evidence. The live REST/Worker results above are from prior validation. No live inference was repeated for this focused example/documentation update.

Two standalone Clairic fixtures remain expected failures: company-list extraction includes extra mentions, and full-sentence extraction returns a partial answer. The explicit combined Clairic/Clef example passes the announcement fixtures through REST and Python Workers. HTTP errors, malformed responses, and invalid spans still fail normally.

@CollierKing CollierKing changed the title Add Clairic extraction support and prepare v0.4.3 Add Clairic extraction and native Pydantic structured output (v0.4.3) Oct 20, 2026
@CollierKing CollierKing changed the title Add Clairic extraction and native Pydantic structured output (v0.4.3) Add Clairic extraction and Pydantic structured agents (v0.4.3) Oct 20, 2026
@CollierKing
CollierKing merged commit b3ada29 into main Oct 21, 2026
9 checks passed
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