nuxt-hub / core

Build full-stack applications with Nuxt on CloudFlare, with zero configuration.
https://hub.nuxt.com
Apache License 2.0
993 stars 57 forks source link

docs: document `useChat()` from Vercel AI SDK #250

Closed ra-jeev closed 2 months ago

ra-jeev commented 2 months ago

Utility composable for handling Workers AI LLM responses from api endpoints.

Supports streaming/non-streaming responses from a single generator function.

Typical usage:

const response = useAIChat('/api/chat', model, params)();

for await (const chunk of response) {
  // Do something with the response chunks
  // Single chunk for non-streaming case      
}
pkg-pr-new[bot] commented 2 months ago

commit: fc83b41

pnpm add https://pkg.pr.new/nuxt-hub/core/@nuxthub/core@250

Open in Stackblitz

ra-jeev commented 2 months ago

@atinux please review the new composable. Instead of having two separate functions for streaming/non-streaming cases, merged into one.

Have also changed the playground AI UI & api endpoint little bit to test the composable.

Thanks, Rajeev