Spaces:
Runtime error
Runtime error
Commit
Β·
a561bc6
1
Parent(s):
4de5f47
added compatible secrets management code
Browse files- streamlit_app.py +6 -1
streamlit_app.py
CHANGED
|
@@ -6,12 +6,15 @@ from openai import OpenAI
|
|
| 6 |
|
| 7 |
# App title
|
| 8 |
st.set_page_config(page_title="π¬ Open AI Chatbot")
|
|
|
|
| 9 |
|
| 10 |
# Replicate Credentials
|
| 11 |
with st.sidebar:
|
| 12 |
st.title("π¬ Open AI Chatbot")
|
| 13 |
st.write("This chatbot is created using the GPT model from Open AI.")
|
| 14 |
-
if
|
|
|
|
|
|
|
| 15 |
st.success("API key already provided!", icon="β
")
|
| 16 |
openai_api = st.secrets["OPENAI_API_KEY"]
|
| 17 |
else:
|
|
@@ -20,6 +23,8 @@ with st.sidebar:
|
|
| 20 |
st.warning("Please enter your credentials!", icon="β οΈ")
|
| 21 |
else:
|
| 22 |
st.success("Proceed to entering your prompt message!", icon="π")
|
|
|
|
|
|
|
| 23 |
os.environ["OPENAI_API_KEY"] = openai_api
|
| 24 |
|
| 25 |
st.subheader("Models and parameters")
|
|
|
|
| 6 |
|
| 7 |
# App title
|
| 8 |
st.set_page_config(page_title="π¬ Open AI Chatbot")
|
| 9 |
+
openai_api = os.getenv("OPENAI_API_KEY")
|
| 10 |
|
| 11 |
# Replicate Credentials
|
| 12 |
with st.sidebar:
|
| 13 |
st.title("π¬ Open AI Chatbot")
|
| 14 |
st.write("This chatbot is created using the GPT model from Open AI.")
|
| 15 |
+
if openai_api:
|
| 16 |
+
pass
|
| 17 |
+
elif "OPENAI_API_KEY" in st.secrets:
|
| 18 |
st.success("API key already provided!", icon="β
")
|
| 19 |
openai_api = st.secrets["OPENAI_API_KEY"]
|
| 20 |
else:
|
|
|
|
| 23 |
st.warning("Please enter your credentials!", icon="β οΈ")
|
| 24 |
else:
|
| 25 |
st.success("Proceed to entering your prompt message!", icon="π")
|
| 26 |
+
|
| 27 |
+
### for streamlit purpose
|
| 28 |
os.environ["OPENAI_API_KEY"] = openai_api
|
| 29 |
|
| 30 |
st.subheader("Models and parameters")
|