From dfda9118d9291a9e21f91bf4eba7e80dcfd4bc49 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Wed, 9 Apr 2025 17:46:27 -0700 Subject: [PATCH] feat: use grok-3-mini as reasoning model (#922) --- .env.example | 3 - README.md | 2 +- components/chat-header.tsx | 2 +- lib/ai/providers.ts | 3 +- package.json | 7 +-- pnpm-lock.yaml | 114 +++++++++++++++++-------------------- 6 files changed, 59 insertions(+), 72 deletions(-) diff --git a/.env.example b/.env.example index ce92e55..5d1199b 100644 --- a/.env.example +++ b/.env.example @@ -7,9 +7,6 @@ AUTH_SECRET=**** # Get your xAI API Key here for chat and image models: https://console.x.ai/ XAI_API_KEY=**** -# Get your Groq API Key here for reasoning models: https://console.groq.com/keys -GROQ_API_KEY=**** - # Instructions to create a Vercel Blob Store here: https://vercel.com/docs/storage/vercel-blob BLOB_READ_WRITE_TOKEN=**** diff --git a/README.md b/README.md index 8665a0a..b8aff09 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ This template ships with [xAI](https://x.ai) `grok-2-1212` as the default chat m You can deploy your own version of the Next.js AI Chatbot to Vercel with one click: -[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fai-chatbot&env=AUTH_SECRET&envDescription=Generate%20a%20random%20secret%20to%20use%20for%20authentication&envLink=https%3A%2F%2Fgenerate-secret.vercel.app%2F32&project-name=my-awesome-chatbot&repository-name=my-awesome-chatbot&demo-title=AI%20Chatbot&demo-description=An%20Open-Source%20AI%20Chatbot%20Template%20Built%20With%20Next.js%20and%20the%20AI%20SDK%20by%20Vercel&demo-url=https%3A%2F%2Fchat.vercel.ai&products=%5B%7B%22type%22%3A%22integration%22%2C%22protocol%22%3A%22ai%22%2C%22productSlug%22%3A%22grok%22%2C%22integrationSlug%22%3A%22xai%22%7D%2C%7B%22type%22%3A%22integration%22%2C%22protocol%22%3A%22ai%22%2C%22productSlug%22%3A%22api-key%22%2C%22integrationSlug%22%3A%22groq%22%7D%2C%7B%22type%22%3A%22integration%22%2C%22protocol%22%3A%22storage%22%2C%22productSlug%22%3A%22neon%22%2C%22integrationSlug%22%3A%22neon%22%7D%2C%7B%22type%22%3A%22blob%22%7D%5D) +[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fai-chatbot&env=AUTH_SECRET&envDescription=Generate%20a%20random%20secret%20to%20use%20for%20authentication&envLink=https%3A%2F%2Fgenerate-secret.vercel.app%2F32&project-name=my-awesome-chatbot&repository-name=my-awesome-chatbot&demo-title=AI%20Chatbot&demo-description=An%20Open-Source%20AI%20Chatbot%20Template%20Built%20With%20Next.js%20and%20the%20AI%20SDK%20by%20Vercel&demo-url=https%3A%2F%2Fchat.vercel.ai&products=%5B%7B%22type%22%3A%22integration%22%2C%22protocol%22%3A%22ai%22%2C%22productSlug%22%3A%22grok%22%2C%22integrationSlug%22%3A%22xai%22%7D%2C%7B%22type%22%3A%22integration%22%2C%22protocol%22%3A%22storage%22%2C%22productSlug%22%3A%22neon%22%2C%22integrationSlug%22%3A%22neon%22%7D%2C%7B%22type%22%3A%22blob%22%7D%5D) ## Running locally diff --git a/components/chat-header.tsx b/components/chat-header.tsx index 003f880..64df8b5 100644 --- a/components/chat-header.tsx +++ b/components/chat-header.tsx @@ -72,7 +72,7 @@ function PureChatHeader({ asChild > diff --git a/lib/ai/providers.ts b/lib/ai/providers.ts index e0ea989..810c329 100644 --- a/lib/ai/providers.ts +++ b/lib/ai/providers.ts @@ -3,7 +3,6 @@ import { extractReasoningMiddleware, wrapLanguageModel, } from 'ai'; -import { groq } from '@ai-sdk/groq'; import { xai } from '@ai-sdk/xai'; import { isTestEnvironment } from '../constants'; import { @@ -26,7 +25,7 @@ export const myProvider = isTestEnvironment languageModels: { 'chat-model': xai('grok-2-1212'), 'chat-model-reasoning': wrapLanguageModel({ - model: groq('deepseek-r1-distill-llama-70b'), + model: xai('grok-3-mini-beta'), middleware: extractReasoningMiddleware({ tagName: 'think' }), }), 'title-model': xai('grok-2-1212'), diff --git a/package.json b/package.json index fdee038..a48d3e3 100644 --- a/package.json +++ b/package.json @@ -19,9 +19,8 @@ "test": "export PLAYWRIGHT=True && pnpm exec playwright test --workers=4" }, "dependencies": { - "@ai-sdk/groq": "^1.2.3", - "@ai-sdk/react": "^1.2.5", - "@ai-sdk/xai": "^1.2.6", + "@ai-sdk/react": "^1.2.8", + "@ai-sdk/xai": "^1.2.10", "@codemirror/lang-javascript": "^6.2.2", "@codemirror/lang-python": "^6.1.6", "@codemirror/state": "^6.5.0", @@ -40,7 +39,7 @@ "@vercel/analytics": "^1.3.1", "@vercel/blob": "^0.24.1", "@vercel/postgres": "^0.10.0", - "ai": "4.2.10", + "ai": "4.3.4", "bcrypt-ts": "^5.0.2", "class-variance-authority": "^0.7.0", "classnames": "^2.5.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index adb36a7..97657c4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,15 +8,12 @@ importers: .: dependencies: - '@ai-sdk/groq': - specifier: ^1.2.3 - version: 1.2.3(zod@3.24.2) '@ai-sdk/react': - specifier: ^1.2.5 - version: 1.2.5(react@19.0.0-rc-45804af1-20241021)(zod@3.24.2) + specifier: ^1.2.8 + version: 1.2.8(react@19.0.0-rc-45804af1-20241021)(zod@3.24.2) '@ai-sdk/xai': - specifier: ^1.2.6 - version: 1.2.6(zod@3.24.2) + specifier: ^1.2.10 + version: 1.2.10(zod@3.24.2) '@codemirror/lang-javascript': specifier: ^6.2.2 version: 6.2.3 @@ -72,8 +69,8 @@ importers: specifier: ^0.10.0 version: 0.10.0 ai: - specifier: 4.2.10 - version: 4.2.10(react@19.0.0-rc-45804af1-20241021)(zod@3.24.2) + specifier: 4.3.4 + version: 4.3.4(react@19.0.0-rc-45804af1-20241021)(zod@3.24.2) bcrypt-ts: specifier: ^5.0.2 version: 5.0.3 @@ -258,30 +255,24 @@ importers: packages: - '@ai-sdk/groq@1.2.3': - resolution: {integrity: sha512-MGPo+ROdJfavrkI4SgJSUOtT6cFjEZEyu7sKKI1PWE3FBTp0oYxSfsmAFWebXGI1G+v70XPFiH9IObBYUiEMvQ==} + '@ai-sdk/openai-compatible@0.2.8': + resolution: {integrity: sha512-o1CrhTrXnMj72G44oBqlDDBtunw6iwONysXj7EYN/Fx27rhP7YTcWwVeKs5gMx/u/8TIho9iZ9rkqXXc2xg8Bg==} engines: {node: '>=18'} peerDependencies: zod: ^3.0.0 - '@ai-sdk/openai-compatible@0.2.5': - resolution: {integrity: sha512-Mi83WLIbrmcrQ5b4LQSl8DSs/QHLGTtRu+5+Kb+4lzxCHAGiqzgEGrFww3S6bl+GVfhGtyTCONqU1Nok2r+k5Q==} - engines: {node: '>=18'} - peerDependencies: - zod: ^3.0.0 - - '@ai-sdk/provider-utils@2.2.3': - resolution: {integrity: sha512-o3fWTzkxzI5Af7U7y794MZkYNEsxbjLam2nxyoUZSScqkacb7vZ3EYHLh21+xCcSSzEC161C7pZAGHtC0hTUMw==} + '@ai-sdk/provider-utils@2.2.6': + resolution: {integrity: sha512-sUlZ7Gnq84DCGWMQRIK8XVbkzIBnvPR1diV4v6JwPgpn5armnLI/j+rqn62MpLrU5ZCQZlDKl/Lw6ed3ulYqaA==} engines: {node: '>=18'} peerDependencies: zod: ^3.23.8 - '@ai-sdk/provider@1.1.0': - resolution: {integrity: sha512-0M+qjp+clUD0R1E5eWQFhxEvWLNaOtGQRUaBn8CUABnSKredagq92hUS9VjOzGsTm37xLfpaxl97AVtbeOsHew==} + '@ai-sdk/provider@1.1.2': + resolution: {integrity: sha512-ITdgNilJZwLKR7X5TnUr1BsQW6UTX5yFp0h66Nfx8XjBYkWD9W3yugr50GOz3CnE9m/U/Cd5OyEbTMI0rgi6ZQ==} engines: {node: '>=18'} - '@ai-sdk/react@1.2.5': - resolution: {integrity: sha512-0jOop3S2WkDOdO4X5I+5fTGqZlNX8/h1T1eYokpkR9xh8Vmrxqw8SsovqGvrddTsZykH8uXRsvI+G4FTyy894A==} + '@ai-sdk/react@1.2.8': + resolution: {integrity: sha512-S2FzCSi4uTF0JuSN6zYMXyiAWVAzi/Hho8ISYgHpGZiICYLNCP2si4DuXQOsnWef3IXzQPLVoE11C63lILZIkw==} engines: {node: '>=18'} peerDependencies: react: ^18 || ^19 || ^19.0.0-rc @@ -290,14 +281,14 @@ packages: zod: optional: true - '@ai-sdk/ui-utils@1.2.4': - resolution: {integrity: sha512-wLTxEZrKZRyBmlVZv8nGXgLBg5tASlqXwbuhoDu0MhZa467ZFREEnosH/OC/novyEHTQXko2zC606xoVbMrUcA==} + '@ai-sdk/ui-utils@1.2.7': + resolution: {integrity: sha512-OVRxa4SDj0wVsMZ8tGr/whT89oqNtNoXBKmqWC2BRv5ZG6azL2LYZ5ZK35u3lb4l1IE7cWGsLlmq0py0ttsL7A==} engines: {node: '>=18'} peerDependencies: zod: ^3.23.8 - '@ai-sdk/xai@1.2.6': - resolution: {integrity: sha512-I5D1uH8kCAx+SDsYdkNQETWMOLMoNGE4BUSqV2qzxnc3+/0RHa0W5pkhyGAgArs+3GDWA3UyRO5OFFdTTCNeVg==} + '@ai-sdk/xai@1.2.10': + resolution: {integrity: sha512-jPaOq7HHJ9A7FF3i/zngcUd6jczFMJF1x9Ayle4IxCZ2gIhtLgv0hiUb1X95keh/gCHjtelBQdzLFNNuiPBadQ==} engines: {node: '>=18'} peerDependencies: zod: ^3.0.0 @@ -1652,8 +1643,8 @@ packages: engines: {node: '>=0.4.0'} hasBin: true - ai@4.2.10: - resolution: {integrity: sha512-rOfKbNRWlzwxbFll6W9oAdnC0R5VVbAJoof+p92CatHzA3reqQZmYn33IBnj+CgqeXYUsH9KX9Wnj7g2wCHc9Q==} + ai@4.3.4: + resolution: {integrity: sha512-uMjzrowIqfU8CCCxhx8QGl7ETydHBROeNL0VoEwetkmDCY6Q8ZTacj6jNNqGJOiCk595aUrGR9VHPY9Ylvy1fg==} engines: {node: '>=18'} peerDependencies: react: ^18 || ^19 || ^19.0.0-rc @@ -2939,6 +2930,11 @@ packages: mz@2.7.0: resolution: {integrity: sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==} + nanoid@3.3.11: + resolution: {integrity: sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==} + engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} + hasBin: true + nanoid@3.3.9: resolution: {integrity: sha512-SppoicMGpZvbF1l3z4x7No3OlIjP7QJvC9XR7AhZr1kL133KHnKPztkKDc+Ir4aJ/1VhTySrtKhrsycmrMQfvg==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} @@ -3849,8 +3845,8 @@ packages: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} - zod-to-json-schema@3.24.3: - resolution: {integrity: sha512-HIAfWdYIt1sssHfYZFCXp4rU1w2r8hVVXYIlmoa0r0gABLs5di3RCqPU5DDROogVz1pAdYBaz7HK5n9pSUNs3A==} + zod-to-json-schema@3.24.5: + resolution: {integrity: sha512-/AuWwMP+YqiPbsJx5D6TfgRTc4kTLjsh5SOcd4bLsfUg2RcEXrFMJl1DGgdHy2aCfsIA/cr/1JM0xcB2GZji8g==} peerDependencies: zod: ^3.24.1 @@ -3862,51 +3858,45 @@ packages: snapshots: - '@ai-sdk/groq@1.2.3(zod@3.24.2)': + '@ai-sdk/openai-compatible@0.2.8(zod@3.24.2)': dependencies: - '@ai-sdk/provider': 1.1.0 - '@ai-sdk/provider-utils': 2.2.3(zod@3.24.2) + '@ai-sdk/provider': 1.1.2 + '@ai-sdk/provider-utils': 2.2.6(zod@3.24.2) zod: 3.24.2 - '@ai-sdk/openai-compatible@0.2.5(zod@3.24.2)': + '@ai-sdk/provider-utils@2.2.6(zod@3.24.2)': dependencies: - '@ai-sdk/provider': 1.1.0 - '@ai-sdk/provider-utils': 2.2.3(zod@3.24.2) - zod: 3.24.2 - - '@ai-sdk/provider-utils@2.2.3(zod@3.24.2)': - dependencies: - '@ai-sdk/provider': 1.1.0 - nanoid: 3.3.9 + '@ai-sdk/provider': 1.1.2 + nanoid: 3.3.11 secure-json-parse: 2.7.0 zod: 3.24.2 - '@ai-sdk/provider@1.1.0': + '@ai-sdk/provider@1.1.2': dependencies: json-schema: 0.4.0 - '@ai-sdk/react@1.2.5(react@19.0.0-rc-45804af1-20241021)(zod@3.24.2)': + '@ai-sdk/react@1.2.8(react@19.0.0-rc-45804af1-20241021)(zod@3.24.2)': dependencies: - '@ai-sdk/provider-utils': 2.2.3(zod@3.24.2) - '@ai-sdk/ui-utils': 1.2.4(zod@3.24.2) + '@ai-sdk/provider-utils': 2.2.6(zod@3.24.2) + '@ai-sdk/ui-utils': 1.2.7(zod@3.24.2) react: 19.0.0-rc-45804af1-20241021 swr: 2.3.3(react@19.0.0-rc-45804af1-20241021) throttleit: 2.1.0 optionalDependencies: zod: 3.24.2 - '@ai-sdk/ui-utils@1.2.4(zod@3.24.2)': + '@ai-sdk/ui-utils@1.2.7(zod@3.24.2)': dependencies: - '@ai-sdk/provider': 1.1.0 - '@ai-sdk/provider-utils': 2.2.3(zod@3.24.2) + '@ai-sdk/provider': 1.1.2 + '@ai-sdk/provider-utils': 2.2.6(zod@3.24.2) zod: 3.24.2 - zod-to-json-schema: 3.24.3(zod@3.24.2) + zod-to-json-schema: 3.24.5(zod@3.24.2) - '@ai-sdk/xai@1.2.6(zod@3.24.2)': + '@ai-sdk/xai@1.2.10(zod@3.24.2)': dependencies: - '@ai-sdk/openai-compatible': 0.2.5(zod@3.24.2) - '@ai-sdk/provider': 1.1.0 - '@ai-sdk/provider-utils': 2.2.3(zod@3.24.2) + '@ai-sdk/openai-compatible': 0.2.8(zod@3.24.2) + '@ai-sdk/provider': 1.1.2 + '@ai-sdk/provider-utils': 2.2.6(zod@3.24.2) zod: 3.24.2 '@alloc/quick-lru@5.2.0': {} @@ -5005,12 +4995,12 @@ snapshots: acorn@8.14.1: {} - ai@4.2.10(react@19.0.0-rc-45804af1-20241021)(zod@3.24.2): + ai@4.3.4(react@19.0.0-rc-45804af1-20241021)(zod@3.24.2): dependencies: - '@ai-sdk/provider': 1.1.0 - '@ai-sdk/provider-utils': 2.2.3(zod@3.24.2) - '@ai-sdk/react': 1.2.5(react@19.0.0-rc-45804af1-20241021)(zod@3.24.2) - '@ai-sdk/ui-utils': 1.2.4(zod@3.24.2) + '@ai-sdk/provider': 1.1.2 + '@ai-sdk/provider-utils': 2.2.6(zod@3.24.2) + '@ai-sdk/react': 1.2.8(react@19.0.0-rc-45804af1-20241021)(zod@3.24.2) + '@ai-sdk/ui-utils': 1.2.7(zod@3.24.2) '@opentelemetry/api': 1.9.0 jsondiffpatch: 0.6.0 zod: 3.24.2 @@ -6675,6 +6665,8 @@ snapshots: object-assign: 4.1.1 thenify-all: 1.6.0 + nanoid@3.3.11: {} + nanoid@3.3.9: {} nanoid@5.1.3: {} @@ -7742,7 +7734,7 @@ snapshots: yocto-queue@0.1.0: {} - zod-to-json-schema@3.24.3(zod@3.24.2): + zod-to-json-schema@3.24.5(zod@3.24.2): dependencies: zod: 3.24.2