Skip to content

Commit bcd6805

Browse files
committed
add web search to anthropic and google; upgrade ai dependencies and next
1 parent 3f08165 commit bcd6805

8 files changed

Lines changed: 123 additions & 116 deletions

File tree

next.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const withPWA = require('next-pwa')({
77
const nextConfig = {
88
reactStrictMode: true,
99
trailingSlash: true,
10-
// distDir: 'out',
11-
// output: 'export',
10+
turbopack: {},
1211
};
1312

14-
module.exports = withPWA(nextConfig);
13+
module.exports =
14+
process.env.NODE_ENV === 'production' ? withPWA(nextConfig) : nextConfig;

package-lock.json

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

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
"type-check": "tsc --noEmit"
1515
},
1616
"dependencies": {
17-
"@ai-sdk/anthropic": "^2.0.45",
18-
"@ai-sdk/google": "^2.0.43",
19-
"@ai-sdk/openai": "^2.0.69",
20-
"@ai-sdk/react": "^2.0.97",
17+
"@ai-sdk/anthropic": "^3.0.45",
18+
"@ai-sdk/google": "^3.0.29",
19+
"@ai-sdk/openai": "^3.0.29",
20+
"@ai-sdk/react": "^3.0.92",
2121
"@ai-sdk/ui-utils": "^2.0.0-canary.3",
2222
"@emotion/react": "^11.11.0",
2323
"@emotion/styled": "^11.11.0",
@@ -26,9 +26,9 @@
2626
"@mui/icons-material": "^6.1.5",
2727
"@mui/material": "^6.1.5",
2828
"@vercel/blob": "^0.23.4",
29-
"ai": "^5.0.97",
29+
"ai": "^6.0.90",
3030
"copy-to-clipboard": "^3.3.3",
31-
"next": "15.4.8",
31+
"next": "^16.1.5",
3232
"next-auth": "^4.24.13",
3333
"next-pwa": "^5.6.0",
3434
"react": "^18.2.0",

src/app/api/use-generate-text/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export async function POST(req: Request) {
1111
try {
1212
const result: GenerateTextResult<any, any> = await generateText({
1313
model: openai(model.value),
14-
messages: convertToModelMessages(messages),
14+
messages: await convertToModelMessages(messages),
1515
topP: 0.8,
1616
});
1717

src/app/api/use-stream-text/route.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ export async function POST(req: Request) {
2020
if (model.provider === 'anthropic') {
2121
modelName = anthropic(model.value);
2222

23+
tools = {
24+
web_search: anthropic.tools.webSearch_20250305({}),
25+
};
26+
2327
if (reasoningEffort === 'none') {
2428
providerOptions = {
2529
anthropic: {
@@ -50,6 +54,10 @@ export async function POST(req: Request) {
5054
} else if (model.provider === 'google') {
5155
modelName = google(model.value);
5256

57+
tools = {
58+
google_search: google.tools.googleSearch({}),
59+
};
60+
5361
providerOptions = {
5462
google: {
5563
thinkingConfig: {
@@ -63,8 +71,7 @@ export async function POST(req: Request) {
6371

6472
if (!(reasoningEffort === 'none' && model.value === 'gpt-5-mini')) {
6573
tools = {
66-
web_search_preview: openai.tools.webSearchPreview({
67-
// optional configuration:
74+
web_search: openai.tools.webSearch({
6875
searchContextSize: 'high',
6976
userLocation: {
7077
type: 'approximate',
@@ -89,7 +96,7 @@ export async function POST(req: Request) {
8996
try {
9097
const result: StreamTextResult<any, any> = streamText({
9198
model: modelName,
92-
messages: convertToModelMessages(messages),
99+
messages: await convertToModelMessages(messages),
93100
system: `When presenting any code examples or data tables, always use Markdown code fences.
94101
- Code: wrap with triple backticks and specify the language (e.g., \`\`\`python, \`\`\`rust). Never show code outside fences.
95102
- Tables: wrap GitHub-flavored Markdown tables inside \`\`\`markdown fences.

src/components/Completion.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ export default function Completion({
6161
<div style={{ minHeight: '100%', paddingBottom: '70vh' }}>
6262
{messages?.map((message: UIMessage, index: number) => {
6363
const isUserMessage = message.role === 'user';
64-
const messageTextPart = message.parts.find((part) => part.type === 'text');
64+
const messageTextParts = message.parts.filter((part) => part.type === 'text');
65+
const messageTextPart = messageTextParts.length > 0
66+
? { type: 'text' as const, text: messageTextParts.map((p) => p.text).join('') }
67+
: undefined;
6568
const messageReasoningPart = [...message.parts].reverse().find((part) =>
6669
part.type === 'reasoning' && part.text && getMessageReasoningPartTextTitle(part.text)
6770
);

src/components/MessagesContainer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const MessagesContainer = () => {
1414
hasFiles,
1515
hasImages,
1616
} = useChatContext();
17+
console.log('messages', messages);
1718

1819
const hasAttachments = hasFiles || hasImages;
1920

tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"moduleResolution": "node",
1717
"resolveJsonModule": true,
1818
"isolatedModules": true,
19-
"jsx": "preserve",
19+
"jsx": "react-jsx",
2020
"incremental": true,
2121
"plugins": [
2222
{
@@ -35,7 +35,8 @@
3535
"**/*.tsx",
3636
".next/types/**/*.ts",
3737
"out/types/**/*.ts",
38-
"export/types/**/*.ts"
38+
"export/types/**/*.ts",
39+
".next/dev/types/**/*.ts"
3940
],
4041
"exclude": [
4142
"node_modules"

0 commit comments

Comments
 (0)