|
1 | | -import { useState, useEffect, useCallback, useRef } from 'react'; |
| 1 | +import { useState, useEffect, useCallback, useMemo, useRef } from 'react'; |
2 | 2 | import { EmbeddingMismatchWarning } from '@/components/ui/EmbeddingMismatchWarning'; |
3 | 3 | import { LiveTerminal, LiveTerminalHandle } from '@/components/LiveTerminal/LiveTerminal'; |
4 | 4 | import { CollapsibleSection } from '@/components/ui/CollapsibleSection'; |
@@ -150,17 +150,30 @@ export function RetrievalSubtab() { |
150 | 150 | } = useConfig(); |
151 | 151 |
|
152 | 152 | // --- Derived helpers ----------------------------------------------------- |
| 153 | + const ragweldGenModelOption = useMemo(() => { |
| 154 | + const base = String(config?.training?.ragweld_agent_base_model || 'mlx-community/Qwen3-1.7B-4bit').trim(); |
| 155 | + if (!base) return ''; |
| 156 | + return `ragweld:${base}`; |
| 157 | + }, [config?.training?.ragweld_agent_base_model]); |
| 158 | + |
153 | 159 | const loadModels = useCallback(async () => { |
| 160 | + let models: string[] = []; |
154 | 161 | try { |
155 | 162 | const data = await modelsApi.listByType('GEN'); |
156 | | - const models = Array.isArray(data) ? data.map((m: any) => m.model).filter(Boolean) : []; |
157 | | - if (models.length) { |
158 | | - setAvailableModels(models); |
159 | | - } |
| 163 | + models = Array.isArray(data) ? data.map((m: any) => m.model).filter(Boolean) : []; |
160 | 164 | } catch (error) { |
161 | 165 | console.error('Failed to load models from /api/models/by-type/GEN:', error); |
162 | 166 | } |
163 | | - }, []); |
| 167 | + |
| 168 | + const merged: string[] = []; |
| 169 | + if (ragweldGenModelOption) merged.push(ragweldGenModelOption); |
| 170 | + for (const m of models) { |
| 171 | + if (!m) continue; |
| 172 | + if (merged.includes(m)) continue; |
| 173 | + merged.push(m); |
| 174 | + } |
| 175 | + setAvailableModels(merged); |
| 176 | + }, [ragweldGenModelOption]); |
164 | 177 |
|
165 | 178 | useEffect(() => { |
166 | 179 | loadModels(); |
|
0 commit comments