fix: remove duplicate selected models
This commit is contained in:
@@ -89,13 +89,18 @@ const SelectWrapper = styled.div`
|
|||||||
}
|
}
|
||||||
.ant-select-placeholder {
|
.ant-select-placeholder {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 10px;
|
top: 1px;
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
}
|
}
|
||||||
.ant-select .ant-select-content {
|
.ant-select .ant-select-content {
|
||||||
padding-block: 0px 0;
|
padding-block: 0px 0;
|
||||||
}
|
}
|
||||||
|
.ant-select-auto-complete {
|
||||||
|
.ant-select-placeholder {
|
||||||
|
top: 1px;
|
||||||
|
}
|
||||||
|
}
|
||||||
.ant-select.ant-cascader {
|
.ant-select.ant-cascader {
|
||||||
.ant-select-placeholder {
|
.ant-select-placeholder {
|
||||||
top: 0px !important;
|
top: 0px !important;
|
||||||
|
|||||||
@@ -271,6 +271,12 @@ export const useCheckCompatibility = () => {
|
|||||||
|
|
||||||
let compatibilityMessage = compatibility_messages.join(' ');
|
let compatibilityMessage = compatibility_messages.join(' ');
|
||||||
|
|
||||||
|
compatibilityMessage = compatibilityMessage.startsWith(
|
||||||
|
`The model file path you specified does not exist on the GPUStack server. It's recommended`
|
||||||
|
)
|
||||||
|
? intl.formatMessage({ id: 'models.form.modelfile.notfound' })
|
||||||
|
: compatibilityMessage;
|
||||||
|
|
||||||
let msgData = {
|
let msgData = {
|
||||||
title: scheduling_messages?.length > 0 ? compatibilityMessage : '',
|
title: scheduling_messages?.length > 0 ? compatibilityMessage : '',
|
||||||
message:
|
message:
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
|
import IconFont from '@/components/icon-font';
|
||||||
import SealInput from '@/components/seal-form/seal-input';
|
import SealInput from '@/components/seal-form/seal-input';
|
||||||
import { PageActionType } from '@/config/types';
|
import { PageActionType } from '@/config/types';
|
||||||
import YamlEditor from '@/pages/_components/yaml-editor';
|
import YamlEditor from '@/pages/_components/yaml-editor';
|
||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
import { Form } from 'antd';
|
import { Button, Form } from 'antd';
|
||||||
import React, { forwardRef, useImperativeHandle } from 'react';
|
import React, { forwardRef, useImperativeHandle } from 'react';
|
||||||
import APIKeys from './api-keys';
|
import APIKeys from './api-keys';
|
||||||
import ProxyConfig from './proxy-config';
|
import ProxyConfig from './proxy-config';
|
||||||
|
|
||||||
|
const referLink = `https://higress.cn/docs/latest/plugins/ai/api-provider/ai-proxy/?spm=36971b57.3562eb7c.0.0.31764f5f7uLs2F#%E6%8F%90%E4%BE%9B%E5%95%86%E7%89%B9%E6%9C%89%E9%85%8D%E7%BD%AE`;
|
||||||
|
|
||||||
const AdvanceConfig: React.FC<{
|
const AdvanceConfig: React.FC<{
|
||||||
action: PageActionType;
|
action: PageActionType;
|
||||||
ref?: any;
|
ref?: any;
|
||||||
@@ -45,7 +48,18 @@ const AdvanceConfig: React.FC<{
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
<YamlEditor
|
<YamlEditor
|
||||||
ref={editorRef}
|
ref={editorRef}
|
||||||
title={`${intl.formatMessage({ id: 'providers.form.customConfig' })} (YAML)`}
|
title={
|
||||||
|
<span className="flex-center">
|
||||||
|
<span>{`${intl.formatMessage({ id: 'providers.form.customConfig' })} YAML`}</span>
|
||||||
|
<Button size="small" type="link" target="_blank" href={referLink}>
|
||||||
|
{intl.formatMessage({ id: 'playground.audio.enablemic.doc' })}{' '}
|
||||||
|
<IconFont
|
||||||
|
type="icon-external-link"
|
||||||
|
className="font-size-14"
|
||||||
|
></IconFont>
|
||||||
|
</Button>
|
||||||
|
</span>
|
||||||
|
}
|
||||||
value={fileContent}
|
value={fileContent}
|
||||||
height={300}
|
height={300}
|
||||||
onUpload={(content) => {
|
onUpload={(content) => {
|
||||||
|
|||||||
@@ -21,6 +21,13 @@ const Basic = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const filterOption = (input: string, option?: any) => {
|
||||||
|
return (
|
||||||
|
option?.label?.toLowerCase().includes(input.toLowerCase()) ||
|
||||||
|
option?.value?.toLowerCase().includes(input.toLowerCase())
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Form.Item<FormData> name="name" data-field="name">
|
<Form.Item<FormData> name="name" data-field="name">
|
||||||
@@ -38,19 +45,21 @@ const Basic = () => {
|
|||||||
required: true,
|
required: true,
|
||||||
message: getRuleMessage(
|
message: getRuleMessage(
|
||||||
'select',
|
'select',
|
||||||
intl.formatMessage({ id: 'providers.table.providerName' })
|
intl.formatMessage({ id: 'common.table.type' })
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<SealSelect
|
<SealSelect
|
||||||
showSearch
|
showSearch={{
|
||||||
|
filterOption: filterOption
|
||||||
|
}}
|
||||||
required
|
required
|
||||||
options={maasProviderOptions}
|
options={maasProviderOptions}
|
||||||
optionRender={optionRender}
|
optionRender={optionRender}
|
||||||
labelRender={optionRender}
|
labelRender={optionRender}
|
||||||
label={intl.formatMessage({
|
label={intl.formatMessage({
|
||||||
id: 'providers.table.providerName'
|
id: 'common.table.type'
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import AutoComplete from '@/components/seal-form/auto-complete';
|
||||||
import SealSelect from '@/components/seal-form/seal-select';
|
import SealSelect from '@/components/seal-form/seal-select';
|
||||||
import { categoryOptions } from '@/pages/llmodels/config';
|
import { categoryOptions } from '@/pages/llmodels/config';
|
||||||
import {
|
import {
|
||||||
@@ -28,7 +29,8 @@ const SelectWrapper = styled.div`
|
|||||||
interface ModelItemProps {
|
interface ModelItemProps {
|
||||||
onOpenChange: (open: boolean) => void;
|
onOpenChange: (open: boolean) => void;
|
||||||
onChange: (data: ProviderModel) => void;
|
onChange: (data: ProviderModel) => void;
|
||||||
providerModelList: ProviderModel[];
|
providerModelList: Global.BaseOption<string>[];
|
||||||
|
selectedModelList: ProviderModel[];
|
||||||
item: ProviderModel;
|
item: ProviderModel;
|
||||||
loading?: boolean;
|
loading?: boolean;
|
||||||
}
|
}
|
||||||
@@ -38,6 +40,7 @@ const ModelItem: React.FC<ModelItemProps> = ({
|
|||||||
onChange,
|
onChange,
|
||||||
loading,
|
loading,
|
||||||
providerModelList,
|
providerModelList,
|
||||||
|
selectedModelList,
|
||||||
item
|
item
|
||||||
}) => {
|
}) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
@@ -96,20 +99,30 @@ const ModelItem: React.FC<ModelItemProps> = ({
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// filter out already selected models, but keep the current one
|
||||||
|
const selectedModelMap = new Map(
|
||||||
|
selectedModelList?.map((model) => [model.name, true])
|
||||||
|
);
|
||||||
|
const filteredOptions = () => {
|
||||||
|
return providerModelList.filter((model) => {
|
||||||
|
return model.value === item.name || !selectedModelMap.has(model.value);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SelectWrapper>
|
<SelectWrapper>
|
||||||
<SealSelect
|
<AutoComplete
|
||||||
loading={loading}
|
loading={loading}
|
||||||
showSearch
|
showSearch
|
||||||
onOpenChange={onOpenChange}
|
onOpenChange={onOpenChange}
|
||||||
suffixIcon={renderSuffixIcon()}
|
suffixIcon={renderSuffixIcon()}
|
||||||
alwaysFocus={true}
|
|
||||||
value={item.name}
|
value={item.name}
|
||||||
onChange={handleOnChange}
|
onChange={handleOnChange}
|
||||||
options={providerModelList}
|
options={filteredOptions()}
|
||||||
|
placeholder={intl.formatMessage({ id: 'providers.table.models' })}
|
||||||
/>
|
/>
|
||||||
<SealSelect
|
<SealSelect
|
||||||
value={item.category}
|
value={item.category || undefined}
|
||||||
onChange={handleOnCategoryChange}
|
onChange={handleOnCategoryChange}
|
||||||
options={categoryOptions}
|
options={categoryOptions}
|
||||||
placeholder={intl.formatMessage({
|
placeholder={intl.formatMessage({
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ const SupportedModels = () => {
|
|||||||
{(item, index) => (
|
{(item, index) => (
|
||||||
<ModelItem
|
<ModelItem
|
||||||
key={index}
|
key={index}
|
||||||
|
selectedModelList={modelList}
|
||||||
onOpenChange={handleOpenChange}
|
onOpenChange={handleOpenChange}
|
||||||
onChange={(data) => onChange(data, index)}
|
onChange={(data) => onChange(data, index)}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
|
|||||||
@@ -33,11 +33,6 @@ interface TargetItemProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const childActionList = [
|
export const childActionList = [
|
||||||
// {
|
|
||||||
// key: 'fallback',
|
|
||||||
// label: 'routes.table.setAsFallback',
|
|
||||||
// icon: <IconFont type="icon-shield" />
|
|
||||||
// },
|
|
||||||
{
|
{
|
||||||
key: 'delete',
|
key: 'delete',
|
||||||
label: 'common.button.delete',
|
label: 'common.button.delete',
|
||||||
|
|||||||
Reference in New Issue
Block a user