Update app.py
Browse files
app.py
CHANGED
@@ -5,20 +5,16 @@ from openai import OpenAI
|
|
5 |
import gradio as gr
|
6 |
|
7 |
# βββ Configure your OpenRouter key βββ
|
8 |
-
|
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
|
17 |
-
print("Please
|
18 |
else:
|
19 |
client = OpenAI(
|
20 |
base_url="https://openrouter.ai/api/v1",
|
21 |
-
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):
|