-
Notifications
You must be signed in to change notification settings - Fork 1k
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
make ai sdk native #698
Conversation
🦋 Changeset detectedLatest commit: 35dd6c7 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
]); | ||
|
||
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.
Co-authored-by: Miguel <[email protected]>
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.
why are we deleting this file? we still need for when we wrap AI SDK for evals to get telemetry
evals/index.eval.ts
Outdated
import { groq } from "@ai-sdk/groq"; | ||
import { cerebras } from "@ai-sdk/cerebras"; | ||
import { openai } from "@ai-sdk/openai"; | ||
import { AISdkClient } from "@/lib/llm/aisdk"; |
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.
evals should only reference dist
, not lib
why
what changed
test plan