Spaces:
Sleeping
Sleeping
allow API key to use env vars
Browse files- app/variables.py +11 -5
app/variables.py
CHANGED
|
@@ -477,13 +477,19 @@ from langchain_openai import ChatOpenAI
|
|
| 477 |
import streamlit as st
|
| 478 |
# from langchain_openai.chat_models.base import BaseChatOpenAI
|
| 479 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 480 |
llm_options = {
|
| 481 |
# "llama-3.3-quantized": ChatOpenAI(model = "cirrus", api_key=st.secrets['CIRRUS_LLM_API_KEY'], base_url = "https://llm.cirrus.carlboettiger.info/v1", temperature=0),
|
| 482 |
-
"llama3.3": ChatOpenAI(model = "llama3-sdsc", api_key=
|
| 483 |
-
"gemma3": ChatOpenAI(model = "gemma3", api_key=
|
| 484 |
-
# "DeepSeek-R1-Distill-Qwen-32B": BaseChatOpenAI(model = "DeepSeek-R1-Distill-Qwen-32B", api_key=
|
| 485 |
-
"watt": ChatOpenAI(model = "watt", api_key=
|
| 486 |
-
# "phi3": ChatOpenAI(model = "phi3", api_key=
|
| 487 |
}
|
| 488 |
|
| 489 |
|
|
|
|
| 477 |
import streamlit as st
|
| 478 |
# from langchain_openai.chat_models.base import BaseChatOpenAI
|
| 479 |
|
| 480 |
+
## dockerized streamlit app wants to read from os.getenv(), otherwise use st.secrets
|
| 481 |
+
import os
|
| 482 |
+
api_key = os.getenv("NRP_API_KEY")
|
| 483 |
+
if api_key is None:
|
| 484 |
+
api_key = st.secrets["NRP_API_KEY"]
|
| 485 |
+
|
| 486 |
llm_options = {
|
| 487 |
# "llama-3.3-quantized": ChatOpenAI(model = "cirrus", api_key=st.secrets['CIRRUS_LLM_API_KEY'], base_url = "https://llm.cirrus.carlboettiger.info/v1", temperature=0),
|
| 488 |
+
"llama3.3": ChatOpenAI(model = "llama3-sdsc", api_key=api_key, base_url = "https://llm.nrp-nautilus.io/", temperature=0),
|
| 489 |
+
"gemma3": ChatOpenAI(model = "gemma3", api_key=api_key, base_url = "https://llm.nrp-nautilus.io/", temperature=0),
|
| 490 |
+
# "DeepSeek-R1-Distill-Qwen-32B": BaseChatOpenAI(model = "DeepSeek-R1-Distill-Qwen-32B", api_key=api_key, base_url = "https://llm.nrp-nautilus.io/", temperature=0),
|
| 491 |
+
"watt": ChatOpenAI(model = "watt", api_key=api_key, base_url = "https://llm.nrp-nautilus.io/", temperature=0),
|
| 492 |
+
# "phi3": ChatOpenAI(model = "phi3", api_key=api_key, base_url = "https://llm.nrp-nautilus.io/", temperature=0),
|
| 493 |
}
|
| 494 |
|
| 495 |
|