diff --git a/examples/nextjs/server-actions/package.json b/examples/nextjs/server-actions/package.json index 2e8fe80..4433cdb 100644 --- a/examples/nextjs/server-actions/package.json +++ b/examples/nextjs/server-actions/package.json @@ -9,7 +9,7 @@ "lint": "next lint" }, "dependencies": { - "@upstash/rag-chat": "../../", + "@upstash/rag-chat": "^1.0.1", "next": "14.2.4", "react": "^18", "react-dom": "^18" diff --git a/examples/nextjs/server-actions/src/app/actions.ts b/examples/nextjs/server-actions/src/app/actions.ts index 6337d46..dde5f78 100644 --- a/examples/nextjs/server-actions/src/app/actions.ts +++ b/examples/nextjs/server-actions/src/app/actions.ts @@ -1,10 +1,10 @@ "use server"; -import { UpstashMessage } from "@upstash/rag-chat"; -import { createServerActionStream } from "@upstash/rag-chat/rsc"; +import type { UpstashMessage } from "@upstash/rag-chat"; +import { createServerActionStream } from "@upstash/rag-chat/nextjs"; import { ragChat } from "./rag-chat"; -export const server_chat = async ({ userMessage }: { userMessage: UpstashMessage }) => { +export const serverChat = async ({ userMessage }: { userMessage: UpstashMessage }) => { const { output } = await ragChat.chat(userMessage.content, { streaming: true }); // 👇 adapter to convert standard readable stream into rsc-compatible stream @@ -13,26 +13,26 @@ export const server_chat = async ({ userMessage }: { userMessage: UpstashMessage return stream; }; -export const server_add_data = async () => { +export const serverAddData = async () => { await Promise.all([ ragChat.context.add({ - dataType: "text", + type: "text", data: "Paris, the capital of France, is renowned for its iconic landmark, the Eiffel Tower, which was completed in 1889 and stands at 330 meters tall.", }), ragChat.context.add({ - dataType: "text", + type: "text", data: "The city is home to numerous world-class museums, including the Louvre Museum, housing famous works such as the Mona Lisa and Venus de Milo.", }), ragChat.context.add({ - dataType: "text", + type: "text", data: "Paris is often called the City of Light due to its significant role during the Age of Enlightenment and its early adoption of street lighting.", }), ragChat.context.add({ - dataType: "text", + type: "text", data: "The Seine River gracefully flows through Paris, dividing the city into the Left Bank and the Right Bank, each offering its own distinct atmosphere.", }), ragChat.context.add({ - dataType: "text", + type: "text", data: "Paris boasts a rich culinary scene, with a plethora of bistros, cafés, and Michelin-starred restaurants serving exquisite French cuisine.", }), ]); diff --git a/examples/nextjs/server-actions/src/app/components/Chat.tsx b/examples/nextjs/server-actions/src/app/components/chat.tsx similarity index 90% rename from examples/nextjs/server-actions/src/app/components/Chat.tsx rename to examples/nextjs/server-actions/src/app/components/chat.tsx index 289c2e6..45edc5c 100644 --- a/examples/nextjs/server-actions/src/app/components/Chat.tsx +++ b/examples/nextjs/server-actions/src/app/components/chat.tsx @@ -1,9 +1,9 @@ "use client"; -import { UpstashMessage } from "@upstash/rag-chat"; -import { readServerActionStream } from "@upstash/rag-chat/rsc"; +import type { UpstashMessage } from "@upstash/rag-chat"; +import { readServerActionStream } from "@upstash/rag-chat/nextjs"; import { useState } from "react"; -import { server_add_data, server_chat } from "../actions"; +import { serverAddData, serverChat } from "../actions"; export const Chat = ({ initialMessages }: { initialMessages?: UpstashMessage[] }) => { const [messages, setMessages] = useState(initialMessages ?? []); @@ -20,7 +20,7 @@ export const Chat = ({ initialMessages }: { initialMessages?: UpstashMessage[] } setIsLoading(true); try { - const stream = await server_chat({ userMessage }); + const stream = await serverChat({ userMessage }); let aiMessage: UpstashMessage = { content: "", role: "assistant", @@ -46,7 +46,7 @@ export const Chat = ({ initialMessages }: { initialMessages?: UpstashMessage[] } const handleAddData = async () => { setIsLoading(true); try { - await server_add_data(); + await serverAddData(); } catch (error) { console.error("Error adding data:", error); } finally { diff --git a/examples/nextjs/server-actions/src/app/page.tsx b/examples/nextjs/server-actions/src/app/page.tsx index 4c232b1..58a9f11 100644 --- a/examples/nextjs/server-actions/src/app/page.tsx +++ b/examples/nextjs/server-actions/src/app/page.tsx @@ -1,4 +1,4 @@ -import { Chat } from "./components/Chat"; +import { Chat } from "./components/chat"; import { ragChat } from "./rag-chat"; export default async function Page() { diff --git a/examples/nextjs/vercel-ai-sdk/package.json b/examples/nextjs/vercel-ai-sdk/package.json index e8a16d9..4433cdb 100644 --- a/examples/nextjs/vercel-ai-sdk/package.json +++ b/examples/nextjs/vercel-ai-sdk/package.json @@ -9,7 +9,7 @@ "lint": "next lint" }, "dependencies": { - "@upstash/rag-chat": "0.0.5-1.alpha", + "@upstash/rag-chat": "^1.0.1", "next": "14.2.4", "react": "^18", "react-dom": "^18" diff --git a/examples/nextjs/vercel-ai-sdk/src/app/api/add-data/route.ts b/examples/nextjs/vercel-ai-sdk/src/app/api/add-data/route.ts index 79b8ee7..b131f51 100644 --- a/examples/nextjs/vercel-ai-sdk/src/app/api/add-data/route.ts +++ b/examples/nextjs/vercel-ai-sdk/src/app/api/add-data/route.ts @@ -5,23 +5,23 @@ export async function POST() { const ragChat = new RAGChat({}); await Promise.all([ ragChat.context.add({ - dataType: "text", + type: "text", data: "Paris, the capital of France, is renowned for its iconic landmark, the Eiffel Tower, which was completed in 1889 and stands at 330 meters tall.", }), ragChat.context.add({ - dataType: "text", + type: "text", data: "The city is home to numerous world-class museums, including the Louvre Museum, housing famous works such as the Mona Lisa and Venus de Milo.", }), ragChat.context.add({ - dataType: "text", + type: "text", data: "Paris is often called the City of Light due to its significant role during the Age of Enlightenment and its early adoption of street lighting.", }), ragChat.context.add({ - dataType: "text", + type: "text", data: "The Seine River gracefully flows through Paris, dividing the city into the Left Bank and the Right Bank, each offering its own distinct atmosphere.", }), ragChat.context.add({ - dataType: "text", + type: "text", data: "Paris boasts a rich culinary scene, with a plethora of bistros, cafés, and Michelin-starred restaurants serving exquisite French cuisine.", }), ]);