fix: access source error

This commit is contained in:
jialin
2026-02-03 18:21:08 +08:00
parent 497813eced
commit 6d65797b4f
8 changed files with 67 additions and 61 deletions
+1 -8
View File
@@ -17,14 +17,7 @@ const CategorySelect = (props: any) => {
</span>
);
};
return (
<SealSelect
options={options}
optionRenderer={optionRenderer}
labelRender={optionRenderer}
{...rest}
/>
);
return <SealSelect options={options} {...rest} />;
};
export default CategorySelect;
+5 -5
View File
@@ -59,11 +59,11 @@ export const ActionList: ActionItem[] = [
key: 'api',
icon: icons.ApiOutlined
},
{
label: 'models.button.accessSettings',
key: 'accessControl',
icon: icons.Permission
},
// {
// label: 'models.button.accessSettings',
// key: 'accessControl',
// icon: icons.Permission
// },
{
label: 'common.button.stop',
key: 'stop',
+1
View File
@@ -430,6 +430,7 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
restart_on_error: true,
distributed_inference_across_workers: true,
mode: 'throughput',
enable_model_access: true,
generic_proxy: false,
extended_kv_cache: {
enabled: false,
+3 -3
View File
@@ -146,15 +146,15 @@ const UserModels: React.FC = () => {
};
const getStatus = useCallback((model: any) => {
if (!model.replicas && !model.ready_replicas) {
if (!model.replicas && !model.ready_endpoints) {
return MyModelsStatusValueMap.Inactive;
}
if (model.replicas > 0 && !model.ready_replicas) {
if (model.replicas > 0 && !model.ready_endpoints) {
return MyModelsStatusValueMap.Degrade;
}
if (model.ready_replicas > 0 && model.replicas > 0) {
if (model.ready_endpoints > 0 && model.replicas > 0) {
return MyModelsStatusValueMap.Active;
}
return MyModelsStatusValueMap.Degrade;
@@ -30,11 +30,6 @@ interface AccessItemProps {
}
export const childActionList = [
{
key: 'viewlog',
label: 'common.button.viewlog',
icon: <IconFont type="icon-logs" />
},
{
key: 'fallback',
label: 'accesses.table.setAsFallback',
@@ -58,30 +53,34 @@ const AccessItem: React.FC<AccessItemProps> = ({
const intl = useIntl();
const renderProviderSource = () => {
const model = sourceModels.find(
(item: any) => item.value === data.provider_id || item.id === data.model
);
return model.label || '-';
const model = sourceModels.find((item: any) => {
if (data.model_id) {
return item.value === 'deployments';
}
return item.value === data.provider_id;
});
console.log('renderProviderSource model:', data, sourceModels);
return model?.label || '-';
};
return (
<div style={{ borderRadius: 'var(--ant-table-header-border-radius)' }}>
<RowChildren>
<Row gutter={16} style={{ width: '100%' }}>
<Col span={4}>
<Col span={5}>
<CellContent
style={{
paddingInline: 'var(--ant-table-cell-padding-inline)'
}}
>
<AutoTooltip ghost>{data.provider_model_name}</AutoTooltip>
<AutoTooltip ghost>{data.name}</AutoTooltip>
</CellContent>
</Col>
<Col span={3}>
<Col span={4} style={{ paddingLeft: 56 }}>
<CellContent>{renderProviderSource()}</CellContent>
</Col>
<Col span={4}>
<Col span={3}>
<CellContent>
{data.weight && (
{data.weight > 0 && (
<AutoTooltip ghost>
{intl.formatMessage({ id: 'accesses.form.endpoint.weight' })}:{' '}
{data.weight}
@@ -91,7 +90,9 @@ const AccessItem: React.FC<AccessItemProps> = ({
{data.fallback_status_codes &&
data.fallback_status_codes?.length > 0 && (
<>
<span style={{ marginInline: 8 }}>/</span>
{data.weight > 0 && (
<span style={{ marginInline: 8 }}>/</span>
)}
<span>
{intl.formatMessage({
id: 'accesses.table.label.fallback'
@@ -101,7 +102,7 @@ const AccessItem: React.FC<AccessItemProps> = ({
)}
</CellContent>
</Col>
<Col span={4}>
<Col span={3}>
<CellContent>
<AutoTooltip ghost>
<StatusTag
+3 -3
View File
@@ -4,17 +4,17 @@ import { StatusType } from '@/config/types';
export const EndpointsStatusValueMap: Record<string, string> = {
Active: 'active',
Inactive: 'inactive'
Unavailable: 'unavailable'
};
export const EndpointStatusLabelMap = {
[EndpointsStatusValueMap.Active]: 'Active',
[EndpointsStatusValueMap.Inactive]: 'Inactive'
[EndpointsStatusValueMap.Unavailable]: 'Unavailable'
};
export const EndpointStatus: Record<string, StatusType> = {
[EndpointsStatusValueMap.Active]: StatusMaps.success,
[EndpointsStatusValueMap.Inactive]: StatusMaps.error
[EndpointsStatusValueMap.Unavailable]: StatusMaps.error
};
// actions for each row
+31 -25
View File
@@ -63,35 +63,41 @@ const AccessForm: React.FC<ProviderFormProps> = forwardRef((props, ref) => {
const formatEndpoints = (values: FormData) => {
console.log('formatEndpoints values:', values);
let endPoints = [...values.endpoints];
let endPoints = [...(values.endpoints || [])];
let fallbackEndpoint = values.fallback_endpoint;
if (fallbackEndpoint && endPoints.length > 0) {
endPoints = endPoints?.map((ep) => {
if (ep.model_id === fallbackEndpoint.model_id && ep.model_id) {
return {
...ep,
fallback_status_codes: ['4xx', '5xx']
};
if (fallbackEndpoint) {
const exsitinged = endPoints.find((ep) => {
if (fallbackEndpoint!.model_id) {
return ep.model_id === fallbackEndpoint!.model_id;
}
if (
ep.provider_id === fallbackEndpoint.provider_id &&
ep.provider_model_name === fallbackEndpoint.provider_model_name &&
!fallbackEndpoint.model_id
) {
return {
...ep,
fallback_status_codes: ['4xx', '5xx']
};
}
return ep;
});
} else if (fallbackEndpoint) {
endPoints.push({
...fallbackEndpoint,
weight: null,
fallback_status_codes: ['4xx', '5xx']
return (
ep.provider_id === fallbackEndpoint!.provider_id &&
ep.provider_model_name === fallbackEndpoint!.provider_model_name
);
});
if (exsitinged) {
endPoints = endPoints.map((ep) => {
if (
ep.model_id === fallbackEndpoint.model_id ||
ep.provider_model_name === fallbackEndpoint.provider_model_name
) {
return {
...ep,
fallback_status_codes: ['4xx', '5xx']
};
}
return ep;
});
}
if (!exsitinged) {
endPoints.push({
...fallbackEndpoint,
weight: 0,
fallback_status_codes: ['4xx', '5xx']
});
}
}
return endPoints;
+6 -1
View File
@@ -200,6 +200,10 @@ const Accesses: React.FC = () => {
);
};
const setDisableExpand = (record: any) => {
return !record?.endpoints;
};
useEffect(() => {
fetchSourceModels();
}, []);
@@ -223,7 +227,8 @@ const Accesses: React.FC = () => {
></FilterBar>
<TableContext.Provider
value={{
allChildren: allAccessPoints
allChildren: allAccessPoints,
setDisableExpand: setDisableExpand
}}
>
<SealTable