Make models serializable#174
Closed
anbuzin wants to merge 3 commits into
Closed
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
msullivan
reviewed
Jun 16, 2026
msullivan
left a comment
Contributor
There was a problem hiding this comment.
I left some specific comments but I (sorry) think we need to rethink the plan again.
Comment on lines
+52
to
+58
| # ``ai.Model`` is fully serializable: it stores a provider *recipe* | ||
| # (factory reference + JSON args) and only builds the provider — and | ||
| # its ``httpx.AsyncClient`` — on first use. The workflow can therefore | ||
| # construct the model with ``ai.get_model`` inside the Temporal sandbox | ||
| # (nothing network-shaped is created there) and ship it to | ||
| # ``llm_call_activity`` as plain JSON, where the provider gets built | ||
| # for real. |
Contributor
There was a problem hiding this comment.
Classic backward-looking AI comment. Probably delete?
| async def llm_call_activity(params: LLMParams) -> LLMResult: | ||
| """Call the LLM, drain the stream, return the final message.""" | ||
| model = ai.get_model(params.model_id) | ||
| model = ai.Model.model_validate(params.model) |
Contributor
There was a problem hiding this comment.
Nothing to do about it, but the overloading of model is unfortunate
| model = ai.Model( | ||
| os.environ.get("LOCAL_OPENAI_MODEL", "local-model"), | ||
| provider=provider, | ||
| provider_factory=lambda: ai.get_provider( |
Contributor
There was a problem hiding this comment.
I think provider_factory should be ai.get_provider and everything else should be the arguments? (Using dict(...))
| """Provider instance, built lazily from the factory and cached.""" | ||
| provider = self._provider_instance | ||
| if provider is None: | ||
| provider = self.provider_factory(**self.provider_args) |
Contributor
There was a problem hiding this comment.
OK, I think we should actually avoid doing a serialized function name, for security concerns.
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.
No description provided.