RFC: explore sending content parts to LiteLLM instead of always sending strings to be deserialized for custom types #8280
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.
Issue: Text deserialization breaks on some escaped quotes in custom types.
When sending strings with lots of escaped quote, the ChatAdapter deserialize step can break. See below.
This happens because we try to deserialize for custom types:
dspy/dspy/adapters/types/base_type.py
Lines 68 to 86 in 6270e95
As shown above, we serialize and then deserialize content parts to support custom types like
dspy.Image
. It would be nice if there was more direct support for content parts for DSPy types.Request for comment (RFC): Passing Through a Custom Type's
format()
partsRather than serialize and deserialize, let's allow the parts to pass all the way through to LiteLLM. This would be more efficient, skip serialization issues, and allow more powerful types.
Implementation
This is a rough implementation to help drive the conversation. I'm not sure I understand the implications in other adapters or parts of the system. If we like this direction, I can clean it up.