-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChatbotConfig.tsx
64 lines (59 loc) · 1.63 KB
/
ChatbotConfig.tsx
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
58
59
60
61
62
63
64
// ChatbotConfig.tsx
import React, { useState } from 'react';
import { ChatbotConfig } from './types';
import { updateChatbotConfig } from './api.service';
const ChatbotConfigComponent: React.FC = () => {
const [config, setConfig] = useState<ChatbotConfig>({
model: 'gpt-3.5-turbo',
maxTokens: 150,
temperature: 0.7
});
async function handleUpdateConfig() {
const response = await updateChatbotConfig(config);
if (response.success) {
alert('Configuration updated successfully');
} else {
alert('Failed to update configuration');
}
}
return (
<div className="chatbot-config">
<h2>Chatbot Configuration</h2>
<div>
<label>
Model:
<input
type="text"
value={config.model}
onChange={(e) => setConfig(prev => ({ ...prev, model: e.target.value }))}
/>
</label>
</div>
<div>
<label>
Max Tokens:
<input
type="number"
value={config.maxTokens}
onChange={(e) => setConfig(prev => ({ ...prev, maxTokens: parseInt(e.target.value) }))}
/>
</label>
</div>
<div>
<label>
Temperature:
<input
type="number"
step="0.1"
min="0"
max="1"
value={config.temperature}
onChange={(e) => setConfig(prev => ({ ...prev, temperature: parseFloat(e.target.value) }))}
/>
</label>
</div>
<button onClick={handleUpdateConfig}>Update Configuration</button>
</div>
);
};
export default ChatbotConfigComponent;