style: playground collapse button
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { listFiles } from '@huggingface/hub';
|
||||
import { listFiles, listModels } from '@huggingface/hub';
|
||||
import { request } from '@umijs/max';
|
||||
import {
|
||||
FormData,
|
||||
@@ -116,6 +116,23 @@ export async function callHuggingfaceQuickSearch(params: any) {
|
||||
});
|
||||
}
|
||||
|
||||
export async function queryHuggingfaceModels(params: {
|
||||
search: {
|
||||
query: string;
|
||||
tags: string[];
|
||||
};
|
||||
}) {
|
||||
const result = [];
|
||||
for await (const model of listModels({
|
||||
...params,
|
||||
limit: 100,
|
||||
additionalFields: ['author']
|
||||
})) {
|
||||
result.push(model);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function queryHuggingfaceModelFiles(params: { repo: string }) {
|
||||
const result = [];
|
||||
for await (const fileInfo of listFiles(params)) {
|
||||
|
||||
@@ -10,10 +10,7 @@ import { useIntl } from '@umijs/max';
|
||||
import { Form, Input, Modal } from 'antd';
|
||||
import _ from 'lodash';
|
||||
import { memo, useEffect, useState } from 'react';
|
||||
import {
|
||||
callHuggingfaceQuickSearch,
|
||||
queryHuggingfaceModelFiles
|
||||
} from '../apis';
|
||||
import { queryHuggingfaceModelFiles, queryHuggingfaceModels } from '../apis';
|
||||
import { ollamaModelOptions } from '../config';
|
||||
import { FormData, ListItem } from '../config/types';
|
||||
|
||||
@@ -106,14 +103,17 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
const handleOnSearchRepo = async (text: string) => {
|
||||
try {
|
||||
const params = {
|
||||
q: `${text}`,
|
||||
type: 'model'
|
||||
search: {
|
||||
query: text,
|
||||
tags: ['gguf']
|
||||
}
|
||||
};
|
||||
const res = await callHuggingfaceQuickSearch(params);
|
||||
const list = _.map(res.models || [], (item: any) => {
|
||||
const models = await queryHuggingfaceModels(params);
|
||||
const list = _.map(models || [], (item: any) => {
|
||||
return {
|
||||
value: item.id,
|
||||
label: item.id
|
||||
...item,
|
||||
value: item.name,
|
||||
label: item.name
|
||||
};
|
||||
});
|
||||
setRepoOptions(list);
|
||||
|
||||
Reference in New Issue
Block a user