wifix199 commited on
Commit
81576ad
Β·
verified Β·
1 Parent(s): 92f2dea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -8
app.py CHANGED
@@ -5,20 +5,16 @@ from openai import OpenAI
5
  import gradio as gr
6
 
7
  # β€”β€”β€” Configure your OpenRouter key β€”β€”β€”
8
- api_key=os.getenv("OPENROUTER_API_KEY")
9
- # Assuming OPENROUTER_API_KEY is already set in the environment or Colab secrets
10
-
11
- # Retrieve the API key from Colab secrets
12
-
13
 
14
  # Check if the API key was retrieved
15
  if not OPENROUTER_API_KEY:
16
- print("Error: OPENROUTER_API_KEY not found in Colab secrets.")
17
- print("Please add your API key to Colab secrets by clicking on the key icon in the left panel and naming it OPENROUTER_API_KEY.")
18
  else:
19
  client = OpenAI(
20
  base_url="https://openrouter.ai/api/v1",
21
- api_key=os.getenv("OPENROUTER_API_KEY"),
22
  )
23
 
24
  def openrouter_chat(user_message, history):
 
5
  import gradio as gr
6
 
7
  # β€”β€”β€” Configure your OpenRouter key β€”β€”β€”
8
+ OPENROUTER_API_KEY = os.getenv("OPENROUTER_API_KEY")
 
 
 
 
9
 
10
  # Check if the API key was retrieved
11
  if not OPENROUTER_API_KEY:
12
+ print("Error: OPENROUTER_API_KEY not found in environment.")
13
+ print("Please set your API key in the environment as 'OPENROUTER_API_KEY'.")
14
  else:
15
  client = OpenAI(
16
  base_url="https://openrouter.ai/api/v1",
17
+ api_key=OPENROUTER_API_KEY,
18
  )
19
 
20
  def openrouter_chat(user_message, history):