Skip to content

Commit 68120b0

Browse files
committed
Migrate to Vercel AI SDK v4.2 from v3.x
1 parent 0ba24b1 commit 68120b0

5 files changed

Lines changed: 69 additions & 143 deletions

File tree

.changeset/chatty-seas-pump.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@srcbook/api': patch
3+
---
4+
5+
Migrate to Vercel AI SDK v4.2.

packages/api/ai/config.mts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,8 @@ export async function getModel(): Promise<LanguageModel> {
7070
baseURL: aiBaseUrl,
7171
});
7272
return openaiCompatible(model);
73+
74+
default:
75+
throw new Error(`Unsupported AI provider: ${aiProvider}`);
7376
}
74-
}
77+
}

packages/api/ai/generate.mts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ ${query}
138138
return prompt;
139139
};
140140

141-
type NoToolsGenerateTextResult = GenerateTextResult<{}>;
141+
// this might throw a compiler error, but that's fine: it's correct in Vercel AI SDK v4.x
142+
type NoToolsGenerateTextResult = GenerateTextResult<{}, {}>;
142143
/*
143144
* Given a user request, which is free form text describing their intent,
144145
* generate a srcbook using an LLM.
@@ -281,6 +282,7 @@ export async function streamEditApp(
281282
}
282283
},
283284
onFinish: () => {
285+
// eslint-disable-next-line turbo/no-undeclared-env-vars
284286
if (process.env.SRCBOOK_DISABLE_ANALYTICS !== 'true') {
285287
logAppGeneration({
286288
appId,

packages/api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"@ai-sdk/openai": "catalog:",
2828
"@ai-sdk/provider": "^1.0.1",
2929
"@srcbook/shared": "workspace:^",
30-
"ai": "^3.4.33",
30+
"ai": "^4.2.0",
3131
"archiver": "^7.0.1",
3232
"better-sqlite3": "^11.3.0",
3333
"cors": "^2.8.5",

0 commit comments

Comments
 (0)