ollama / services /useApiService.ts
rippanteq7's picture
Upload folder using huggingface_hub
bbef364 verified
raw
history blame contribute delete
802 Bytes
import { useCallback } from 'react';
import { useFetch } from '@/hooks/useFetch';
import {OllamaModel, OllamaModelDetail} from '@/types/ollama'
const useApiService = () => {
const fetchService = useFetch();
const getModels = useCallback(
(): Promise<OllamaModel[]> => {
return fetchService.get(`/api/models`, {
headers: {
'Content-Type': 'application/json',
},
});
},
[fetchService],
);
const getModelDetails = useCallback(
(name: string) => {
return fetchService.post(`/api/modeldetails`, {
headers: {
'Content-Type': 'application/json',
},
body: {name: name },
});
},
[fetchService],
);
return {
getModels,
getModelDetails
};
};
export default useApiService;