fix: 修复百炼 API key 配置并发布 v0.23.1

This commit is contained in:
7418 committed 2026-03-03 16:36:10 +08:00
1 parent 5413eb55ba
commit 6dfe23a9a9
3 files changed
+5 -24

No files matched your search

+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "codepilot",
"version": "0.23.0",
"version": "0.23.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "codepilot",
"version": "0.23.0",
"version": "0.23.1",
"dependencies": {
"@ai-sdk/anthropic": "^3.0.47",
"@ai-sdk/google": "^3.0.31",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "codepilot",
"version": "0.23.0",
"version": "0.23.1",
"private": true,
"author": {
"name": "op7418",
+2 -21
View File
@@ -77,16 +77,6 @@ function getProviderIcon(name: string, baseUrl: string): ReactNode {
return <HugeiconsIcon icon={ServerStack01Icon} className="h-[18px] w-[18px] text-muted-foreground" />;
}
/** Resolve the key field name from extra_env JSON (e.g. ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN) */
function getKeyFieldFromExtraEnv(extraEnv: string): string | null {
try {
const parsed = JSON.parse(extraEnv);
if ("ANTHROPIC_AUTH_TOKEN" in parsed) return "ANTHROPIC_AUTH_TOKEN";
if ("ANTHROPIC_API_KEY" in parsed) return "ANTHROPIC_API_KEY";
} catch { /* ignore */ }
return null;
}
// ---------------------------------------------------------------------------
// Quick-add preset definitions
// ---------------------------------------------------------------------------
@@ -237,7 +227,7 @@ const QUICK_PRESETS: QuickPreset[] = [
icon: <Bailian size={18} />,
provider_type: "custom",
base_url: "https://coding.dashscope.aliyuncs.com/apps/anthropic",
extra_env: '{"ANTHROPIC_AUTH_TOKEN":""}',
extra_env: '{"ANTHROPIC_API_KEY":""}',
fields: ["api_key"],
},
{
@@ -349,16 +339,7 @@ function PresetConnectDialog({
e.preventDefault();
setError(null);
// Inject key into extra_env if needed
let finalExtraEnv = extraEnv;
const keyField = getKeyFieldFromExtraEnv(preset.extra_env);
if (keyField && apiKey) {
try {
const envObj = JSON.parse(finalExtraEnv);
envObj[keyField] = apiKey;
finalExtraEnv = JSON.stringify(envObj);
} catch { /* use as-is */ }
}
// Inject model name into extra_env if model_names field is used
if (preset.fields.includes("model_names") && modelName.trim()) {
@@ -383,7 +364,7 @@ function PresetConnectDialog({
name: name.trim() || preset.name,
provider_type: preset.provider_type,
base_url: baseUrl.trim(),
api_key: keyField ? "" : apiKey,
api_key: apiKey,
extra_env: finalExtraEnv,
notes: "",
});