This guide provides detailed, step-by-step instructions on how to use Upstash RAG Chat with Next.js Server Actions. You can also explore our Next.js Server Actions example for detailed, end-to-end examples and best practices.
"use server";import{ RAGChat, upstash }from"@upstash/rag-chat";import{ createServerActionStream }from"@upstash/rag-chat/nextjs";const ragChat =newRAGChat({ model:upstash("meta-llama/Meta-Llama-3-8B-Instruct"),});exportconstserverChat=async(message:string)=>{const{ output }=await ragChat.chat(message,{ streaming:true});// 👇 adapter to let us stream from server actionsreturncreateServerActionStream(output);};