-
Notifications
You must be signed in to change notification settings - Fork 625
make ai sdk native #698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
make ai sdk native #698
Conversation
🦋 Changeset detectedLatest commit: 1848be5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
I started looking into this yesterday; it seems like if we're going with aisdk we should probably change our internal inference logic to adapt to |
* avoid using model-provider map * prettier * remove duplicate dependency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR integrates the AI SDK as a first-class LLM client in Stagehand, moving from an external implementation to a native one with enhanced logging and caching capabilities.
- Added
lib/llm/aisdk.ts
implementingAISdkClient
with support for multiple AI providers (OpenAI, Google, Anthropic, Groq, Cerebras) - Modified model naming convention to use format
aisdk/provider/model
(e.g.aisdk/openai/gpt-4o
) for simplified integration - Moved AI SDK dependencies from devDependencies to optionalDependencies in
package.json
, allowing selective provider installation - Added support for provider-specific API keys in environment variables through
lib/index.ts
- Enhanced
types/model.ts
to support flexible model strings while maintaining type safety
10 file(s) reviewed, 8 comment(s)
Edit PR Review Bot Settings | Greptile
@@ -34,14 +34,15 @@ export const AvailableModelSchema = z.enum([ | |||
"gemini-2.5-pro-preview-03-25", | |||
]); | |||
|
|||
export type AvailableModel = z.infer<typeof AvailableModelSchema>; | |||
export type AvailableModel = z.infer<typeof AvailableModelSchema> | string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Adding string to AvailableModel type weakens type safety. Consider using a branded type or maintaining an explicit list of supported models to prevent runtime errors from invalid model names.
why
what changed
test plan