#ai-sdk/react primitives support
16 messages · Page 1 of 1 (latest)
Hi @primal apex. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Based on the knowledge sources available, the Convex Agent component does not directly use @ai-sdk/react primitives. Instead, it provides its own React hooks for displaying messages.
The Agent component offers these React-side tools:
useUIMessageshook (from@convex-dev/agent/react) for listing messages, with optional streaming support viastream: trueuseStreamingUIMessageshook for streaming-only scenariosoptimisticallySendMessagehelper for optimistic UI updates
Example usage:
import { api } from "../convex/_generated/api";
import { useUIMessages } from "@convex-dev/agent/react";
function MyComponent({ threadId }: { threadId: string }) {
const { results, status, loadMore } = useUIMessages(
api.chat.streaming.listMessages,
{ threadId },
{ initialNumItems: 10 /* stream: true */ },
);
return (
<div>
{results.map((message) => (
<div key={message.key}>{message.text}</div>
))}
</div>
);
}
The messages returned are typed as UIMessage (extended from the AI SDK's UIMessage type), so the data model is compatible with AI SDK conventions, but the hooks themselves come from @convex-dev/agent/react, not @ai-sdk/react. [UIMessage type]
The knowledge sources do not explicitly mention support for @ai-sdk/react hooks (like useChat) working directly with the Convex Agent component. If you need that integration, you would likely need to bridge them manually, but there is no documented guidance on this in the available sources.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@primal apex Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Let me check the knowledge base for you again. One moment! :books:
It looks like your message came through as just "^" — could you clarify what you meant or rephrase your question? I'm happy to help with anything related to Convex!
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@primal apex Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@leaden fog can convex agent react work with json-render?
Let me check the knowledge base for you again. One moment! :books:
The knowledge sources do not contain any information about "json-render" or its integration with the Convex Agent component. I'm unable to confirm or deny compatibility based on the available documentation.
What I can say is that the Convex Agent's React hooks return UIMessage objects with structured data (including parts, role, text, status, etc.), which you could use to drive any custom rendering logic you write yourself. [UIMessage type]
If you could clarify what "json-render" refers to (a specific library, a pattern, etc.), I can try to give a more targeted answer based on what's available in the Convex docs.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@primal apex Kapa.ai is still learning and improving, please let me know how I did by reacting below.
is it compatible with ai-sdk DataPart? @leaden fog
Let me check the knowledge base for you again. One moment! :books:
The knowledge sources do not contain any information about compatibility between the Convex Agent component and the AI SDK's DataPart type. I cannot confirm or deny this based on the available documentation.
What the knowledge sources do confirm is that the Agent component uses the AI SDK's UIMessage type as a base (extending it with additional fields like key, order, status, etc.), and that messages have a parts array containing items like "text", "file", "image", "toolCall", and "toolResult". [UIMessage type]