Skip to content

Commit 8f3e300

Browse files
authored
chore: upgrade to AI SDK v6 (#1372)
### Description <!-- ✍️ Write a short summary of your work. Screenshots and videos are welcome! --> ### Demo URL https://oss-vibe-coding-platform.vercel.app/ <!-- Provide a URL to a live deployment where we can test your PR. If a demo isn't possible feel free to omit this section. --> ### Type of Change - [ ] New Example - [x] Example updates (Bug fixes, new features, etc.) - [ ] Other (changes to the codebase, but not to examples) ### New Example Checklist - [ ] 🛫 `npm run new-example` was used to create the example - [ ] 📚 The template wasn't used but I carefuly read the [Adding a new example](https://github.com/vercel/examples#adding-a-new-example) steps and implemented them in the example - [ ] 📱 Is it responsive? Are mobile and tablets considered?
1 parent dc8117d commit 8f3e300

File tree

6 files changed

+86
-83
lines changed

6 files changed

+86
-83
lines changed

apps/vibe-coding-platform/ai/gateway.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { createGatewayProvider } from '@ai-sdk/gateway'
22
import { Models } from './constants'
33
import type { JSONValue } from 'ai'
44
import type { OpenAIResponsesProviderOptions } from '@ai-sdk/openai'
5-
import type { LanguageModelV2 } from '@ai-sdk/provider'
5+
import type { LanguageModelV3 } from '@ai-sdk/provider'
66

77
export async function getAvailableModels() {
88
const gateway = gatewayInstance()
@@ -11,7 +11,7 @@ export async function getAvailableModels() {
1111
}
1212

1313
export interface ModelOptions {
14-
model: LanguageModelV2
14+
model: LanguageModelV3
1515
providerOptions?: Record<string, Record<string, JSONValue>>
1616
headers?: Record<string, string>
1717
}

apps/vibe-coding-platform/ai/tools/generate-files/get-contents.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { streamObject, type ModelMessage } from 'ai'
1+
import { streamText, Output, type ModelMessage } from 'ai'
22
import { getModelOptions } from '@/ai/gateway'
33
import { Deferred } from '@/lib/deferred'
44
import z from 'zod/v3'
@@ -35,7 +35,7 @@ export async function* getContents(
3535
): AsyncGenerator<FileContentChunk> {
3636
const generated: z.infer<typeof fileSchema>[] = []
3737
const deferred = new Deferred<void>()
38-
const result = streamObject({
38+
const result = streamText({
3939
...getModelOptions(params.modelId, { reasoningEffort: 'low' }),
4040
maxOutputTokens: 64000,
4141
system:
@@ -49,15 +49,15 @@ export async function* getContents(
4949
)}`,
5050
},
5151
],
52-
schema: z.object({ files: z.array(fileSchema) }),
52+
output: Output.object({ schema: z.object({ files: z.array(fileSchema) }) }),
5353
onError: (error) => {
5454
deferred.reject(error)
5555
console.error('Error communicating with AI')
5656
console.error(JSON.stringify(error, null, 2))
5757
},
5858
})
5959

60-
for await (const items of result.partialObjectStream) {
60+
for await (const items of result.partialOutputStream) {
6161
if (!Array.isArray(items?.files)) {
6262
continue
6363
}
@@ -81,7 +81,7 @@ export async function* getContents(
8181
}
8282
}
8383

84-
const raceResult = await Promise.race([result.object, deferred.promise])
84+
const raceResult = await Promise.race([result.output, deferred.promise])
8585
if (!raceResult) {
8686
throw new Error('Unexpected Error: Deferred was resolved before the result')
8787
}

apps/vibe-coding-platform/app/api/chat/route.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ export async function POST(req: Request) {
3939
return createUIMessageStreamResponse({
4040
stream: createUIMessageStream({
4141
originalMessages: messages,
42-
execute: ({ writer }) => {
42+
execute: async ({ writer }) => {
4343
const result = streamText({
4444
...getModelOptions(modelId, { reasoningEffort }),
4545
system: prompt,
46-
messages: convertToModelMessages(
46+
messages: await convertToModelMessages(
4747
messages.map((message) => {
4848
message.parts = message.parts.map((part) => {
4949
if (part.type === 'data-report-errors') {
@@ -83,5 +83,5 @@ export async function POST(req: Request) {
8383
)
8484
},
8585
}),
86-
})
86+
});
8787
}

apps/vibe-coding-platform/app/api/errors/route.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Models } from '@/ai/constants'
22
import { NextResponse } from 'next/server'
33
import { checkBotId } from 'botid/server'
4-
import { generateObject } from 'ai'
4+
import { generateText, Output } from 'ai'
55
import { linesSchema, resultSchema } from '@/components/error-monitor/schemas'
66
import prompt from './prompt.md'
77

@@ -17,7 +17,7 @@ export async function POST(req: Request) {
1717
return NextResponse.json({ error: `Invalid request` }, { status: 400 })
1818
}
1919

20-
const result = await generateObject({
20+
const result = await generateText({
2121
system: prompt,
2222
model: Models.OpenAIGPT52,
2323
providerOptions: {
@@ -29,10 +29,10 @@ export async function POST(req: Request) {
2929
},
3030
},
3131
messages: [{ role: 'user', content: JSON.stringify(parsedBody.data) }],
32-
schema: resultSchema,
32+
output: Output.object({ schema: resultSchema }),
3333
})
3434

35-
return NextResponse.json(result.object, {
35+
return NextResponse.json(result.output, {
3636
status: 200,
3737
})
3838
}

apps/vibe-coding-platform/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
"type-check": "tsc --noEmit"
1111
},
1212
"dependencies": {
13-
"@ai-sdk/gateway": "1.0.32",
14-
"@ai-sdk/openai": "2.0.42",
15-
"@ai-sdk/provider": "^2.0.0",
16-
"@ai-sdk/react": "2.0.59",
17-
"@ai-sdk/vercel": "1.0.20",
13+
"@ai-sdk/gateway": "2.0.0-beta.93",
14+
"@ai-sdk/openai": "3.0.0-beta.112",
15+
"@ai-sdk/provider": "3.0.0-beta.32",
16+
"@ai-sdk/react": "3.0.0-beta.172",
17+
"@ai-sdk/vercel": "2.0.0-beta.60",
1818
"@radix-ui/react-checkbox": "1.3.3",
1919
"@radix-ui/react-dialog": "1.1.14",
2020
"@radix-ui/react-label": "2.1.7",
@@ -23,7 +23,7 @@
2323
"@radix-ui/react-select": "2.2.5",
2424
"@radix-ui/react-slot": "1.2.3",
2525
"@vercel/sandbox": "0.0.17",
26-
"ai": "5.0.59",
26+
"ai": "6.0.0-beta.169",
2727
"arctic": "3.7.0",
2828
"botid": "1.4.5",
2929
"class-variance-authority": "0.7.1",
@@ -37,11 +37,11 @@
3737
"nuqs": "2.4.3",
3838
"react": "^19.2.1",
3939
"react-dom": "^19.2.1",
40-
"streamdown": "^1.6.6",
4140
"react-resizable-panels": "3.0.4",
4241
"react-spinners": "0.17.0",
4342
"react-syntax-highlighter": "15.6.1",
4443
"sonner": "^2.0.6",
44+
"streamdown": "^1.6.6",
4545
"strip-ansi": "7.1.0",
4646
"swr": "2.3.4",
4747
"tailwind-merge": "3.3.1",

apps/vibe-coding-platform/pnpm-lock.yaml

Lines changed: 65 additions & 62 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)