chat client clean up and switch to llama.cpp with models folder network sharing
This commit is contained in:
24
packages/chat-client/src/hooks/useModels.js
Normal file
24
packages/chat-client/src/hooks/useModels.js
Normal file
@@ -0,0 +1,24 @@
|
||||
// hooks/useModels.js
|
||||
import { useState, useEffect } from 'react';
|
||||
import { fetchModels } from '../api/orchestration';
|
||||
import { FALLBACK_MODELS, DEFAULT_MODEL } from '../config/constants';
|
||||
|
||||
export function useModels() {
|
||||
const [models, setModels] = useState(FALLBACK_MODELS);
|
||||
const [selectedModel, setSelectedModel] = useState(DEFAULT_MODEL);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
fetchModels()
|
||||
.then(data => {
|
||||
setModels(data);
|
||||
setSelectedModel(data[0]?.value ?? DEFAULT_MODEL);
|
||||
})
|
||||
.catch(err => {
|
||||
console.warn('[useModels] Falling back to static list:', err.message);
|
||||
})
|
||||
.finally(() => setLoading(false));
|
||||
}, []);
|
||||
|
||||
return { models, selectedModel, setSelectedModel, loading };
|
||||
}
|
||||
Reference in New Issue
Block a user