1Egyb commited on
Commit
0ec1fff
·
verified ·
1 Parent(s): d492ffe

Create chat-interface.tsx

Browse files
Files changed (1) hide show
  1. frontend/app/chat-interface.tsx +97 -0
frontend/app/chat-interface.tsx ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use client'
2
+
3
+ import { useState } from "react"
4
+ import { Button } from "@/components/ui/button"
5
+ import { Textarea } from "@/components/ui/textarea"
6
+ import { ScrollArea } from "@/components/ui/scroll-area"
7
+ import { Copy, Download, ThumbsUp, ThumbsDown } from 'lucide-react'
8
+ import { cn } from "@/lib/utils"
9
+
10
+ interface Message {
11
+ role: "agent" | "user"
12
+ content: string
13
+ timestamp: string
14
+ }
15
+
16
+ export default function ChatInterface() {
17
+ const [input, setInput] = useState("")
18
+ const [messages] = useState<Message[]>([
19
+ {
20
+ role: "agent",
21
+ content: "Hello, I am a generative AI agent. How may I assist you today?",
22
+ timestamp: "4:08:28 PM"
23
+ },
24
+ {
25
+ role: "user",
26
+ content: "Hi, I'd like to check my bill.",
27
+ timestamp: "4:08:37 PM"
28
+ },
29
+ {
30
+ role: "agent",
31
+ content: "Please hold for a second.\n\nOk, I can help you with that\n\nI'm pulling up your current bill information\n\nYour current bill is $150, and it is due on August 31, 2024.\n\nIf you need more details, feel free to ask!",
32
+ timestamp: "4:08:37 PM"
33
+ }
34
+ ])
35
+
36
+ return (
37
+ <div className="flex-1 flex flex-col">
38
+ <ScrollArea className="flex-1 p-4">
39
+ <div className="space-y-4">
40
+ {messages.map((message, index) => (
41
+ <div
42
+ key={index}
43
+ className={cn(
44
+ "flex gap-2 max-w-[80%]",
45
+ message.role === "user" && "ml-auto"
46
+ )}
47
+ >
48
+ {message.role === "agent" && (
49
+ <div className="h-8 w-8 rounded-full bg-primary flex-shrink-0" />
50
+ )}
51
+ <div className="space-y-2">
52
+ <div className="flex items-center gap-2">
53
+ <span className="text-sm font-medium">
54
+ {message.role === "agent" ? "GenerativeAgent" : "G5"}
55
+ </span>
56
+ <span className="text-sm text-muted-foreground">
57
+ {message.timestamp}
58
+ </span>
59
+ </div>
60
+ <div className="p-3 bg-muted/50 rounded-lg">
61
+ <p className="text-sm whitespace-pre-wrap">{message.content}</p>
62
+ </div>
63
+ {message.role === "agent" && (
64
+ <div className="flex items-center gap-2">
65
+ <Button variant="ghost" size="icon" className="h-8 w-8">
66
+ <Copy className="h-4 w-4" />
67
+ </Button>
68
+ <Button variant="ghost" size="icon" className="h-8 w-8">
69
+ <Download className="h-4 w-4" />
70
+ </Button>
71
+ <Button variant="ghost" size="icon" className="h-8 w-8">
72
+ <ThumbsUp className="h-4 w-4" />
73
+ </Button>
74
+ <Button variant="ghost" size="icon" className="h-8 w-8">
75
+ <ThumbsDown className="h-4 w-4" />
76
+ </Button>
77
+ </div>
78
+ )}
79
+ </div>
80
+ </div>
81
+ ))}
82
+ </div>
83
+ </ScrollArea>
84
+ <div className="p-4 border-t">
85
+ <div className="flex gap-2">
86
+ <Textarea
87
+ placeholder="Type a message as a customer"
88
+ value={input}
89
+ onChange={(e) => setInput(e.target.value)}
90
+ className="min-h-[44px] max-h-32"
91
+ />
92
+ <Button className="px-8">Send</Button>
93
+ </div>
94
+ </div>
95
+ </div>
96
+ )
97
+ }