From bfb5dce74456202c0170efa506a1ded3953f0726 Mon Sep 17 00:00:00 2001 From: "estevez.sebastian@gmail.com" Date: Wed, 16 Jul 2025 03:54:01 -0400 Subject: [PATCH] toggle --- frontend/src/app/chat/page.tsx | 38 +++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/frontend/src/app/chat/page.tsx b/frontend/src/app/chat/page.tsx index b26d0270..b64dd1f2 100644 --- a/frontend/src/app/chat/page.tsx +++ b/frontend/src/app/chat/page.tsx @@ -4,7 +4,7 @@ import { useState, useRef, useEffect } from "react" import { Button } from "@/components/ui/button" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { Input } from "@/components/ui/input" -import { MessageCircle, Send, Loader2, User, Bot } from "lucide-react" +import { MessageCircle, Send, Loader2, User, Bot, Settings } from "lucide-react" import { cn } from "@/lib/utils" interface Message { @@ -13,10 +13,13 @@ interface Message { timestamp: Date } +type EndpointType = "chat" | "langflow" + export default function ChatPage() { const [messages, setMessages] = useState([]) const [input, setInput] = useState("") const [loading, setLoading] = useState(false) + const [endpoint, setEndpoint] = useState("chat") const messagesEndRef = useRef(null) const scrollToBottom = () => { @@ -42,7 +45,8 @@ export default function ChatPage() { setLoading(true) try { - const response = await fetch("/api/chat", { + const apiEndpoint = endpoint === "chat" ? "/api/chat" : "/api/langflow" + const response = await fetch(apiEndpoint, { method: "POST", headers: { "Content-Type": "application/json", @@ -90,12 +94,32 @@ export default function ChatPage() { - - - Chat - +
+
+ + Chat +
+
+ + +
+
- Chat with AI about your indexed documents + Chat with AI about your indexed documents using {endpoint === "chat" ? "Chat" : "Langflow"} endpoint