Skip to content
Open
10 changes: 1 addition & 9 deletions examples/dev-screener/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,14 @@ To get started with Langbase, you'll need to [create a free personal account on
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"
```

7. Run the following commands in your CLI:

```sh
# Install the dependencies using the following command:
npm install

# Run the project using the following command:
npm run dev
```

```
8. Your app template should now be running on [localhost:3000][local].

> NOTE:
Expand Down
11 changes: 10 additions & 1 deletion examples/dev-screener/components/chatbot-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,6 +32,11 @@ export function Chatbot({ id, initialMessages, className }: ChatProps) {
setThreadId(lbThreadId)
}
})

const sendSuggestedPrompt = (prompt: string) => {
setInput(prompt)
}

return (
<div className="min-h-screen">
<div className={cn('pb-36 pt-4 md:pt-10', className)}>
Expand All @@ -39,7 +45,10 @@ export function Chatbot({ id, initialMessages, className }: ChatProps) {
<ChatList messages={messages} />
</>
) : (
<Opening />
<>
<Opening />
<Suggestions sendSuggestedPrompt={sendSuggestedPrompt} />
</>
)}
</div>
<ChatInput
Expand Down
16 changes: 14 additions & 2 deletions examples/dev-screener/components/prompt-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<UseChatHelpers, 'input' | 'setInput'> {
Expand Down Expand Up @@ -49,9 +50,20 @@ export function PromptForm({
className="text-muted-foreground/50 h-5 w-5"
aria-hidden="true"
/>
<h3>Chat</h3>
<h3>Ask</h3>
<HoverCard>
<HoverCardTrigger asChild>
<Button variant="link" size="lg" className="text-inherit">@conversation tips</Button>
</HoverCardTrigger>
<HoverCardContent>
<ul className="list-disc pl-4">
<li>Say hello to start a guided conversation.</li>
<li>DevScreener provides a demo to help determine if there is a match between the candidate's profile and the company's position goals.</li>
<li>The conversation with DevScreener includes multiple-choice questions (MCQs) and experience-related questions for the candidate to answer.</li>
</ul>
</HoverCardContent>
</HoverCard>
</div>

<div className="flex items-center justify-center gap-2 md:justify-start">
{/* Reset chat */}
<Button
Expand Down
48 changes: 48 additions & 0 deletions examples/dev-screener/components/suggestions.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div className="mx-auto mt-12 max-w-4xl">
<label className="font-semibold">Suggestions</label>
<div className="grid grid-cols-1 gap-4 pt-6 md:grid-cols-2">
{suggestions.map((suggestion, index) => {
return (
<div
key={index}
className={cn(
'border-muted-foreground/20 flex cursor-pointer items-center gap-4 rounded-md border p-4',
'hover:bg-background transition-all'
)}
onClick={() => handleClick(suggestion.prompt)}
>
<IconSparkles
className="text-muted-foreground size-4"
aria-hidden="true"
/>
<p className="text-foreground/70 line-clamp-2 font-light leading-6">
{suggestion.title}
</p>
</div>
)
})}
</div>
</div>
)
}
29 changes: 29 additions & 0 deletions examples/dev-screener/components/ui/hovercard.tsx
Original file line number Diff line number Diff line change
@@ -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<typeof HoverCardPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof HoverCardPrimitive.Content>
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
<HoverCardPrimitive.Content
ref={ref}
align={align}
sideOffset={sideOffset}
className={cn(
"z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className
)}
{...props}
/>
))
HoverCardContent.displayName = HoverCardPrimitive.Content.displayName

export { HoverCard, HoverCardTrigger, HoverCardContent }
1 change: 1 addition & 0 deletions examples/dev-screener/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"@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",
Expand Down