feat(types): bridge normalized LM outputs - #63
Draft
isaacbmiller wants to merge 1 commit into
Draft
Conversation
isaacbmiller
force-pushed
the
reviewable/adapter-simplify-01-type-bridges
branch
from
May 27, 2026 05:28
1d4c395 to
188e60a
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
This is PR 1 of 2 in the adapter simplification stack.
It adds the type-side bridge that lets adapter parsing consume normalized
LMOutputvalues without requiring the LM/client boundary changes from the earlier version of this work.Key changes:
Type.parse_lm_output(output)as the normalized output hook, with a default bridge back to existingparse_lm_response(...)implementations.ReasoningandCitationsto parse directly from normalizedLMOutputparts.Citations.Citationmodel.LMRequest.from_call(...)to accept existing OpenAI-shaped message dictionaries as message items in direct-call paths.Why This Is Separate
The next PR simplifies
dspy/adapters/base.pyto parseLMResponsedirectly. That only makes sense if native response types can already read normalizedLMOutputvalues. This PR creates that type contract first, while keeping the existing legacy type methods in place.Review Notes
The important invariant is that this is a bridge, not a public LM boundary change. It should not require changes to
dspy.LM,BaseLM, or provider clients.History has two surfaces here:
dspy.Historyinputs are still signature-shaped adapter records and are rendered by adapters before the LM request is built.LMParts back into the legacy display shape.Validation
uv run --frozen ruff check dspy/adapters/types/base_type.py dspy/adapters/types/citation.py dspy/adapters/types/reasoning.py dspy/core/types.pyuv run --frozen pytest --deno -q tests/core/test_types.py tests/streaming/test_streaming.py::test_streaming_allows_custom_streamable_type21 passed, 14 warningsTop of stack validation is in PR 2.