From eb0eb26f4cefa4880c895ff017f312e8674f9b73 Mon Sep 17 00:00:00 2001 From: karpathy Date: Sat, 22 Nov 2025 14:27:53 -0800 Subject: v0 --- frontend/src/components/ChatInterface.css | 149 +++++++++++++++++++++++++++++ frontend/src/components/ChatInterface.jsx | 117 +++++++++++++++++++++++ frontend/src/components/Sidebar.css | 78 +++++++++++++++ frontend/src/components/Sidebar.jsx | 43 +++++++++ frontend/src/components/Stage1.css | 65 +++++++++++++ frontend/src/components/Stage1.jsx | 36 +++++++ frontend/src/components/Stage2.css | 153 ++++++++++++++++++++++++++++++ frontend/src/components/Stage2.jsx | 99 +++++++++++++++++++ frontend/src/components/Stage3.css | 25 +++++ frontend/src/components/Stage3.jsx | 22 +++++ 10 files changed, 787 insertions(+) create mode 100644 frontend/src/components/ChatInterface.css create mode 100644 frontend/src/components/ChatInterface.jsx create mode 100644 frontend/src/components/Sidebar.css create mode 100644 frontend/src/components/Sidebar.jsx create mode 100644 frontend/src/components/Stage1.css create mode 100644 frontend/src/components/Stage1.jsx create mode 100644 frontend/src/components/Stage2.css create mode 100644 frontend/src/components/Stage2.jsx create mode 100644 frontend/src/components/Stage3.css create mode 100644 frontend/src/components/Stage3.jsx (limited to 'frontend/src/components') diff --git a/frontend/src/components/ChatInterface.css b/frontend/src/components/ChatInterface.css new file mode 100644 index 0000000..531d2a3 --- /dev/null +++ b/frontend/src/components/ChatInterface.css @@ -0,0 +1,149 @@ +.chat-interface { + flex: 1; + display: flex; + flex-direction: column; + height: 100vh; + background: #ffffff; +} + +.messages-container { + flex: 1; + overflow-y: auto; + padding: 24px; +} + +.empty-state { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + height: 100%; + color: #666; + text-align: center; +} + +.empty-state h2 { + margin: 0 0 8px 0; + font-size: 24px; + color: #333; +} + +.empty-state p { + margin: 0; + font-size: 16px; +} + +.message-group { + margin-bottom: 32px; +} + +.user-message, +.assistant-message { + margin-bottom: 16px; +} + +.message-label { + font-size: 12px; + font-weight: 600; + color: #666; + margin-bottom: 8px; + text-transform: uppercase; + letter-spacing: 0.5px; +} + +.user-message .message-content { + background: #f0f7ff; + padding: 16px; + border-radius: 8px; + border: 1px solid #d0e7ff; + color: #333; + line-height: 1.6; + max-width: 80%; + white-space: pre-wrap; +} + +.loading-indicator { + display: flex; + align-items: center; + gap: 12px; + padding: 16px; + color: #666; + font-size: 14px; +} + +.spinner { + width: 20px; + height: 20px; + border: 2px solid #e0e0e0; + border-top-color: #4a90e2; + border-radius: 50%; + animation: spin 0.8s linear infinite; +} + +@keyframes spin { + to { + transform: rotate(360deg); + } +} + +.input-form { + display: flex; + align-items: flex-end; + gap: 12px; + padding: 24px; + border-top: 1px solid #e0e0e0; + background: #fafafa; +} + +.message-input { + flex: 1; + padding: 14px; + background: #ffffff; + border: 1px solid #d0d0d0; + border-radius: 8px; + color: #333; + font-size: 15px; + font-family: inherit; + line-height: 1.5; + outline: none; + resize: vertical; + min-height: 80px; + max-height: 300px; +} + +.message-input:focus { + border-color: #4a90e2; + box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1); +} + +.message-input:disabled { + opacity: 0.5; + cursor: not-allowed; + background: #f5f5f5; +} + +.send-button { + padding: 14px 28px; + background: #4a90e2; + border: 1px solid #4a90e2; + border-radius: 8px; + color: #fff; + font-size: 15px; + font-weight: 600; + cursor: pointer; + transition: background 0.2s; + white-space: nowrap; + align-self: flex-end; +} + +.send-button:hover:not(:disabled) { + background: #357abd; + border-color: #357abd; +} + +.send-button:disabled { + opacity: 0.5; + cursor: not-allowed; + background: #ccc; + border-color: #ccc; +} diff --git a/frontend/src/components/ChatInterface.jsx b/frontend/src/components/ChatInterface.jsx new file mode 100644 index 0000000..951183f --- /dev/null +++ b/frontend/src/components/ChatInterface.jsx @@ -0,0 +1,117 @@ +import { useState, useEffect, useRef } from 'react'; +import ReactMarkdown from 'react-markdown'; +import Stage1 from './Stage1'; +import Stage2 from './Stage2'; +import Stage3 from './Stage3'; +import './ChatInterface.css'; + +export default function ChatInterface({ + conversation, + onSendMessage, + isLoading, +}) { + const [input, setInput] = useState(''); + const messagesEndRef = useRef(null); + + const scrollToBottom = () => { + messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' }); + }; + + useEffect(() => { + scrollToBottom(); + }, [conversation]); + + const handleSubmit = (e) => { + e.preventDefault(); + if (input.trim() && !isLoading) { + onSendMessage(input); + setInput(''); + } + }; + + const handleKeyDown = (e) => { + // Submit on Enter (without Shift) + if (e.key === 'Enter' && !e.shiftKey) { + e.preventDefault(); + handleSubmit(e); + } + }; + + if (!conversation) { + return ( +
+
+

Welcome to LLM Council

+

Create a new conversation to get started

+
+
+ ); + } + + return ( +
+
+ {conversation.messages.length === 0 ? ( +
+

Start a conversation

+

Ask a question to consult the LLM Council

+
+ ) : ( + conversation.messages.map((msg, index) => ( +
+ {msg.role === 'user' ? ( +
+
You
+
+
+ {msg.content} +
+
+
+ ) : ( +
+
LLM Council
+ + + +
+ )} +
+ )) + )} + + {isLoading && ( +
+
+ Consulting the council... +
+ )} + +
+
+ +
+