uumerrr684 commited on
Commit
b9b7adb
Β·
verified Β·
1 Parent(s): 2a1afd2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -11
app.py CHANGED
@@ -162,6 +162,9 @@
162
  </div>
163
 
164
  <script>
 
 
 
165
  // Global variables
166
  let messages = [];
167
  let sessions = [];
@@ -251,13 +254,8 @@
251
  }
252
 
253
  async function getAIResponse(userMessage) {
254
- // Try to get API key from various sources
255
- const OPENROUTER_API_KEY = window.OPENROUTER_API_KEY ||
256
- window.HF_TOKEN ||
257
- (typeof process !== 'undefined' && process.env && process.env.OPENROUTER_API_KEY);
258
-
259
- if (!OPENROUTER_API_KEY) {
260
- throw new Error("No API key found. Please add OPENROUTER_API_KEY to Hugging Face Spaces secrets.");
261
  }
262
 
263
  const url = "https://openrouter.ai/api/v1/chat/completions";
@@ -294,7 +292,8 @@
294
  });
295
 
296
  if (!response.ok) {
297
- throw new Error("API Error: " + response.status);
 
298
  }
299
 
300
  const result = await response.json();
@@ -484,9 +483,7 @@
484
 
485
  async function checkAPIStatus() {
486
  try {
487
- const OPENROUTER_API_KEY = window.OPENROUTER_API_KEY || window.HF_TOKEN;
488
-
489
- if (!OPENROUTER_API_KEY) {
490
  document.getElementById('api-status').textContent = 'πŸ”΄ No API Key';
491
  document.getElementById('api-dot').className = 'w-2 h-2 rounded-full bg-red-500';
492
  return;
 
162
  </div>
163
 
164
  <script>
165
+ // πŸ”‘ OpenRouter API Key
166
+ const OPENROUTER_API_KEY = "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";
167
+
168
  // Global variables
169
  let messages = [];
170
  let sessions = [];
 
254
  }
255
 
256
  async function getAIResponse(userMessage) {
257
+ if (!OPENROUTER_API_KEY || OPENROUTER_API_KEY === "YOUR_API_KEY_HERE") {
258
+ throw new Error("Please add your OpenRouter API key to the code.");
 
 
 
 
 
259
  }
260
 
261
  const url = "https://openrouter.ai/api/v1/chat/completions";
 
292
  });
293
 
294
  if (!response.ok) {
295
+ const errorText = await response.text();
296
+ throw new Error("API Error: " + response.status + " - " + errorText);
297
  }
298
 
299
  const result = await response.json();
 
483
 
484
  async function checkAPIStatus() {
485
  try {
486
+ if (!OPENROUTER_API_KEY || OPENROUTER_API_KEY === "YOUR_API_KEY_HERE") {
 
 
487
  document.getElementById('api-status').textContent = 'πŸ”΄ No API Key';
488
  document.getElementById('api-dot').className = 'w-2 h-2 rounded-full bg-red-500';
489
  return;