refactor(proxy): remove Codex Chat Completions API format support

Codex CLI only uses OpenAI Responses API. Remove unused Chat Completions
routes, handler, parser config, URL builder branches, frontend API format
selector, and stale i18n keys. Claude openai_chat support is preserved.
This commit is contained in:
YoVinchen
2026-02-12 23:00:46 +08:00
parent fad81d6fa4
commit c1048ebcbe
13 changed files with 17 additions and 283 deletions
@@ -2,22 +2,11 @@ import { useTranslation } from "react-i18next";
import EndpointSpeedTest from "./EndpointSpeedTest";
import { ApiKeySection, EndpointField } from "./shared";
import type { ProviderCategory } from "@/types";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { FormLabel } from "@/components/ui/form";
interface EndpointCandidate {
url: string;
}
// Codex API 格式类型
export type CodexApiFormat = "responses" | "chat";
interface CodexFormFieldsProps {
providerId?: string;
// API Key
@@ -46,11 +35,6 @@ interface CodexFormFieldsProps {
// Speed Test Endpoints
speedTestEndpoints: EndpointCandidate[];
// API Format (for Codex providers)
apiFormat?: CodexApiFormat;
onApiFormatChange?: (format: CodexApiFormat) => void;
shouldShowApiFormatSelector?: boolean;
}
export function CodexFormFields({
@@ -74,21 +58,9 @@ export function CodexFormFields({
modelName = "",
onModelNameChange,
speedTestEndpoints,
apiFormat = "responses",
onApiFormatChange,
shouldShowApiFormatSelector = false,
}: CodexFormFieldsProps) {
const { t } = useTranslation();
// 根据 API 格式选择提示文本
const apiHint =
apiFormat === "chat"
? t("providerForm.codexApiHintChat", {
defaultValue:
"💡 填写兼容 OpenAI Chat Completions 格式的服务端点地址",
})
: t("providerForm.codexApiHint");
return (
<>
{/* Codex API Key 输入框 */}
@@ -112,37 +84,6 @@ export function CodexFormFields({
}}
/>
{/* API 格式选择器 */}
{shouldShowApiFormatSelector && onApiFormatChange && (
<div className="space-y-2">
<FormLabel htmlFor="codexApiFormat">
{t("providerForm.apiFormat", { defaultValue: "API 格式" })}
</FormLabel>
<Select value={apiFormat} onValueChange={onApiFormatChange}>
<SelectTrigger id="codexApiFormat" className="w-full">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="responses">
{t("providerForm.codexApiFormatResponses", {
defaultValue: "OpenAI Responses (默认)",
})}
</SelectItem>
<SelectItem value="chat">
{t("providerForm.codexApiFormatChat", {
defaultValue: "OpenAI Chat Completions",
})}
</SelectItem>
</SelectContent>
</Select>
<p className="text-xs text-muted-foreground">
{t("providerForm.codexApiFormatHint", {
defaultValue: "选择供应商支持的 API 格式",
})}
</p>
</div>
)}
{/* Codex Base URL 输入框 */}
{shouldShowSpeedTest && (
<EndpointField
@@ -151,10 +92,10 @@ export function CodexFormFields({
value={codexBaseUrl}
onChange={onBaseUrlChange}
placeholder={t("providerForm.codexApiEndpointPlaceholder")}
hint={apiHint}
hint={t("providerForm.codexApiHint")}
onManageClick={() => onEndpointModalToggle(true)}
appType="codex"
apiFormat={apiFormat}
apiFormat="responses"
/>
)}
@@ -37,7 +37,6 @@ import { OpenCodeFormFields } from "./OpenCodeFormFields";
import type { UniversalProviderPreset } from "@/config/universalProviderPresets";
import {
applyTemplateValues,
extractCodexWireApi,
setCodexWireApi,
} from "@/utils/providerConfigUtils";
import { mergeProviderMeta } from "@/utils/providerMetaUtils";
@@ -50,7 +49,7 @@ import { Label } from "@/components/ui/label";
import { ProviderPresetSelector } from "./ProviderPresetSelector";
import { BasicFormFields } from "./BasicFormFields";
import { ClaudeFormFields } from "./ClaudeFormFields";
import { CodexFormFields, type CodexApiFormat } from "./CodexFormFields";
import { CodexFormFields } from "./CodexFormFields";
import { GeminiFormFields } from "./GeminiFormFields";
import { OmoFormFields } from "./OmoFormFields";
import { type OmoGlobalConfigFieldsRef } from "./OmoGlobalConfigFields";
@@ -369,19 +368,6 @@ export function ProviderForm({
: "anthropic";
});
const [localCodexApiFormat, setLocalCodexApiFormat] =
useState<CodexApiFormat>(() => {
if (appId !== "codex") return "responses";
if (initialData?.meta?.apiFormat === "chat") return "chat";
if (initialData?.meta?.apiFormat === "responses") return "responses";
const initialConfig = initialData?.settingsConfig?.config;
if (typeof initialConfig === "string") {
return extractCodexWireApi(initialConfig) ?? "responses";
}
return "responses";
});
const {
codexAuth,
codexConfig,
@@ -390,7 +376,6 @@ export function ProviderForm({
codexModelName,
codexAuthError,
setCodexAuth,
setCodexConfig,
handleCodexApiKeyChange,
handleCodexBaseUrlChange,
handleCodexModelNameChange,
@@ -413,14 +398,6 @@ export function ProviderForm({
setLocalClaudeApiFormat(format);
}, []);
const handleCodexApiFormatChange = useCallback(
(format: CodexApiFormat) => {
setLocalCodexApiFormat(format);
setCodexConfig((prev) => setCodexWireApi(prev, format));
},
[setCodexConfig],
);
useEffect(() => {
if (appId === "codex" && !initialData && selectedPresetId === "custom") {
const template = getCodexCustomTemplate();
@@ -1078,7 +1055,7 @@ export function ProviderForm({
const authJson = JSON.parse(codexAuth);
const configObj = {
auth: authJson,
config: codexConfig ?? "",
config: setCodexWireApi(codexConfig ?? "", "responses"),
};
settingsConfig = JSON.stringify(configObj);
} catch (err) {
@@ -1198,9 +1175,7 @@ export function ProviderForm({
const providerApiFormat =
appId === "claude" && category !== "official"
? localClaudeApiFormat
: appId === "codex" && category !== "official"
? localCodexApiFormat
: undefined;
: undefined;
const baseMeta: ProviderMeta | undefined =
payload.meta ?? (initialData?.meta ? { ...initialData.meta } : undefined);
@@ -1310,9 +1285,6 @@ export function ProviderForm({
if (appId === "codex") {
const template = getCodexCustomTemplate();
setLocalCodexApiFormat(
extractCodexWireApi(template.config) ?? "responses",
);
resetCodexConfig(template.auth, template.config);
}
if (appId === "gemini") {
@@ -1347,7 +1319,6 @@ export function ProviderForm({
const auth = preset.auth ?? {};
const config = preset.config ?? "";
setLocalCodexApiFormat(extractCodexWireApi(config) ?? "responses");
resetCodexConfig(auth, config);
form.reset({
@@ -1584,9 +1555,6 @@ export function ProviderForm({
modelName={codexModelName}
onModelNameChange={handleCodexModelNameChange}
speedTestEndpoints={speedTestEndpoints}
apiFormat={localCodexApiFormat}
onApiFormatChange={handleCodexApiFormatChange}
shouldShowApiFormatSelector={category !== "official"}
/>
)}