diff --git a/examples/product-review-generator/README.md b/examples/product-review-generator/README.md index 86afb914..bb34a6e4 100755 --- a/examples/product-review-generator/README.md +++ b/examples/product-review-generator/README.md @@ -37,7 +37,7 @@ To get started with Langbase, you'll need to [create a free personal account on ``` # Replace `PIPE_API_KEY` with the copied API key. NEXT_LB_PIPE_API_KEY="PIPE_API_KEY" -``` +``` 7. Issue the following in your CLI: ```sh @@ -46,7 +46,7 @@ To get started with Langbase, you'll need to [create a free personal account on # Run the project using the following command: npm run dev -``` +``` 8. Your app template should now be running on [localhost:3000][local]. diff --git a/examples/product-review-generator/components/chatbot-page.tsx b/examples/product-review-generator/components/chatbot-page.tsx index 80203378..9a66b0d0 100755 --- a/examples/product-review-generator/components/chatbot-page.tsx +++ b/examples/product-review-generator/components/chatbot-page.tsx @@ -7,6 +7,9 @@ import { useState } from 'react' import { toast } from 'sonner' import { ChatInput } from './chat-input' import { Opening } from './opening' +import { HoverCard, HoverCardTrigger, HoverCardContent } from '@/components/ui/hovercard' +import { Suggestions } from './suggestions' +import { Button } from './ui/button' export interface ChatProps extends React.ComponentProps<'div'> { id?: string // Optional: Thread ID if you want to persist the chat in a DB @@ -31,27 +34,37 @@ export function Chatbot({ id, initialMessages, className }: ChatProps) { setThreadId(lbThreadId) } }) + + const sendSuggestedPrompt = (prompt: string) => { + setInput(prompt) + } + return (
-
- {messages.length ? ( - <> - - - ) : ( - - )} +
+
+ {messages.length ? ( + <> + + + ) : ( + <> + + + + )} +
+
- -
+
) } diff --git a/examples/product-review-generator/components/prompt-form.tsx b/examples/product-review-generator/components/prompt-form.tsx index 49b6cb77..9623dd02 100755 --- a/examples/product-review-generator/components/prompt-form.tsx +++ b/examples/product-review-generator/components/prompt-form.tsx @@ -4,6 +4,7 @@ import { useEnterSubmit } from '@/lib/hooks/use-enter-submit' import { UseChatHelpers } from 'ai/react' import * as React from 'react' import Textarea from 'react-textarea-autosize' +import { HoverCard, HoverCardTrigger, HoverCardContent } from '@/components/ui/hovercard' export interface PromptProps extends Pick { @@ -49,7 +50,19 @@ export function PromptForm({ className="text-muted-foreground/50 h-5 w-5" aria-hidden="true" /> -

Chat

+

Ask

+ + + + + +
    +
  • Say hello to start a guided conversation.
  • +
  • Give a detailed review of the product you recently bought including positive and negative aspects.
  • +
  • The Product Review Generator bot will generate a comprehensive review for you and other buyers looking for the same product.
  • +
+
+
diff --git a/examples/product-review-generator/components/suggestions.tsx b/examples/product-review-generator/components/suggestions.tsx new file mode 100644 index 00000000..10d6068f --- /dev/null +++ b/examples/product-review-generator/components/suggestions.tsx @@ -0,0 +1,48 @@ +import cn from 'mxcn' +import { IconSparkles } from './ui/icons' + +// Prompt suggestions – Change these to match your use-case/company +const suggestions = [ + { + title: `Say hello to begin and follow guided conversation`, + prompt: `Hello` + }, +] + +export const Suggestions = ({ + sendSuggestedPrompt +}: { + sendSuggestedPrompt: (prompt: string) => void +}) => { + const handleClick = (prompt: string) => { + sendSuggestedPrompt(prompt) + } + + return ( +
+ +
+ {suggestions.map((suggestion, index) => { + return ( +
handleClick(suggestion.prompt)} + > +
+ ) + })} +
+
+ ) +} \ No newline at end of file diff --git a/examples/product-review-generator/components/ui/accordion.tsx b/examples/product-review-generator/components/ui/accordion.tsx new file mode 100644 index 00000000..b192028a --- /dev/null +++ b/examples/product-review-generator/components/ui/accordion.tsx @@ -0,0 +1,58 @@ +"use client" + +import * as React from "react" +import * as AccordionPrimitive from "@radix-ui/react-accordion" +import { ChevronDown } from "lucide-react" + +import cn from 'mxcn' + +const Accordion = AccordionPrimitive.Root + +const AccordionItem = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AccordionItem.displayName = "AccordionItem" + +const AccordionTrigger = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + + svg]:rotate-180", + className + )} + {...props} + > + {children} + + + +)) +AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName + +const AccordionContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + +
{children}
+
+)) + +AccordionContent.displayName = AccordionPrimitive.Content.displayName + +export { Accordion, AccordionItem, AccordionTrigger, AccordionContent } diff --git a/examples/product-review-generator/components/ui/hovercard.tsx b/examples/product-review-generator/components/ui/hovercard.tsx new file mode 100644 index 00000000..89c7a16d --- /dev/null +++ b/examples/product-review-generator/components/ui/hovercard.tsx @@ -0,0 +1,29 @@ +"use client" + +import * as React from "react" +import * as HoverCardPrimitive from "@radix-ui/react-hover-card" + +import cn from 'mxcn' + +const HoverCard = HoverCardPrimitive.Root + +const HoverCardTrigger = HoverCardPrimitive.Trigger + +const HoverCardContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, align = "center", sideOffset = 4, ...props }, ref) => ( + +)) +HoverCardContent.displayName = HoverCardPrimitive.Content.displayName + +export { HoverCard, HoverCardTrigger, HoverCardContent } diff --git a/examples/product-review-generator/package.json b/examples/product-review-generator/package.json index 206cf7a2..959368a5 100755 --- a/examples/product-review-generator/package.json +++ b/examples/product-review-generator/package.json @@ -9,12 +9,15 @@ "lint": "next lint" }, "dependencies": { + "@radix-ui/react-accordion": "^1.2.0", + "@radix-ui/react-hover-card": "^1.1.1", "@radix-ui/react-label": "^2.0.2", "@radix-ui/react-separator": "^1.0.3", "@radix-ui/react-slot": "^1.0.2", "@radix-ui/react-switch": "^1.0.3", "ai": "3.0.16", "class-variance-authority": "^0.7.0", + "lucide-react": "^0.438.0", "mxcn": "^2.0.0", "next": "14.0.4", "react": "^18.2.0",