Skip to content

Replace params: Any in stream/generate with generalized types#150

Merged
elprans merged 1 commit into
mainfrom
elprans/typify-inference-params
May 28, 2026
Merged

Replace params: Any in stream/generate with generalized types#150
elprans merged 1 commit into
mainfrom
elprans/typify-inference-params

Conversation

@elprans
Copy link
Copy Markdown
Collaborator

@elprans elprans commented May 22, 2026

Using params: Any for the typing of inference parameters is not great,
because discoverability and validation. Even though the variability in
upstream provider configuration shapes is great, the overlap in
common functionality is big enough to warrant ascribing it in common
types and concepts.

In addition to common parameters, add a provider-specific options
section as well as generic extra_headers/extra_query/extra_body
escape hatch to drop to untyped underlying API level.

@elprans elprans requested review from 1st1, anbuzin and msullivan May 22, 2026 16:50
@vercel
Copy link
Copy Markdown

vercel Bot commented May 22, 2026

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

Project Deployment Actions Updated (UTC)
ai-python Ready Ready Preview, Comment May 28, 2026 8:09pm

@socket-security
Copy link
Copy Markdown

socket-security Bot commented May 22, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedpypi/​anthropic@​0.83.0 ⏵ 0.103.191 -4100100100100
Updatedpypi/​openai@​2.14.0 ⏵ 2.37.096 +1100100100100

View full report

Copy link
Copy Markdown
Contributor

@msullivan msullivan left a comment

Choose a reason for hiding this comment

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

This seems more or less reasonable in terms of API surface but I do worry about keeping it up to date?

Though AI makes that a lot easier.

I wonder if there is a table driven approach we could do, though?

Comment thread examples/model_params.py
Using `params: Any` for the typing of inference parameters is not great,
because discoverability and validation.  Even though the variability in
upstream provider configuration shapes is great, the overlap in
common functionality is big enough to warrant ascribing it in common
types and concepts.

In addition to common parameters, add a provider-specific options
section as well as generic `extra_headers`/`extra_query`/`extra_body`
escape hatch to drop to untyped underlying API level.
@elprans elprans force-pushed the elprans/typify-inference-params branch from a516af0 to 824efe0 Compare May 28, 2026 20:08
@elprans elprans marked this pull request as ready for review May 28, 2026 20:15
@elprans elprans merged commit 4581295 into main May 28, 2026
7 checks passed
@elprans elprans deleted the elprans/typify-inference-params branch May 28, 2026 20:15
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