diff --git a/examples/js-tutor/.env.example b/examples/js-tutor/.env.example index 85d27328..81f12161 100644 --- a/examples/js-tutor/.env.example +++ b/examples/js-tutor/.env.example @@ -1 +1,2 @@ -NEXT_LB_PIPE_API_KEY="" \ No newline at end of file +LB_PIPE_API_KEY="" + diff --git a/examples/js-tutor/README.md b/examples/js-tutor/README.md index a84fa99c..fa0dc160 100755 --- a/examples/js-tutor/README.md +++ b/examples/js-tutor/README.md @@ -5,7 +5,7 @@ ## Build JavaScript Tutor 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). +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]. @@ -37,7 +37,7 @@ To get started with Langbase, you'll need to [create a free personal account on 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: ``` @@ -63,7 +63,8 @@ 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/js_tutor/js_tutor.png + +[cover]:https://raw.githubusercontent.com/LangbaseInc/docs-images/main/examples/js_tutor/js-tutor-chatbot.png [demo]: https://js-tutor.langbase.dev [lb]: https://langbase.com [pipe]: https://langbase.com/examples/js-tutor diff --git a/examples/js-tutor/app/api/chat/route.ts b/examples/js-tutor/app/api/chat/route.ts index 95af6ed7..7987954b 100755 --- a/examples/js-tutor/app/api/chat/route.ts +++ b/examples/js-tutor/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/js-tutor/components/chatbot-page.tsx b/examples/js-tutor/components/chatbot-page.tsx index 80203378..f5424b9b 100755 --- a/examples/js-tutor/components/chatbot-page.tsx +++ b/examples/js-tutor/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} +
+