fix: get models in cloning

This commit is contained in:
jialin
2026-02-10 10:25:02 +08:00
parent ba11689029
commit 8779b79bbf
5 changed files with 34 additions and 18 deletions
@@ -39,10 +39,16 @@ const ActiveTable = () => {
ellipsis: true, ellipsis: true,
render: (text: any, record: any) => { render: (text: any, record: any) => {
return ( return (
<AutoTooltip ghost> <>
{convertFileSize(record.resource_claim?.vram || 0)} /{' '} {record.provider_name ? (
{convertFileSize(record.resource_claim?.ram || 0)} <span>N/A</span>
</AutoTooltip> ) : (
<AutoTooltip ghost>
{convertFileSize(record.resource_claim?.vram || 0)} /{' '}
{convertFileSize(record.resource_claim?.ram || 0)}
</AutoTooltip>
)}
</>
); );
} }
}, },
@@ -58,6 +64,9 @@ const ActiveTable = () => {
ellipsis: true, ellipsis: true,
render: (text: any, record: any) => { render: (text: any, record: any) => {
let val = text; let val = text;
if (record.provider_name) {
return <span>N/A</span>;
}
if (!text) { if (!text) {
val = !NACategories.includes(record.categories?.[0]) ? 'N/A' : 0; val = !NACategories.includes(record.categories?.[0]) ? 'N/A' : 0;
} }
@@ -147,7 +147,11 @@ export default function useAddResource(options?: { onCreated?: () => void }) {
}} }}
onCancel={handleCancel} onCancel={handleCancel}
> >
<Content> <Content
style={{
marginTop: !resourceCount.cluster_count ? 32 : 16
}}
>
<div className="icon"> <div className="icon">
<IconFont type="icon-dashboard" /> <IconFont type="icon-dashboard" />
</div> </div>
@@ -59,7 +59,6 @@ import {
ModelInstanceListItem, ModelInstanceListItem,
SourceType SourceType
} from '../config/types'; } from '../config/types';
import Filters from '../filters';
import useEditDeployment from '../hooks/use-edit-deployment'; import useEditDeployment from '../hooks/use-edit-deployment';
import useFilterStatus from '../hooks/use-filter-status'; import useFilterStatus from '../hooks/use-filter-status';
import useFormInitialValues from '../hooks/use-form-initial-values'; import useFormInitialValues from '../hooks/use-form-initial-values';
@@ -650,15 +649,6 @@ const Models: React.FC<ModelsProps> = ({
options={statusOptions} options={statusOptions}
onChange={handleStatusChange} onChange={handleStatusChange}
></BaseSelect> ></BaseSelect>
<Filters
initialValues={{
cluster_id: undefined,
state: undefined,
categories: undefined
}}
clusterList={clusterList}
onValuesChange={onFilterChange}
></Filters>
<Button <Button
type="text" type="text"
style={{ color: 'var(--ant-color-text-tertiary)' }} style={{ color: 'var(--ant-color-text-tertiary)' }}
+8 -2
View File
@@ -67,9 +67,16 @@ const ModelItem: React.FC<ModelItemProps> = ({
return currentAPIKey; return currentAPIKey;
}; };
const generateID = () => {
if (action === PageAction.EDIT || action === PageAction.COPY) {
return id!;
}
return 0;
};
const handleTestModel = async () => { const handleTestModel = async () => {
const res = await runTestModel({ const res = await runTestModel({
id: action === PageAction.EDIT ? id! : 0, id: generateID(),
data: { data: {
model_name: item.name, model_name: item.name,
api_token: generateCurrentAPIKey( api_token: generateCurrentAPIKey(
@@ -88,7 +95,6 @@ const ModelItem: React.FC<ModelItemProps> = ({
}; };
const handleOnChange = (value: string, option: any) => { const handleOnChange = (value: string, option: any) => {
console.log('selected model', value, option);
onChange({ onChange({
...option, ...option,
name: value name: value
@@ -29,6 +29,13 @@ const SupportedModels = () => {
return currentAPIKey; return currentAPIKey;
}; };
const generateID = () => {
if (action === PageAction.EDIT || action === PageAction.COPY) {
return id!;
}
return 0;
};
const handleOpenChange = async (open: boolean) => { const handleOpenChange = async (open: boolean) => {
try { try {
await form.validateFields(['api_key', ['config', 'type']]); await form.validateFields(['api_key', ['config', 'type']]);
@@ -39,7 +46,7 @@ const SupportedModels = () => {
if (open && prevAPIKeyRef.current !== currentAPIKey && currentAPIKey) { if (open && prevAPIKeyRef.current !== currentAPIKey && currentAPIKey) {
prevAPIKeyRef.current = currentAPIKey; prevAPIKeyRef.current = currentAPIKey;
fetchProviderModels({ fetchProviderModels({
id: action === PageAction.EDIT ? id! : 0, id: generateID(),
data: { data: {
api_token: generateCurrentAPIKey(currentAPIKey) as string, api_token: generateCurrentAPIKey(currentAPIKey) as string,
proxy_url: form.getFieldValue('proxy_url') || undefined, proxy_url: form.getFieldValue('proxy_url') || undefined,