8900 commited on
Commit
f76ec57
·
verified ·
1 Parent(s): 35ec70f

Update setup-hf-config.mjs

Browse files
Files changed (1) hide show
  1. setup-hf-config.mjs +9 -27
setup-hf-config.mjs CHANGED
@@ -87,33 +87,15 @@ if (allowedOrigins.length > 0) {
87
 
88
  config.gateway.trustedProxies = trustedProxies;
89
 
90
- // -- providers: write API keys so gateway can read them --
91
- if (!config.providers) config.providers = {};
 
92
 
93
- if (anthropicKey) {
94
- if (!config.providers.anthropic) config.providers.anthropic = {};
95
- config.providers.anthropic.apiKey = anthropicKey;
96
- }
97
-
98
- if (googleKey) {
99
- if (!config.providers.gemini) config.providers.gemini = {};
100
- config.providers.gemini.apiKey = googleKey;
101
- }
102
-
103
- if (groqKey) {
104
- if (!config.providers.groq) config.providers.groq = {};
105
- config.providers.groq.apiKey = groqKey;
106
- }
107
-
108
- if (openaiKey) {
109
- if (!config.providers.openai) config.providers.openai = {};
110
- config.providers.openai.apiKey = openaiKey;
111
- }
112
-
113
- if (openrouterKey) {
114
- if (!config.providers.openrouter) config.providers.openrouter = {};
115
- config.providers.openrouter.apiKey = openrouterKey;
116
- }
117
 
118
  // -- agents defaults --
119
  if (!config.agents) config.agents = {};
@@ -124,7 +106,7 @@ config.agents.defaults.model.primary = defaultModel;
124
 
125
  var fallbacks = [];
126
  if (anthropicKey) fallbacks.push("anthropic/claude-sonnet-4-6");
127
- if (googleKey) fallbacks.push("gemini/gemini-2.0-flash");
128
  if (groqKey) fallbacks.push("groq/llama-3.3-70b-versatile");
129
  if (openaiKey) fallbacks.push("openai/gpt-4o-mini");
130
  if (openrouterKey) fallbacks.push("openrouter/google/gemini-2.0-flash");
 
87
 
88
  config.gateway.trustedProxies = trustedProxies;
89
 
90
+ // -- 核心修正:将 API Key 写入 env.vars 而非 providers --
91
+ if (!config.env) config.env = {};
92
+ if (!config.env.vars) config.env.vars = {};
93
 
94
+ if (anthropicKey) config.env.vars.ANTHROPIC_API_KEY = anthropicKey;
95
+ if (googleKey) config.env.vars.GOOGLE_API_KEY = googleKey;
96
+ if (groqKey) config.env.vars.GROQ_API_KEY = groqKey;
97
+ if (openaiKey) config.env.vars.OPENAI_API_KEY = openaiKey;
98
+ if (openrouterKey) config.env.vars.OPENROUTER_API_KEY = openrouterKey;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
 
100
  // -- agents defaults --
101
  if (!config.agents) config.agents = {};
 
106
 
107
  var fallbacks = [];
108
  if (anthropicKey) fallbacks.push("anthropic/claude-sonnet-4-6");
109
+ if (googleKey) fallbacks.push("google/gemini-2.0-flash");
110
  if (groqKey) fallbacks.push("groq/llama-3.3-70b-versatile");
111
  if (openaiKey) fallbacks.push("openai/gpt-4o-mini");
112
  if (openrouterKey) fallbacks.push("openrouter/google/gemini-2.0-flash");