#completion ai agent

1 messages · Page 1 of 1 (latest)

hallow slate
#

"The useCompletion hook allows you to create a user interface to handle text completions in your application. It enables the streaming of text completions from your AI provider, manages the state for chat input, and updates the UI automatically as new messages are received."

Does the convex agent component supports completions from the ai sdk?

livid karmaBOT
#

Hi @hallow slate. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Yes, the Convex Agent component supports completions using the AI SDK. The Agent component is designed to work with language models and can generate and stream both text and objects by leveraging the AI SDK under the hood. You can use methods like agent.streamText or agent.generateText to generate completions, and these methods accept the same arguments as the AI SDK, but you don't need to specify the model each time—the agent's configuration handles that for you. The component also supports streaming completions, allowing you to update the UI as new messages are received, similar to what the useCompletion hook provides in other frameworks. For more details, see the official documentation on Agent Definition and Usage and Streaming with the Agent component.

If you want to consume the stream yourself, you can use the agent's streamText method and iterate over the streamed content, or save the deltas for persistent, multi-client streaming. The Agent component is built to integrate seamlessly with the AI SDK for these use cases, making it suitable for building chat and completion UIs that require real-time updates from your AI provider Consuming the stream yourself with the Agent.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: