mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-01 17:00:21 +08:00
fix: Codex 端点 URL 使用 /responses 而非 /v1/responses
Codex OAuth 端点(chatgpt.com/backend-api/codex)不走标准 /v1 前缀,之前 build_provider_url() 统一使用 /v1/responses 导致 404 错误。 修改内容: - transport.py: build_provider_url() 对 Codex URL 做特判,使用 /responses - EndpointFormDialog.vue: placeholder 对 Codex 端点显示正确路径 - guide-config.ts: 文档说明两种路径格式
This commit is contained in:
@@ -95,7 +95,7 @@
|
||||
<Label class="text-xs text-muted-foreground">自定义路径</Label>
|
||||
<Input
|
||||
:model-value="getEndpointEditState(endpoint.id)?.path ?? (endpoint.custom_path || '')"
|
||||
:placeholder="getDefaultPath(endpoint.api_format) || '留空使用默认'"
|
||||
:placeholder="getDefaultPath(endpoint.api_format, endpoint.base_url) || '留空使用默认'"
|
||||
:disabled="isFixedProvider"
|
||||
@update:model-value="(v) => updateEndpointField(endpoint.id, 'path', v)"
|
||||
/>
|
||||
@@ -673,9 +673,20 @@ const deleteConfirmDescription = computed(() => {
|
||||
})
|
||||
|
||||
// 获取指定 API 格式的默认路径
|
||||
function getDefaultPath(apiFormat: string): string {
|
||||
function getDefaultPath(apiFormat: string, baseUrl?: string): string {
|
||||
const format = apiFormats.value.find(f => f.value === apiFormat)
|
||||
return format?.default_path || ''
|
||||
const defaultPath = format?.default_path || ''
|
||||
// Codex 端点使用 /responses 而非 /v1/responses
|
||||
if (apiFormat === 'openai:cli' && baseUrl && isCodexUrl(baseUrl)) {
|
||||
return '/responses'
|
||||
}
|
||||
return defaultPath
|
||||
}
|
||||
|
||||
// 判断是否是 Codex OAuth 端点
|
||||
function isCodexUrl(baseUrl: string): boolean {
|
||||
const url = baseUrl.replace(/\/+$/, '')
|
||||
return url.includes('/backend-api/codex') || url.endsWith('/codex')
|
||||
}
|
||||
|
||||
// 初始化端点的编辑状态
|
||||
@@ -1183,7 +1194,9 @@ function hasValidationErrorsForEndpoint(endpointId: string): boolean {
|
||||
|
||||
// 新端点选择的格式的默认路径
|
||||
const newEndpointDefaultPath = computed(() => {
|
||||
return getDefaultPath(newEndpoint.value.api_format)
|
||||
// 使用填写的 base_url 或 provider 的 website 来判断是否是 Codex 端点
|
||||
const baseUrl = newEndpoint.value.base_url || props.provider?.website || ''
|
||||
return getDefaultPath(newEndpoint.value.api_format, baseUrl)
|
||||
})
|
||||
|
||||
// 加载 API 格式列表
|
||||
|
||||
@@ -118,7 +118,7 @@ export const apiFormats = [
|
||||
},
|
||||
{
|
||||
name: 'OpenAI CLI',
|
||||
endpoint: '/v1/responses',
|
||||
endpoint: '/v1/responses (Codex: /responses)',
|
||||
auth: 'Authorization: Bearer xxx',
|
||||
clients: ['Codex CLI']
|
||||
},
|
||||
|
||||
@@ -146,6 +146,10 @@ def build_provider_url(
|
||||
else:
|
||||
# 使用 API 格式的默认路径
|
||||
path = _resolve_default_path(endpoint_sig)
|
||||
# Codex OAuth 端点(chatgpt.com/backend-api/codex)使用 /responses 而非 /v1/responses
|
||||
base_url = getattr(endpoint, "base_url", "") or ""
|
||||
if endpoint_sig == "openai:cli" and _is_codex_url(base_url):
|
||||
path = "/responses"
|
||||
if effective_path_params:
|
||||
try:
|
||||
path = path.format(**effective_path_params)
|
||||
@@ -191,6 +195,15 @@ def _resolve_default_path(endpoint_sig: str | None) -> str:
|
||||
return "/"
|
||||
|
||||
|
||||
def _is_codex_url(base_url: str) -> bool:
|
||||
"""判断是否是 Codex OAuth 端点(如 chatgpt.com/backend-api/codex)。
|
||||
|
||||
Codex 端点不走标准 /v1 前缀,直接使用 /responses。
|
||||
"""
|
||||
url = base_url.rstrip("/")
|
||||
return "/backend-api/codex" in url or url.endswith("/codex")
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# Vertex AI 配置
|
||||
# ==============================================================================
|
||||
|
||||
Reference in New Issue
Block a user