Skip to content

Migrate to Vercel AI SDK v4.2 from v3.x #495

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chatty-seas-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@srcbook/api': patch
---

Migrate to Vercel AI SDK v4.2.
3 changes: 3 additions & 0 deletions packages/api/ai/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,8 @@ export async function getModel(): Promise<LanguageModel> {
baseURL: aiBaseUrl,
});
return openaiCompatible(model);

default:
throw new Error(`Unsupported AI provider: ${aiProvider}`);
}
}
4 changes: 3 additions & 1 deletion packages/api/ai/generate.mts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ ${query}
return prompt;
};

type NoToolsGenerateTextResult = GenerateTextResult<{}>;
// this might throw a compiler error, but that's fine: it's correct in Vercel AI SDK v4.x
type NoToolsGenerateTextResult = GenerateTextResult<{}, {}>;
/*
* Given a user request, which is free form text describing their intent,
* generate a srcbook using an LLM.
Expand Down Expand Up @@ -281,6 +282,7 @@ export async function streamEditApp(
}
},
onFinish: () => {
// eslint-disable-next-line turbo/no-undeclared-env-vars
if (process.env.SRCBOOK_DISABLE_ANALYTICS !== 'true') {
logAppGeneration({
appId,
Expand Down
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@ai-sdk/openai": "catalog:",
"@ai-sdk/provider": "^1.0.1",
"@srcbook/shared": "workspace:^",
"ai": "^3.4.33",
"ai": "^4.2.0",
"archiver": "^7.0.1",
"better-sqlite3": "^11.3.0",
"cors": "^2.8.5",
Expand Down
Loading