chore(codex): 调整 Codex 预设模板与占位符(auth.json/config.toml 与表单占位)
This commit is contained in:
@@ -48,7 +48,7 @@ const ProviderForm: React.FC<ProviderFormProps> = ({
|
||||
const [codexConfig, setCodexConfig] = useState("");
|
||||
const [codexApiKey, setCodexApiKey] = useState("");
|
||||
const [selectedCodexPreset, setSelectedCodexPreset] = useState<number | null>(
|
||||
null,
|
||||
null
|
||||
);
|
||||
|
||||
// 初始化 Codex 配置
|
||||
@@ -134,7 +134,7 @@ const ProviderForm: React.FC<ProviderFormProps> = ({
|
||||
};
|
||||
|
||||
const handleChange = (
|
||||
e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>,
|
||||
e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>
|
||||
) => {
|
||||
const { name, value } = e.target;
|
||||
|
||||
@@ -171,7 +171,7 @@ const ProviderForm: React.FC<ProviderFormProps> = ({
|
||||
// 更新JSON配置
|
||||
const updatedConfig = updateCoAuthoredSetting(
|
||||
formData.settingsConfig,
|
||||
checked,
|
||||
checked
|
||||
);
|
||||
setFormData({
|
||||
...formData,
|
||||
@@ -202,7 +202,7 @@ const ProviderForm: React.FC<ProviderFormProps> = ({
|
||||
// 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<ProviderFormProps> = ({
|
||||
const configString = setApiKeyInConfig(
|
||||
formData.settingsConfig,
|
||||
key.trim(),
|
||||
{ createIfMissing: selectedPreset !== null },
|
||||
{ createIfMissing: selectedPreset !== null }
|
||||
);
|
||||
|
||||
// 更新表单配置
|
||||
@@ -281,7 +281,7 @@ const ProviderForm: React.FC<ProviderFormProps> = ({
|
||||
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<ProviderFormProps> = ({
|
||||
placeholder={
|
||||
isCodexOfficialPreset
|
||||
? "官方无需填写 API Key,直接保存即可"
|
||||
: "只需要填这里,上方 auth.json 会自动填充"
|
||||
: "只需要填这里,下方 auth.json 会自动填充"
|
||||
}
|
||||
disabled={isCodexOfficialPreset}
|
||||
autoComplete="off"
|
||||
@@ -471,14 +471,15 @@ const ProviderForm: React.FC<ProviderFormProps> = ({
|
||||
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<ProviderFormProps> = ({
|
||||
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
|
||||
|
||||
@@ -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"`,
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user