-
Notifications
You must be signed in to change notification settings - Fork 877
DC-4746 AI SDK Guide #7069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DC-4746 AI SDK Guide #7069
Conversation
WalkthroughAdds a docs sidebar entry and a new guide that implements a Next.js + Prisma AI chat example: Prisma schema and client, API routes for streaming chat and retrieving messages, a persistence helper, and a Next.js page scaffold that loads, streams, and persists chat messages. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UI as Next.js Client (Page)
participant MsgAPI as /api/messages
participant ChatAPI as /api/chat
participant AI as AI SDK
participant DB as Prisma / DB
User->>UI: Open page
UI->>MsgAPI: GET /api/messages
MsgAPI->>DB: Query messages ordered by createdAt
DB-->>MsgAPI: Messages
MsgAPI-->>UI: UI-formatted messages
UI-->>User: Render messages
User->>UI: Submit prompt
UI->>ChatAPI: POST /api/chat { id, messages }
ChatAPI->>AI: Stream completion request
AI-->>ChatAPI: Streamed tokens/response
ChatAPI-->>UI: Streamed response chunks
ChatAPI->>DB: onFinish -> save session + recent messages
DB-->>ChatAPI: Save confirmation
Estimated code review effort🎯 4 (Complex) | ⏱️ ~35 minutes Possibly related PRs
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
Dangerous URL checkNo absolute URLs to prisma.io/docs found. |
Redirect checkThis PR probably requires the following redirects to be added to static/_redirects:
|
Deploying docs with
|
| Latest commit: |
b25b6bd
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://762fca17.docs-51g.pages.dev |
| Branch Preview URL: | https://dc-4746-ai-sdk-guide.docs-51g.pages.dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 8
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
content/800-guides/340-ai-adk-nextjs.mdx(1 hunks)sidebars.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Check internal links
- GitHub Check: runner / linkspector
- GitHub Check: Lost Pixel
- GitHub Check: Cloudflare Pages
🔇 Additional comments (2)
sidebars.ts (1)
449-449: LGTM - Sidebar integration looks correct.The new AI SDK guide is properly added to the Integration Solutions category and maintains the existing sort pattern for consistency.
content/800-guides/340-ai-adk-nextjs.mdx (1)
148-161: Confirm Prisma client import path in the documentation.The
lib/prisma.tssnippet currently imports fromimport { PrismaClient } from "../app/generated/prisma/client";but most setups either use the default
@prisma/clientlocation or customize theoutputin yourschema.prisma. Please verify and update this example to match your generator configuration:• If you’re using the default client, change the import to:
import { PrismaClient } from "@prisma/client";• If you’ve set a custom
outputin yourschema.prisma, make sure it points toapp/generated/prisma/client, e.g.:generator client { provider = "prisma-client-js" output = "../app/generated/prisma/client" }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
🧹 Nitpick comments (3)
content/800-guides/340-ai-sdk-nextjs.mdx (3)
309-319: Remove redundant session null check afterupsert.
upsertalways returns an object; the null/undefined check is dead code.Apply this diff:
const session = await prisma.session.upsert({ where: { id }, update: {}, create: { id }, }); - if (!session) throw new Error("Session not found");
181-185: Clarify Accelerate usage note.If readers use Accelerate primarily to support Edge runtimes, consider adding a short note that the route can be marked for edge runtime in Next.js if desired and that Accelerate requires the proper connection string set up.
I can draft a brief addendum showing
export const runtime = 'edge'for the chat route and a one-liner about setting the Accelerate connection string. Want me to add it?
619-619: Grammar nit: “a AI SDK” → “an AI SDK”.Apply this diff:
-You're done! You've just created a AI SDK chat application with Next.js and Prisma. Below are some next steps to explore, as well as some more resources to help you get started expanding your project. +You're done! You've just created an AI SDK chat application with Next.js and Prisma. Below are some next steps to explore, as well as some more resources to help you get started expanding your project.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
content/800-guides/340-ai-sdk-nextjs.mdx(1 hunks)sidebars.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- sidebars.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Check internal links
- GitHub Check: runner / linkspector
- GitHub Check: Lost Pixel
🔇 Additional comments (1)
content/800-guides/340-ai-sdk-nextjs.mdx (1)
582-597: No changes needed:useChatv5 correctly exposessendMessage
The latest@ai-sdk/react(v5) hook returnssendMessage(alongsideregenerateandstop); the form-helper functionshandleSubmit/handleInputChangeare from earlier v4 patterns and aren’t part of the current API. Your existing snippet usingsendMessage({ text: input })is accurate—no migration tohandleSubmitis required.Likely an incorrect or invalid review comment.
|
Images automagically compressed by Calibre's image-actions ✨ Compression reduced images by 4.2%, saving 31.18 KB.
206 images did not require optimisation. |
* AI SDK guide created * Rename 340-ai-adk-nextjs.mdx to 340-ai-sdk-nextjs.mdx * coderabbit changes * name change in sidebar * sidebar name change * OG image added * Optimised images with calibre/image-actions --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Summary by CodeRabbit