# set OpenAI Key - use Streamlit secrets
os.environ["OPENAI_API_KEY"] = st.secrets.openai_key
are you saying I should do this?
os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY")
my expectation is that I would need to set the st.secrets.openai_key to the correct key value which would be
os.getenv("OPENAI_API_KEY")`st.secrets
to check for the metadata key. core/agent_builder/loader.py:L51
secrets.toml
work π
secrets.toml
doesn't work for you, do a ctrl-f for st.secrets and remove it's usagest.session_state
(not sure how in-depth your streamlit knowledge is these days lol)os.getenv("OPENAI_API_KEY")
and os.getenv("METAPHOR_KEY")
and stuff it into st.session_state
-- the part I get stuck on is the relationship between if "metaphor_key" in st.secrets:
and st.session_state
- where/how do you add/set a st.secrets
... I have been using Chainlit (https://docs.chainlit.io/get-started/overview) and at least that is a bit easier to comprehend - but at the end of the day - the collision of abstractions is problematic... and I personally think it hurts LlamaIndex when the UI frameworks interfere with the "LI way"import streamlit as st
# Check if 'key' already exists in session_state
# If not, then initialize it
if 'key' not in st.session_state:
st.session_state['key'] = 'value'
# Session State also supports the attribute based syntax
if 'key' not in st.session_state:
st.session_state.key = 'value'