diff --git a/src/components/Layout.tsx b/src/components/Layout.tsx index 89704a2..e1bd47e 100644 --- a/src/components/Layout.tsx +++ b/src/components/Layout.tsx @@ -1,16 +1,16 @@ import { useState } from "react"; -import { MessageSquare, Image, Mic, ArrowLeft, Plus, ChevronLeft, ChevronRight } from "lucide-react"; +import { MessageSquare, Image, Mic, ArrowLeft, Plus, ChevronLeft, ChevronRight, Bot } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Separator } from "@/components/ui/separator"; import { ThemeToggle } from "@/components/ThemeToggle"; interface LayoutProps { children: React.ReactNode; - activeTab: "chat" | "images" | "audio"; - onTabChange: (tab: "chat" | "images" | "audio") => void; + activeTab: "chat" | "images" | "audio" | "bots"; + onTabChange: (tab: "chat" | "images" | "audio" | "bots") => void; } -type TabType = "chat" | "images" | "audio"; +type TabType = "chat" | "images" | "audio" | "bots"; export const Layout = ({ children, activeTab, onTabChange }: LayoutProps) => { const [isSidebarCollapsed, setIsSidebarCollapsed] = useState(false); @@ -19,6 +19,7 @@ export const Layout = ({ children, activeTab, onTabChange }: LayoutProps) => { { id: "chat" as TabType, label: "Bate-papo", icon: MessageSquare }, { id: "images" as TabType, label: "Imagens", icon: Image }, { id: "audio" as TabType, label: "Áudio", icon: Mic }, + { id: "bots" as TabType, label: "Bots", icon: Bot }, ]; return ( diff --git a/src/components/bots/BotChat.tsx b/src/components/bots/BotChat.tsx new file mode 100644 index 0000000..bcf2816 --- /dev/null +++ b/src/components/bots/BotChat.tsx @@ -0,0 +1,120 @@ +import { useState } from "react"; +import { ArrowLeft } from "lucide-react"; +import { Button } from "@/components/ui/button"; +import { ChatMessage } from "@/components/chat/ChatMessage"; +import { ChatInput } from "@/components/chat/ChatInput"; +import { ScrollArea } from "@/components/ui/scroll-area"; + +interface Bot { + id: string; + name: string; + prompt: string; + model: string; +} + +interface Message { + id: string; + role: "user" | "assistant"; + content: string; + model?: string; + attachments?: Array<{ + name: string; + type: string; + size: number; + }>; +} + +interface BotChatProps { + bot: Bot; + onBack: () => void; +} + +export const BotChat = ({ bot, onBack }: BotChatProps) => { + const [messages, setMessages] = useState([ + { + id: "1", + role: "assistant", + content: `Olá! Sou ${bot.name}. ${bot.prompt}`, + model: bot.model, + }, + ]); + const [isLoading, setIsLoading] = useState(false); + + const handleSendMessage = (content: string, files?: File[]) => { + const newMessage: Message = { + id: Date.now().toString(), + role: "user", + content, + attachments: files?.map((file) => ({ + name: file.name, + type: file.type, + size: file.size, + })), + }; + + setMessages((prev) => [...prev, newMessage]); + setIsLoading(true); + + // Simulate AI response + setTimeout(() => { + const aiResponse: Message = { + id: (Date.now() + 1).toString(), + role: "assistant", + content: `Resposta do ${bot.name} usando ${bot.model}. Esta é uma resposta simulada considerando as instruções: "${bot.prompt}"`, + model: bot.model, + }; + setMessages((prev) => [...prev, aiResponse]); + setIsLoading(false); + }, 1500); + }; + + return ( +
+ {/* Header */} +
+ +
+

{bot.name}

+

{bot.model}

+
+
+ + {/* Messages */} + +
+ {messages.map((message) => ( + + ))} + + {isLoading && ( +
+
+
+
+
+
+
+
+
+
+ )} +
+ + + {/* Input */} + +
+ ); +}; diff --git a/src/components/bots/BotView.tsx b/src/components/bots/BotView.tsx new file mode 100644 index 0000000..5c92c8b --- /dev/null +++ b/src/components/bots/BotView.tsx @@ -0,0 +1,301 @@ +import { useState } from "react"; +import { Bot, Edit, MessageSquare, Trash2 } from "lucide-react"; +import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import { Textarea } from "@/components/ui/textarea"; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; +import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; +import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog"; +import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@/components/ui/alert-dialog"; +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; + +interface Bot { + id: string; + name: string; + prompt: string; + model: string; +} + +interface BotViewProps { + onStartChat: (bot: Bot) => void; +} + +export const BotView = ({ onStartChat }: BotViewProps) => { + const [bots, setBots] = useState([]); + const [isCreateDialogOpen, setIsCreateDialogOpen] = useState(false); + const [isEditDialogOpen, setIsEditDialogOpen] = useState(false); + const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false); + const [selectedBot, setSelectedBot] = useState(null); + + const [formData, setFormData] = useState({ + name: "", + prompt: "", + model: "ChatGPT 4.1", + }); + + const handleCreateBot = () => { + const newBot: Bot = { + id: Date.now().toString(), + name: formData.name, + prompt: formData.prompt, + model: formData.model, + }; + setBots([...bots, newBot]); + setFormData({ name: "", prompt: "", model: "ChatGPT 4.1" }); + setIsCreateDialogOpen(false); + }; + + const handleEditBot = () => { + if (!selectedBot) return; + setBots(bots.map(bot => + bot.id === selectedBot.id + ? { ...bot, name: formData.name, prompt: formData.prompt, model: formData.model } + : bot + )); + setIsEditDialogOpen(false); + setSelectedBot(null); + setFormData({ name: "", prompt: "", model: "ChatGPT 4.1" }); + }; + + const handleDeleteBot = () => { + if (!selectedBot) return; + setBots(bots.filter(bot => bot.id !== selectedBot.id)); + setIsDeleteDialogOpen(false); + setSelectedBot(null); + }; + + const openEditDialog = (bot: Bot) => { + setSelectedBot(bot); + setFormData({ + name: bot.name, + prompt: bot.prompt, + model: bot.model, + }); + setIsEditDialogOpen(true); + }; + + const openDeleteDialog = (bot: Bot) => { + setSelectedBot(bot); + setIsDeleteDialogOpen(true); + }; + + return ( +
+
+
+
+

+ + Gerenciador de Bots +

+

Crie e gerencie seus assistentes de IA

+
+ + + + + + + Criar Novo Bot + + Configure seu assistente de IA personalizado + + +
+
+ + setFormData({ ...formData, name: e.target.value })} + placeholder="Ex: Assistente de Programação" + /> +
+
+ +