diff --git a/examples/api-sec-consultant/components/chatbot-page.tsx b/examples/api-sec-consultant/components/chatbot-page.tsx index 80203378..9c4538f9 100755 --- a/examples/api-sec-consultant/components/chatbot-page.tsx +++ b/examples/api-sec-consultant/components/chatbot-page.tsx @@ -8,6 +8,9 @@ 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 initialMessages?: Message[] // Optional: Messages to pre-populate the chat from DB @@ -31,6 +34,12 @@ export function Chatbot({ id, initialMessages, className }: ChatProps) { setThreadId(lbThreadId) } }) + + + const sendSuggestedPrompt = (prompt: string) => { + setInput(prompt) + } + return (
@@ -39,7 +48,10 @@ export function Chatbot({ id, initialMessages, className }: ChatProps) { ) : ( - + <> + + + )}
{ @@ -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 with the Web API Security Consultant Bot. Answer the Yes/No questions accurately to assess your API's security posture.
  • +
  • If needed, ask the bot to clarify any question before answering.
  • +
  • After the 10th section, the bot will provide an overall security score, offering a rough estimate of potential vulnerabilities based on the OWASP API Security Checklist (2023).
  • +
+
+
diff --git a/examples/api-sec-consultant/components/suggestions.tsx b/examples/api-sec-consultant/components/suggestions.tsx new file mode 100644 index 00000000..84709607 --- /dev/null +++ b/examples/api-sec-consultant/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 (MCQs)`, + 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/api-sec-consultant/components/ui/accordion.tsx b/examples/api-sec-consultant/components/ui/accordion.tsx new file mode 100644 index 00000000..b192028a --- /dev/null +++ b/examples/api-sec-consultant/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/api-sec-consultant/components/ui/hovercard.tsx b/examples/api-sec-consultant/components/ui/hovercard.tsx new file mode 100644 index 00000000..89c7a16d --- /dev/null +++ b/examples/api-sec-consultant/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/api-sec-consultant/package.json b/examples/api-sec-consultant/package.json index 9dc024ca..e8a2c4f5 100755 --- a/examples/api-sec-consultant/package.json +++ b/examples/api-sec-consultant/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",