File size: 1,745 Bytes
085db90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f3e9c6
1232fa2
0f3e9c6
 
 
 
 
 
 
085db90
 
0f3e9c6
085db90
 
 
 
 
 
 
 
 
 
 
 
 
 
1232fa2
085db90
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import React, { useState } from 'react';
import { Play, Shuffle, Square } from 'lucide-react';

export default function ChatControls({ onStart, onStop, disabled, isRunning }) {
  const [starterText, setStarterText] = useState('');

  const handleStartWithText = () => {
    onStart(starterText.trim() || null);
  };

  const handleAutoStart = () => {
    onStart(null);
  };

  return (
    <div className="chat-controls">
      {isRunning ? (
        <button className="btn-stop" onClick={onStop} title="Stop the conversation">
          <Square size={14} style={{ verticalAlign: 'middle', marginRight: 4 }} />
          Stop Chat
        </button>
      ) : (
        <>
          <button
            className="btn-primary"
            onClick={handleAutoStart}
            disabled={disabled}
            title="Let the LLMs start on their own"
          >
            <Shuffle size={14} style={{ verticalAlign: 'middle', marginRight: 4 }} />
            Let Them Start
          </button>
          <input
            type="text"
            placeholder="Let them start on their own, or enter a conversation starter here"
            value={starterText}
            onChange={e => setStarterText(e.target.value)}
            disabled={disabled}
            onKeyDown={e => {
              if (e.key === 'Enter' && !disabled) handleStartWithText();
            }}
          />
          <button
            className="btn-primary"
            onClick={handleStartWithText}
            disabled={disabled}
            title="Start with your message"
          >
            <Play size={14} style={{ verticalAlign: 'middle', marginRight: 4 }} />
            Start Chat With My Prompt
          </button>
        </>
      )}
    </div>
  );
}