From 0cb89c8f67742666cdc76343009508d06bfb6bab Mon Sep 17 00:00:00 2001 From: Jason Date: Sat, 30 Aug 2025 23:02:49 +0800 Subject: [PATCH] =?UTF-8?q?chore(codex):=20=E8=B0=83=E6=95=B4=20Codex=20?= =?UTF-8?q?=E9=A2=84=E8=AE=BE=E6=A8=A1=E6=9D=BF=E4=B8=8E=E5=8D=A0=E4=BD=8D?= =?UTF-8?q?=E7=AC=A6=EF=BC=88auth.json/config.toml=20=E4=B8=8E=E8=A1=A8?= =?UTF-8?q?=E5=8D=95=E5=8D=A0=E4=BD=8D=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ProviderForm.tsx | 23 +++++++++++------------ src/config/codexProviderPresets.ts | 24 +++++++++++++++++------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/components/ProviderForm.tsx b/src/components/ProviderForm.tsx index 3d499cf..9799977 100644 --- a/src/components/ProviderForm.tsx +++ b/src/components/ProviderForm.tsx @@ -48,7 +48,7 @@ const ProviderForm: React.FC = ({ const [codexConfig, setCodexConfig] = useState(""); const [codexApiKey, setCodexApiKey] = useState(""); const [selectedCodexPreset, setSelectedCodexPreset] = useState( - null, + null ); // 初始化 Codex 配置 @@ -134,7 +134,7 @@ const ProviderForm: React.FC = ({ }; const handleChange = ( - e: React.ChangeEvent, + e: React.ChangeEvent ) => { const { name, value } = e.target; @@ -171,7 +171,7 @@ const ProviderForm: React.FC = ({ // 更新JSON配置 const updatedConfig = updateCoAuthoredSetting( formData.settingsConfig, - checked, + checked ); setFormData({ ...formData, @@ -202,7 +202,7 @@ const ProviderForm: React.FC = ({ // Codex: 应用预设 const applyCodexPreset = ( preset: (typeof codexProviderPresets)[0], - index: number, + index: number ) => { const authString = JSON.stringify(preset.auth || {}, null, 2); setCodexAuth(authString); @@ -227,7 +227,7 @@ const ProviderForm: React.FC = ({ const configString = setApiKeyInConfig( formData.settingsConfig, key.trim(), - { createIfMissing: selectedPreset !== null }, + { createIfMissing: selectedPreset !== null } ); // 更新表单配置 @@ -281,7 +281,7 @@ const ProviderForm: React.FC = ({ useEffect(() => { if (initialData) { const parsedKey = getApiKeyFromConfig( - JSON.stringify(initialData.settingsConfig), + JSON.stringify(initialData.settingsConfig) ); if (parsedKey) setApiKey(parsedKey); } @@ -427,7 +427,7 @@ const ProviderForm: React.FC = ({ placeholder={ isCodexOfficialPreset ? "官方无需填写 API Key,直接保存即可" - : "只需要填这里,上方 auth.json 会自动填充" + : "只需要填这里,下方 auth.json 会自动填充" } disabled={isCodexOfficialPreset} autoComplete="off" @@ -471,14 +471,15 @@ const ProviderForm: React.FC = ({ setCodexAuth(value); try { const auth = JSON.parse(value || "{}"); - const key = typeof auth.api_key === "string" ? auth.api_key : ""; + const key = + typeof auth.api_key === "string" ? auth.api_key : ""; setCodexApiKey(key); } catch { // ignore } }} placeholder={`{ - "api_key": "your-codex-api-key" + "OPENAI_API_KEY": "sk-your-api-key-here" }`} rows={6} style={{ fontFamily: "monospace", fontSize: "14px" }} @@ -493,9 +494,7 @@ const ProviderForm: React.FC = ({ id="codexConfig" value={codexConfig} onChange={(e) => setCodexConfig(e.target.value)} - placeholder={`# Codex configuration -model = "codex-model" -temperature = 0.7`} + placeholder={``} rows={8} style={{ fontFamily: "monospace", fontSize: "14px" }} required diff --git a/src/config/codexProviderPresets.ts b/src/config/codexProviderPresets.ts index d741030..f5342be 100644 --- a/src/config/codexProviderPresets.ts +++ b/src/config/codexProviderPresets.ts @@ -12,20 +12,30 @@ export interface CodexProviderPreset { export const codexProviderPresets: CodexProviderPreset[] = [ { name: "Codex官方", - websiteUrl: "https://codex", + websiteUrl: "https://chatgpt.com/codex", isOfficial: true, - // 官方一般不需要在 auth.json 里预置 key,由用户根据实际环境填写 - auth: {}, - config: `# Codex 默认配置模板\n# 根据你的 Codex 安装或文档进行调整\nmodel = "default"\ntemperature = 0.7`, + // 官方的 key 为null + auth: { + "OPENAI_API_KEY": null, + }, + config: ``, }, { name: "PackyCode", - websiteUrl: "https://www.packycode.com", + websiteUrl: "https://codex.packycode.com/", // PackyCode 一般通过 API Key;请将占位符替换为你的实际 key auth: { - api_key: "sk-your-api-key-here", + "OPENAI_API_KEY": "sk-your-api-key-here", }, - config: `# Codex 配置模板 - PackyCode\n# 如有需要可添加 base_url: \n# base_url = "https://api.packycode.com"\nmodel = "default"\ntemperature = 0.7`, + config: `model_provider = "packycode" +model = "gpt-5" +model_reasoning_effort = "high" + +[model_providers.packycode] +name = "packycode" +base_url = "https://codex-api.packycode.com/v1" +wire_api = "responses" +env_key = "packycode"`, }, ];