diff --git a/examples/expert-proofreader/.env.example b/examples/expert-proofreader/.env.example index 85d27328..a5aacd2b 100644 --- a/examples/expert-proofreader/.env.example +++ b/examples/expert-proofreader/.env.example @@ -1 +1 @@ -NEXT_LB_PIPE_API_KEY="" \ No newline at end of file +LB_PIPE_API_KEY="" \ No newline at end of file diff --git a/examples/expert-proofreader/README.md b/examples/expert-proofreader/README.md index ea984ceb..436f3661 100755 --- a/examples/expert-proofreader/README.md +++ b/examples/expert-proofreader/README.md @@ -1,24 +1,26 @@ - ![Expert Proofreader Chatbot by ⌘ Langbase][cover] ![License: MIT][mit] [![Fork to ⌘ Langbase][fork]][pipe] -## Build Expert Proofreader with Pipes — ⌘ Langbase -This chatbot is built by using an AI Pipe on Langbase, it works with 30+ LLMs (OpenAI, Gemini, Mistral, Llama, Gemma, etc), any Data (10M+ context with Memory sets), and any Framework (standard web API you can use with any software). +## Build Expert Proofreader with a Pipe — ⌘ Langbase + +This chatbot is built by using an agentic Pipe on Langbase, it works with 30+ LLMs (OpenAI, Gemini, Mistral, Llama, Gemma, etc), any Data (10M+ context with Memory sets), and any Framework (standard web API you can use with any software). + Check out the live demo [here][demo]. ## Features -- 💬 [Expert Proofreader Bot][demo] — Built with an [AI Pipe on ⌘ Langbase][pipe] + +- 💬 [Expert Proofreader Chatbot][demo] — Built with an [AI Pipe on ⌘ Langbase][pipe] - ⚡️ Streaming — Real-time chat experience with streamed responses - 🗣️ Q/A — Ask questions and get pre-defined answers with your preferred AI model and tone - 🔋 Responsive and open source — Works on all devices and platforms ## Learn more -1. Check the [Expert Proofreader Bot on ⌘ Langbase][pipe] +1. Check the [Expert Proofreader Chatbot on ⌘ Langbase][pipe] 2. Read the [source code on GitHub][gh] for this example 3. Go through Documentaion: [Pipe Quick Start][qs] 4. Learn more about [Pipes & Memory features on ⌘ Langbase][docs] @@ -29,16 +31,15 @@ Let's get started with the project: To get started with Langbase, you'll need to [create a free personal account on Langbase.com][signup] and verify your email address. _Done? Cool, cool!_ -1. Fork the [Expert Proofreader Bot][pipe] Pipe on ⌘ Langbase. +1. Fork the [Expert Proofreader Chatbot][pipe] Pipe on ⌘ Langbase. 2. Go to the API tab to copy the Pipe's API key (to be used on server-side only). 3. Download the example project folder from [here][download] or clone the reppository. 4. `cd` into the project directory and open it in your code editor. 5. Duplicate the `.env.example` file in this project and rename it to `.env.local`. 6. Add the following environment variables (.env.local): - ``` # Replace `PIPE_API_KEY` with the copied API key. - NEXT_LB_PIPE_API_KEY="PIPE_API_KEY" + LB_PIPE_API_KEY="PIPE_API_KEY" ``` 7. In your CLI issue the following ``` @@ -64,8 +65,7 @@ This project is created by [Langbase][lb] team members, with contributions from: **_Built by ⌘ [Langbase.com][lb] — Ship hyper-personalized AI assistants with memory!_** - -[cover]:https://raw.githubusercontent.com/LangbaseInc/docs-images/main/examples/expert-proofreader/expert-proofreader.png +[cover]:https://raw.githubusercontent.com/LangbaseInc/docs-images/main/examples/expert-proofreader/expert-proofreader-chatbot.png [demo]: https://expert-proofreader.langbase.dev [lb]: https://langbase.com [pipe]: https://langbase.com/examples/expert-proofreader diff --git a/examples/expert-proofreader/app/api/chat/route.ts b/examples/expert-proofreader/app/api/chat/route.ts index 95af6ed7..7987954b 100755 --- a/examples/expert-proofreader/app/api/chat/route.ts +++ b/examples/expert-proofreader/app/api/chat/route.ts @@ -10,9 +10,9 @@ export const runtime = 'edge' */ export async function POST(req: Request) { try { - if (!process.env.NEXT_LB_PIPE_API_KEY) { + if (!process.env.LB_PIPE_API_KEY) { throw new Error( - 'Please set NEXT_LB_PIPE_API_KEY in your environment variables.' + 'Please set LB_PIPE_API_KEY in your environment variables.' ) } @@ -20,7 +20,7 @@ export async function POST(req: Request) { const headers = { 'Content-Type': 'application/json', - Authorization: `Bearer ${process.env.NEXT_LB_PIPE_API_KEY}` + Authorization: `Bearer ${process.env.LB_PIPE_API_KEY}` } // Get chat prompt messages and threadId from the client. diff --git a/examples/expert-proofreader/components/chatbot-page.tsx b/examples/expert-proofreader/components/chatbot-page.tsx index 80203378..e673c6dc 100755 --- a/examples/expert-proofreader/components/chatbot-page.tsx +++ b/examples/expert-proofreader/components/chatbot-page.tsx @@ -7,6 +7,7 @@ import { useState } from 'react' import { toast } from 'sonner' import { ChatInput } from './chat-input' import { Opening } from './opening' +import { Suggestions } from './suggestions' export interface ChatProps extends React.ComponentProps<'div'> { id?: string // Optional: Thread ID if you want to persist the chat in a DB @@ -31,6 +32,11 @@ export function Chatbot({ id, initialMessages, className }: ChatProps) { setThreadId(lbThreadId) } }) + + const sendSuggestedPrompt = (prompt: string) => { + setInput(prompt) + } + return (
+ {suggestion.title} +
+