chore: updated vercel ai sdk

This commit is contained in:
Dustin 2025-06-25 10:39:52 -04:00
parent 7de5851efc
commit 1235143938
3 changed files with 17 additions and 8 deletions

View File

@ -34,13 +34,19 @@ async function chatAction({ context, request }: ActionFunctionArgs) {
const result = await streamText(messages, context.cloudflare.env, options); const result = await streamText(messages, context.cloudflare.env, options);
return stream.switchSource(result.toAIStream()); return (
/* WARNING: toAIStream has been removed from streamText.
See migration guide at https://sdk.vercel.ai/docs/migrations */
stream.switchSource(result.toDataStream())
);
}, },
}; };
const result = await streamText(messages, context.cloudflare.env, options); const result = await streamText(messages, context.cloudflare.env, options);
stream.switchSource(result.toAIStream()); /* WARNING: toAIStream has been removed from streamText.
See migration guide at https://sdk.vercel.ai/docs/migrations */
stream.switchSource(result.toDataStream());
return new Response(stream.readable, { return new Response(stream.readable, {
status: 200, status: 200,

View File

@ -1,5 +1,5 @@
import { type ActionFunctionArgs } from '@remix-run/cloudflare'; import { type ActionFunctionArgs } from '@remix-run/cloudflare';
import { StreamingTextResponse, parseStreamPart } from 'ai'; import { parseDataStreamPart } from 'ai';
import { streamText } from '~/lib/.server/llm/stream-text'; import { streamText } from '~/lib/.server/llm/stream-text';
import { stripIndents } from '~/utils/stripIndent'; import { stripIndents } from '~/utils/stripIndent';
@ -38,7 +38,7 @@ async function enhancerAction({ context, request }: ActionFunctionArgs) {
.decode(chunk) .decode(chunk)
.split('\n') .split('\n')
.filter((line) => line !== '') .filter((line) => line !== '')
.map(parseStreamPart) .map(parseDataStreamPart)
.map((part) => part.value) .map((part) => part.value)
.join(''); .join('');
@ -46,9 +46,11 @@ async function enhancerAction({ context, request }: ActionFunctionArgs) {
}, },
}); });
const transformedStream = result.toAIStream().pipeThrough(transformStream); const transformedStream = /* WARNING: toAIStream has been removed from streamText.
See migration guide at https://sdk.vercel.ai/docs/migrations */
result.toDataStream().pipeThrough(transformStream);
return new StreamingTextResponse(transformedStream); return result.toDataStreamResponse();
} catch (error) { } catch (error) {
console.log(error); console.log(error);

View File

@ -23,7 +23,7 @@
"node": ">=22.14.0" "node": ">=22.14.0"
}, },
"dependencies": { "dependencies": {
"@ai-sdk/anthropic": "^0.0.39", "@ai-sdk/anthropic": "^1.2.12",
"@codemirror/autocomplete": "^6.18.6", "@codemirror/autocomplete": "^6.18.6",
"@codemirror/commands": "^6.8.1", "@codemirror/commands": "^6.8.1",
"@codemirror/lang-cpp": "^6.0.3", "@codemirror/lang-cpp": "^6.0.3",
@ -54,7 +54,7 @@
"@xterm/addon-fit": "^0.10.0", "@xterm/addon-fit": "^0.10.0",
"@xterm/addon-web-links": "^0.11.0", "@xterm/addon-web-links": "^0.11.0",
"@xterm/xterm": "^5.5.0", "@xterm/xterm": "^5.5.0",
"ai": "^3.3.4", "ai": "^4.3.16",
"date-fns": "^3.6.0", "date-fns": "^3.6.0",
"diff": "^5.2.0", "diff": "^5.2.0",
"framer-motion": "^11.2.12", "framer-motion": "^11.2.12",
@ -87,6 +87,7 @@
"is-ci": "^3.0.1", "is-ci": "^3.0.1",
"node-fetch": "^3.3.2", "node-fetch": "^3.3.2",
"prettier": "^3.3.2", "prettier": "^3.3.2",
"sass-embedded": "^1.89.2",
"typescript": "^5.5.2", "typescript": "^5.5.2",
"unified": "^11.0.5", "unified": "^11.0.5",
"unocss": "^0.61.3", "unocss": "^0.61.3",