Spaces:
Paused
Paused
Update frontend/src/components/ModelSelector.tsx
Browse files
frontend/src/components/ModelSelector.tsx
CHANGED
|
@@ -1,21 +1,22 @@
|
|
| 1 |
import React, { useState, useEffect } from 'react';
|
| 2 |
import axios from 'axios';
|
| 3 |
|
| 4 |
-
const ModelSelector: React.FC = () => {
|
| 5 |
-
const [models, setModels] = useState([]);
|
| 6 |
-
const [selected, setSelected] = useState('groq-mixtral-8x7b-32768');
|
| 7 |
|
| 8 |
useEffect(() => {
|
| 9 |
-
axios.get('/api/models')
|
|
|
|
|
|
|
| 10 |
}, []);
|
| 11 |
|
| 12 |
return (
|
| 13 |
<select
|
| 14 |
-
style={{ width: '100%', marginBottom: 8 }}
|
| 15 |
-
value={
|
| 16 |
-
onChange={e =>
|
| 17 |
>
|
| 18 |
-
{models.map(m => (
|
| 19 |
<option key={m.id} value={m.id}>{m.name}</option>
|
| 20 |
))}
|
| 21 |
</select>
|
|
|
|
| 1 |
import React, { useState, useEffect } from 'react';
|
| 2 |
import axios from 'axios';
|
| 3 |
|
| 4 |
+
const ModelSelector: React.FC<{ selectedModel: string; onModelChange: (model: string) => void }> = ({ selectedModel, onModelChange }) => {
|
| 5 |
+
const [models, setModels] = useState<any[]>([]);
|
|
|
|
| 6 |
|
| 7 |
useEffect(() => {
|
| 8 |
+
axios.get('/api/models')
|
| 9 |
+
.then(res => setModels(res.data))
|
| 10 |
+
.catch(() => setModels([]));
|
| 11 |
}, []);
|
| 12 |
|
| 13 |
return (
|
| 14 |
<select
|
| 15 |
+
style={{ width: '100%', marginBottom: 8, background: '#2d2d2d', color: 'white', border: '1px solid #444', padding: '4px 8px', borderRadius: 4 }}
|
| 16 |
+
value={selectedModel}
|
| 17 |
+
onChange={e => onModelChange(e.target.value)}
|
| 18 |
>
|
| 19 |
+
{models.map((m: any) => (
|
| 20 |
<option key={m.id} value={m.id}>{m.name}</option>
|
| 21 |
))}
|
| 22 |
</select>
|