Skip to content

Make models serializable#174

Closed
anbuzin wants to merge 3 commits into
mainfrom
make-models-serializable
Closed

Make models serializable#174
anbuzin wants to merge 3 commits into
mainfrom
make-models-serializable

Conversation

@anbuzin

@anbuzin anbuzin commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ai-python Ready Ready Preview, Comment Jun 16, 2026 10:35pm

@msullivan msullivan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing to do about it, but the overloading of model is unfortunate

Comment thread examples/explicit_client.py Outdated
model = ai.Model(
os.environ.get("LOCAL_OPENAI_MODEL", "local-model"),
provider=provider,
provider_factory=lambda: ai.get_provider(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think provider_factory should be ai.get_provider and everything else should be the arguments? (Using dict(...))

Comment thread src/ai/models/core/model.py Outdated
"""Provider instance, built lazily from the factory and cached."""
provider = self._provider_instance
if provider is None:
provider = self.provider_factory(**self.provider_args)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I think we should actually avoid doing a serialized function name, for security concerns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants