feat: AI SDK registry assistant (chat demo + log)#148
Open
alejopequeno wants to merge 37 commits into
Open
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Author
Contributor
|
@greptile |
Contributor
|
Let's remove the "—" |
Contributor
Contributor
|
I'd love to see a broader explanation about the AI sdk patten. How the event stream relates to the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
The registry's headless
<Chat>had no example of wiring it to a real AI backend, and there was no conversational way to discover registry items. We also lacked a log documenting the AI SDKmessage.partspattern.Root Cause
useChatreduces a stream intomessages[].parts[], where each tool call carries its own frozen output. Rendering rich UI frompart.output(instead of shared state) is the key pattern, but nothing in the registry demonstrated it.Result
Adds a live, AI-powered registry assistant demo (
demos/ai-sdk-chat, embedded via iframe in a new log) that wires the headless<Chat>to the Vercel AI SDK:searchComponentstool (lib/registry-search.ts) searches the whole registry — components, toolbox tools, logs, and lab experiments — and renders each with the registry's own cards (PreviewCard/ExperimentCard).prefers-reduced-motionaware.app/api/chat/route.ts):streamTextvia Groq (openai/gpt-oss-120b) with Zod input validation; replies in the user's language; errors logged server-side, masked client-side.content/logs/16-message-parts-as-render-anchors.mdxteaches the pattern with the live demo embedded.The registry's
<Chat>component is consumed unchanged.Notes
GROQ_API_KEYin the environment (added toenv.example). Free tier; swap the model in one line.Greptile Summary
Adds a live AI-powered registry assistant demo (
demos/ai-sdk-chat) wired to the Vercel AI SDK v6 and a new MDX log documenting themessage.partsrender pattern. The backend usesstreamTextvia Groq with asearchComponentstool that performs keyword search across components, toolbox tools, logs, and lab experiments.app/api/chat/route.ts): correctly uses AI SDK v6 idioms (toUIMessageStreamResponse, typedtool()withinputSchema,stopWhen: stepCountIs,smoothStream), but the in-memoryrateHitsMap provides no real protection in a multi-instance serverless deployment.message.partsrendering pattern correctly — typedtool-searchComponentsparts, lifecycle-aware shimmer/cards transitions, and aprefers-reduced-motionfallback on every animation.Confidence Score: 4/5
Safe to merge with one caveat: the rate limiter added to protect the Groq API key will not work correctly across multiple serverless instances.
The route adds an in-memory rate limiter, but in a Vercel multi-instance deployment each instance keeps its own counter, so a caller whose requests land on different instances sees no effective limit. The Groq key is exposed to exhaustion just as if the limiter weren't there. Everything else — demo components, search logic, AI SDK usage — looks correct and well-structured.
app/api/chat/route.ts — the isRateLimited function needs a durable backing store (e.g., Vercel KV) to be effective in production.
Important Files Changed
Comments Outside Diff (1)
demos/ai-sdk-chat/index.tsx, line 289-293 (link)sr-onlytext needaria-hidden="true"so assistive technology doesn't announce the SVG on top of the visible label.Context Used: public/AGENTS.md (source)
Prompt To Fix With AI
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Reviews (3): Last reviewed commit: "feat: animate streamed assistant markdow..." | Re-trigger Greptile