jan/web/app/_hooks/useGetHuggingFaceModel.ts
James 6f50424917 allow user to query for HF models
Signed-off-by: James <james@jan.ai>
2023-10-06 16:46:47 +07:00

26 lines
726 B
TypeScript

import { useState } from "react";
import { searchHfModels } from "./useGetDownloadedModels";
import { SearchModelParamHf } from "@/_models/hf/SearchModelParam.hf";
import { Product } from "@/_models/Product";
export default function useGetHuggingFaceModel() {
const [modelList, setModelList] = useState<Product[]>([]);
const getHuggingFaceModel = async (owner?: string) => {
if (!owner) {
setModelList([]);
return;
}
const searchParams: SearchModelParamHf = {
search: { owner },
limit: 5,
};
const result = await searchHfModels(searchParams);
console.debug("result", JSON.stringify(result));
setModelList(result);
};
return { modelList, getHuggingFaceModel };
}