2024-10-21 13:57:45 -06:00
|
|
|
import { Send, StopCircle } from "lucide-react"
|
|
|
|
import { Button } from "../../ui/button"
|
2024-10-14 22:34:26 -04:00
|
|
|
|
|
|
|
interface ChatInputProps {
|
2024-10-21 13:57:45 -06:00
|
|
|
input: string
|
|
|
|
setInput: (input: string) => void
|
|
|
|
isGenerating: boolean
|
|
|
|
handleSend: () => void
|
|
|
|
handleStopGeneration: () => void
|
2024-10-14 22:34:26 -04:00
|
|
|
}
|
|
|
|
|
2024-10-21 13:57:45 -06:00
|
|
|
export default function ChatInput({
|
|
|
|
input,
|
|
|
|
setInput,
|
|
|
|
isGenerating,
|
|
|
|
handleSend,
|
|
|
|
handleStopGeneration,
|
|
|
|
}: ChatInputProps) {
|
2024-10-14 22:34:26 -04:00
|
|
|
return (
|
|
|
|
<div className="flex space-x-2 min-w-0">
|
2024-10-21 13:57:45 -06:00
|
|
|
<input
|
2024-10-14 22:34:26 -04:00
|
|
|
type="text"
|
|
|
|
value={input}
|
|
|
|
onChange={(e) => setInput(e.target.value)}
|
2024-10-21 13:57:45 -06:00
|
|
|
onKeyPress={(e) => e.key === "Enter" && !isGenerating && handleSend()}
|
2024-10-14 22:34:26 -04:00
|
|
|
className="flex-grow p-2 border rounded-lg min-w-0 bg-input"
|
|
|
|
placeholder="Type your message..."
|
|
|
|
disabled={isGenerating}
|
|
|
|
/>
|
|
|
|
{isGenerating ? (
|
2024-10-21 13:57:45 -06:00
|
|
|
<Button
|
|
|
|
onClick={handleStopGeneration}
|
|
|
|
variant="destructive"
|
|
|
|
size="icon"
|
|
|
|
className="h-10 w-10"
|
|
|
|
>
|
2024-10-14 22:34:26 -04:00
|
|
|
<StopCircle className="w-4 h-4" />
|
|
|
|
</Button>
|
|
|
|
) : (
|
2024-10-21 13:57:45 -06:00
|
|
|
<Button
|
|
|
|
onClick={handleSend}
|
|
|
|
disabled={isGenerating}
|
|
|
|
size="icon"
|
|
|
|
className="h-10 w-10"
|
|
|
|
>
|
2024-10-14 22:34:26 -04:00
|
|
|
<Send className="w-4 h-4" />
|
|
|
|
</Button>
|
|
|
|
)}
|
|
|
|
</div>
|
2024-10-21 13:57:45 -06:00
|
|
|
)
|
2024-10-14 22:34:26 -04:00
|
|
|
}
|