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