feat: 支持 Completions/Responses 双协议,并在同选型下续链加速

This commit is contained in:
2026-09-24 17:10:34 +08:00
parent 9c2c1ed061
commit d20c6a1302
26 changed files with 533 additions and 43 deletions
+9 -1
View File
@@ -53,6 +53,8 @@ export namespace AgentVO {
configured: boolean;
baseUrl?: string | null;
displayName?: string | null;
/** auto | completions | responses */
apiStyle?: string | null;
apiKeyMasked?: string | null;
models?: LlmModelItem[];
updateTime?: string;
@@ -140,6 +142,7 @@ export async function createAgentLlmProviderApi(body: {
baseUrl: string;
apiKey: string;
displayName?: string;
apiStyle?: string;
}) {
return requestClient.post<AgentVO.LlmProvider>(
'/company/agent-llm-providers',
@@ -149,7 +152,12 @@ export async function createAgentLlmProviderApi(body: {
export async function updateAgentLlmProviderApi(
providerId: number,
body: { baseUrl?: string; apiKey?: string; displayName?: string },
body: {
baseUrl?: string;
apiKey?: string;
displayName?: string;
apiStyle?: string;
},
) {
return requestClient.put<AgentVO.LlmProvider>(
`/company/agent-llm-providers/${providerId}`,
@@ -10,6 +10,7 @@ import {
FormItem,
Input,
InputPassword,
Select,
message,
} from 'ant-design-vue';
@@ -28,8 +29,18 @@ const form = ref({
baseUrl: '',
apiKey: '',
displayName: '',
apiStyle: 'auto',
});
const apiStyleOptions = [
{
value: 'auto',
label: '自动(官方 OpenAI → Responses,其余 Completions)',
},
{ value: 'completions', label: 'Chat Completions' },
{ value: 'responses', label: 'Responses API' },
];
const isEdit = computed(() => !!editing.value);
const modalTitle = computed(() =>
isEdit.value ? '编辑提供商' : '添加提供商',
@@ -52,7 +63,8 @@ function open(row?: AgentVO.LlmProvider) {
baseUrl: row?.baseUrl || '',
apiKey: '',
displayName: row?.displayName || '',
};
apiStyle: row?.apiStyle || 'auto',
};
modalApi.setState({ title: modalTitle.value });
modalApi.open();
}
@@ -74,6 +86,7 @@ async function handleSubmit() {
baseUrl: form.value.baseUrl.trim(),
apiKey: form.value.apiKey.trim() || undefined,
displayName: form.value.displayName.trim(),
apiStyle: form.value.apiStyle,
});
message.success('已保存');
} else {
@@ -81,6 +94,7 @@ async function handleSubmit() {
baseUrl: form.value.baseUrl.trim(),
apiKey: form.value.apiKey.trim(),
displayName: form.value.displayName.trim() || undefined,
apiStyle: form.value.apiStyle,
});
message.success('已创建');
}
@@ -116,6 +130,13 @@ defineExpose({ open });
>
<InputPassword v-model:value="form.apiKey" placeholder="sk-..." />
</FormItem>
<FormItem label="API 协议">
<Select
v-model:value="form.apiStyle"
:options="apiStyleOptions"
class="w-full"
/>
</FormItem>
<FormItem label="备注(可选)">
<Input v-model:value="form.displayName" placeholder="如 DeepSeek" />
</FormItem>
@@ -65,6 +65,19 @@ const baseColumns: VxeGridProps<ProviderRow>['columns'] = [
minWidth: 220,
showOverflow: 'tooltip',
},
{
field: 'apiStyle',
title: 'API 协议',
minWidth: 120,
formatter: ({ row }) => {
const m: Record<string, string> = {
auto: '自动',
completions: 'Completions',
responses: 'Responses',
};
return m[row.apiStyle || 'auto'] || row.apiStyle || '自动';
},
},
{
field: 'apiKeyMasked',
title: 'API Key',