import { useState, useRef, useEffect } from 'react' import './ChatBox.css' export default function ChatBox({ messages, onSendMessage, loading }) { const [inputValue, setInputValue] = useState('') const messagesEndRef = useRef(null) const inputRef = useRef(null) const scrollToBottom = () => { messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' }) } useEffect(() => { scrollToBottom() }, [messages]) const handleSend = () => { if (inputValue.trim() && !loading) { onSendMessage(inputValue) setInputValue('') setTimeout(() => inputRef.current?.focus(), 0) } } const handleKeyPress = (e) => { if (e.key === 'Enter' && !e.shiftKey && !loading) { e.preventDefault() handleSend() } } return (
Starte eine Unterhaltung mit dem Zephyr-7B Modell