chore: hf api use proxy
This commit is contained in:
@@ -70,5 +70,5 @@ export default {
|
|||||||
'models.logs.pagination.prev': 'Previous {lines} Lines',
|
'models.logs.pagination.prev': 'Previous {lines} Lines',
|
||||||
'models.logs.pagination.next': 'Next {lines} Lines',
|
'models.logs.pagination.next': 'Next {lines} Lines',
|
||||||
'models.form.localPath': 'Local Path',
|
'models.form.localPath': 'Local Path',
|
||||||
'models.form.filePath': 'File Path'
|
'models.form.filePath': 'Model Path'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -68,5 +68,5 @@ export default {
|
|||||||
'models.logs.pagination.prev': '上一 {lines} 行',
|
'models.logs.pagination.prev': '上一 {lines} 行',
|
||||||
'models.logs.pagination.next': '下一 {lines} 行',
|
'models.logs.pagination.next': '下一 {lines} 行',
|
||||||
'models.form.localPath': '本地路径',
|
'models.form.localPath': '本地路径',
|
||||||
'models.form.filePath': '文件路径'
|
'models.form.filePath': '模型路径'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -113,19 +113,7 @@ export async function queryModelInstanceLogs(id: number) {
|
|||||||
|
|
||||||
// ===================== call huggingface quicksearch api =====================
|
// ===================== call huggingface quicksearch api =====================
|
||||||
|
|
||||||
export async function callHuggingfaceQuickSearch(params: any) {
|
const HUGGINGFACE_API = '/proxy?url=https://huggingface.co/api/models';
|
||||||
return request<{
|
|
||||||
models: Array<{
|
|
||||||
id: string;
|
|
||||||
_id: string;
|
|
||||||
}>;
|
|
||||||
}>(`https://huggingface.co/api/quicksearch`, {
|
|
||||||
method: 'GET',
|
|
||||||
params
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const HUGGINGFACE_API = 'https://huggingface.co/api/models';
|
|
||||||
|
|
||||||
const MODEL_SCOPE_LIST_MODEL_API =
|
const MODEL_SCOPE_LIST_MODEL_API =
|
||||||
'/proxy?url=https://www.modelscope.cn/api/v1/dolphin/models';
|
'/proxy?url=https://www.modelscope.cn/api/v1/dolphin/models';
|
||||||
@@ -221,6 +209,7 @@ export async function queryModelScopeModelFiles(
|
|||||||
return res.json();
|
return res.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// list models from huggingface
|
||||||
export async function queryHuggingfaceModels(
|
export async function queryHuggingfaceModels(
|
||||||
params: {
|
params: {
|
||||||
search: {
|
search: {
|
||||||
@@ -238,7 +227,8 @@ export async function queryHuggingfaceModels(
|
|||||||
...options,
|
...options,
|
||||||
limit: 100,
|
limit: 100,
|
||||||
additionalFields: ['sha', 'tags'],
|
additionalFields: ['sha', 'tags'],
|
||||||
fetch(url: string, config: any) {
|
fetch(_url: string, config: any) {
|
||||||
|
const url = `/proxy?url=${_url}`;
|
||||||
try {
|
try {
|
||||||
const newUrl = params.search.sort
|
const newUrl = params.search.sort
|
||||||
? `${url}&sort=${params.search.sort}`
|
? `${url}&sort=${params.search.sort}`
|
||||||
@@ -258,6 +248,7 @@ export async function queryHuggingfaceModels(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// list files from huggingface
|
||||||
export async function queryHuggingfaceModelFiles(
|
export async function queryHuggingfaceModelFiles(
|
||||||
params: { repo: string },
|
params: { repo: string },
|
||||||
options?: any
|
options?: any
|
||||||
@@ -268,7 +259,7 @@ export async function queryHuggingfaceModelFiles(
|
|||||||
recursive: true,
|
recursive: true,
|
||||||
fetch(url: string, config: any) {
|
fetch(url: string, config: any) {
|
||||||
try {
|
try {
|
||||||
return fetch(url, {
|
return fetch(`/proxy?url=${url}`, {
|
||||||
...config,
|
...config,
|
||||||
signal: options?.signal
|
signal: options?.signal
|
||||||
});
|
});
|
||||||
@@ -295,7 +286,7 @@ export async function downloadModelFile(
|
|||||||
revision: revision,
|
revision: revision,
|
||||||
path: path,
|
path: path,
|
||||||
fetch(url: string, config: any) {
|
fetch(url: string, config: any) {
|
||||||
return fetch(url, {
|
return fetch(`/proxy?url=${url}`, {
|
||||||
...config,
|
...config,
|
||||||
signal: options?.signal
|
signal: options?.signal
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -131,6 +131,15 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
|
|||||||
form.setFieldValue('backend_parameters', list);
|
form.setFieldValue('backend_parameters', list);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const handleBackendChange = useCallback((val: string) => {
|
||||||
|
if (val === backendOptionsMap.llamaBox) {
|
||||||
|
form.setFieldsValue({
|
||||||
|
distributed_inference_across_workers: true,
|
||||||
|
cpu_offloading: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
const collapseItems = useMemo(() => {
|
const collapseItems = useMemo(() => {
|
||||||
const children = (
|
const children = (
|
||||||
<>
|
<>
|
||||||
@@ -239,6 +248,7 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
|
|||||||
)}
|
)}
|
||||||
<Form.Item name="backend">
|
<Form.Item name="backend">
|
||||||
<SealSelect
|
<SealSelect
|
||||||
|
onChange={handleBackendChange}
|
||||||
label={intl.formatMessage({ id: 'models.form.backend' })}
|
label={intl.formatMessage({ id: 'models.form.backend' })}
|
||||||
options={[
|
options={[
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -289,31 +289,39 @@ const ModelCard: React.FC<{
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<Empty
|
<>
|
||||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
{!loading && (
|
||||||
style={{ marginBlock: 20 }}
|
<Empty
|
||||||
></Empty>
|
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||||
|
style={{ marginBlock: 20 }}
|
||||||
|
></Empty>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{!isGGUFModel && readmeText && (
|
{!isGGUFModel && (
|
||||||
<div>
|
<Spin spinning={loading}>
|
||||||
<TitleWrapper>
|
<div style={{ minHeight: 200 }}>
|
||||||
<div className="title">README.md</div>
|
{readmeText && (
|
||||||
</TitleWrapper>
|
<>
|
||||||
<div className="card-wrapper">
|
<TitleWrapper>
|
||||||
<Spin spinning={loading}>
|
<div className="title">README.md</div>
|
||||||
<MarkdownViewer
|
</TitleWrapper>
|
||||||
generateImgLink={
|
<div className="card-wrapper">
|
||||||
modelSource === modelSourceMap.modelscope_value
|
<MarkdownViewer
|
||||||
? generateModeScopeImgLink
|
generateImgLink={
|
||||||
: undefined
|
modelSource === modelSourceMap.modelscope_value
|
||||||
}
|
? generateModeScopeImgLink
|
||||||
content={readmeText}
|
: undefined
|
||||||
theme="light"
|
}
|
||||||
></MarkdownViewer>
|
content={readmeText}
|
||||||
</Spin>
|
theme="light"
|
||||||
|
></MarkdownViewer>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</Spin>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -461,10 +461,7 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
return `${modelSourceMap.huggingface}/${record.huggingface_repo_id}`;
|
return `${modelSourceMap.huggingface}/${record.huggingface_repo_id}`;
|
||||||
}
|
}
|
||||||
if (record.source === modelSourceMap.local_path_value) {
|
if (record.source === modelSourceMap.local_path_value) {
|
||||||
const localPath = _.startsWith(record.local_path, '/')
|
return `${record.local_path}`;
|
||||||
? record.local_path
|
|
||||||
: `/${record.local_path}`;
|
|
||||||
return `${modelSourceMap.local_path}${localPath}`;
|
|
||||||
}
|
}
|
||||||
if (record.source === modelSourceMap.ollama_library_value) {
|
if (record.source === modelSourceMap.ollama_library_value) {
|
||||||
return `${modelSourceMap.ollama_library}/${record.ollama_library_model_name}`;
|
return `${modelSourceMap.ollama_library}/${record.ollama_library_model_name}`;
|
||||||
|
|||||||
Reference in New Issue
Block a user