feat(llm): add structured output with chat_typed<T> and Extractor#541
Merged
feat(llm): add structured output with chat_typed<T> and Extractor#541
Conversation
f8ff289 to
b12a004
Compare
Add tests for strip_json_fences (7 cases), chat_typed default impl (5 cases: happy path, retry success, both fail, error propagation, fence stripping), Extractor (3 cases: with/without preamble, error), supports_structured_output default, and StructuredParse error display. Document strip_json_fences limitation with nested backticks (R2).
Add chat_typed_erased dispatch test via MockProvider, and supports_structured_output delegation tests for OpenAI and Ollama variants.
b12a004 to
6679d1e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
chat_typed<T>()method toLlmProvidertrait for typed structured output with JSON schema enforcement (feat(llm): add chat_typed<T> method to LlmProvider trait #456)response_format: json_schemawithstrict: true(feat(llm): OpenAI structured output via response_format #457)Extractor<T>utility wrapping provider with optional preamble for typed data extraction (feat(llm): Extractor utility for typed data extraction #459)AnyProvider::chat_typed_erased<T>()for enum dispatchCloses #456, closes #457, closes #458, closes #459
Part of Epic #474
Test plan
strip_json_fencesunit tests (7 cases)chat_typeddefault impl tests (5 cases: happy path, retry, both fail, error propagation, fence stripping)Extractortests (3 cases: basic, preamble, error propagation)AnyProvider::chat_typed_eraseddispatch testsupports_structured_outputdefault andStructuredParseerror displaycargo clippy --workspace -- -D warningscleancargo nextest run --workspace --lib --bins— 1645 passed, 9 skipped