Skip to content

Commit 6dfe23a

Browse files
author
7418
committed
fix: 修复百炼 API key 配置并发布 v0.23.1
1 parent 5413eb5 commit 6dfe23a

File tree

3 files changed

+5
-24
lines changed

3 files changed

+5
-24
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codepilot",
3-
"version": "0.23.0",
3+
"version": "0.23.1",
44
"private": true,
55
"author": {
66
"name": "op7418",

src/components/settings/ProviderManager.tsx

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,6 @@ function getProviderIcon(name: string, baseUrl: string): ReactNode {
7777
return <HugeiconsIcon icon={ServerStack01Icon} className="h-[18px] w-[18px] text-muted-foreground" />;
7878
}
7979

80-
/** Resolve the key field name from extra_env JSON (e.g. ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN) */
81-
function getKeyFieldFromExtraEnv(extraEnv: string): string | null {
82-
try {
83-
const parsed = JSON.parse(extraEnv);
84-
if ("ANTHROPIC_AUTH_TOKEN" in parsed) return "ANTHROPIC_AUTH_TOKEN";
85-
if ("ANTHROPIC_API_KEY" in parsed) return "ANTHROPIC_API_KEY";
86-
} catch { /* ignore */ }
87-
return null;
88-
}
89-
9080
// ---------------------------------------------------------------------------
9181
// Quick-add preset definitions
9282
// ---------------------------------------------------------------------------
@@ -237,7 +227,7 @@ const QUICK_PRESETS: QuickPreset[] = [
237227
icon: <Bailian size={18} />,
238228
provider_type: "custom",
239229
base_url: "https://coding.dashscope.aliyuncs.com/apps/anthropic",
240-
extra_env: '{"ANTHROPIC_AUTH_TOKEN":""}',
230+
extra_env: '{"ANTHROPIC_API_KEY":""}',
241231
fields: ["api_key"],
242232
},
243233
{
@@ -349,16 +339,7 @@ function PresetConnectDialog({
349339
e.preventDefault();
350340
setError(null);
351341

352-
// Inject key into extra_env if needed
353342
let finalExtraEnv = extraEnv;
354-
const keyField = getKeyFieldFromExtraEnv(preset.extra_env);
355-
if (keyField && apiKey) {
356-
try {
357-
const envObj = JSON.parse(finalExtraEnv);
358-
envObj[keyField] = apiKey;
359-
finalExtraEnv = JSON.stringify(envObj);
360-
} catch { /* use as-is */ }
361-
}
362343

363344
// Inject model name into extra_env if model_names field is used
364345
if (preset.fields.includes("model_names") && modelName.trim()) {
@@ -383,7 +364,7 @@ function PresetConnectDialog({
383364
name: name.trim() || preset.name,
384365
provider_type: preset.provider_type,
385366
base_url: baseUrl.trim(),
386-
api_key: keyField ? "" : apiKey,
367+
api_key: apiKey,
387368
extra_env: finalExtraEnv,
388369
notes: "",
389370
});

0 commit comments

Comments
 (0)