Repository navigation
Conversation
Accept `FilePart`s anywhere in decision state and in question
`instructions` and `criteria`, alongside text and JSON, e.g.
`{"photo": ai.file_part(data), "note": "..."}`. `DecisionInput` is now
text, a file, or JSON with files at any depth. It validates like
`pydantic.JsonValue`: an invalid value gives one error at its path. A
plain `str` is always text, and a dict shaped like a file stays JSON.
The TypeSafe protocol turns each file part into an SDK `Image`, which
the SDK sends as an asset with a reference in its place, and sends the
image opt-in header. URLs are downloaded, a repeated file part is sent
once, and files that are not images are rejected. AI Gateway v4 has no
wire format for files in decision requests yet, so it rejects them
before it sends the request.
The TypeSafe example puts images inside structured state and in a score criterion. The OpenAI example puts them where the OpenAI Decisions API accepts them: in a list of text and file parts as state, and in one question's instructions. The OpenAI example raises `NotImplementedError` until the OpenAI decisions protocol lands. TypeSafe is not on models.dev yet, so its example builds the model with `TypeSafeProvider()`.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Statically type DecisionInput with covariant Sequence and Mapping so a typed list or dict such as list[str | int] is accepted without a cast. Validation still stores every sequence as a list and every mapping as a dict, so providers keep walking plain JSON shapes. Binary data is still rejected rather than read as a list of ints.
msullivan
reviewed
Nov 3, 2026
Comment on lines
+127
to
+133
| type DecisionInput = Annotated[ | ||
| Annotated[str, pydantic.Tag("str")] | ||
| | Annotated[messages.FilePart, pydantic.Tag("FilePart")] | ||
| | Annotated[dict[str, _DecisionValue], _AS_DICT, pydantic.Tag("dict")] | ||
| | Annotated[list[_DecisionValue], _AS_LIST, pydantic.Tag("list")], | ||
| _INPUT_DISCRIMINATOR, | ||
| ] |
Collaborator
There was a problem hiding this comment.
Hmmmm: will serializing something with a FilePart and then deserializing it back have any way to preserve the file part? Probably not, right?
But I guess that's kind of inevitable without more of a schema for it...
msullivan
approved these changes
Nov 5, 2026
msullivan
left a comment
Collaborator
There was a problem hiding this comment.
I'm still a little unsure about the image embedding situation but don't have a better plan yet
This branch was successfully deployed
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.
Decision models are now multimodal, and so we're adding support for that.
We can no longer use
pydantic.JsonValuefor typing, so we're replacing it with roughly the same thing plusFilePart.