JPBianchi commited on
Commit
3bec1a5
1 Parent(s): 671b5bb

recoded secrets section

Browse files
Files changed (1) hide show
  1. app.py +14 -12
app.py CHANGED
@@ -143,17 +143,18 @@ cache_path = 'data/impact_theory_cache.parquet'
143
  data = load_data(data_path)
144
  cache = None # load_content_cache(cache_path)
145
 
146
- try:
147
- #st.secrets['secrets']['LLAMA2_ENDPOINT_UPLIMIT']
148
- # # st.write("Secrets loaded from secrets.toml")
149
- # # st.write("HF_TOKEN", hf_token)
150
- # # st.write("Loading secrets from secrets.toml")
151
- # Wapi_key = st.secrets['secrets']['WEAVIATE_API_KEY']
152
- # url = st.secrets['secrets']['WEAVIATE_ENDPOINT']
153
- # openai_api_key = st.secrets['secrets']['OPENAI_API_KEY']
154
-
155
- # hf_token = st.secrets['secrets']['LLAMA2_ENDPOINT_HF_TOKEN_chris']
156
- # hf_endpoint = st.secret
 
157
  # for Huggingface (no [secrets] section)
158
  Wapi_key = st.secrets['WEAVIATE_API_KEY']
159
  url = st.secrets['WEAVIATE_ENDPOINT']
@@ -163,8 +164,9 @@ try:
163
  hf_endpoint = st.secrets['LLAMA2_ENDPOINT_UPLIMIT']
164
  model_token_id = st.secrets['MODAL_TOKEN_ID']
165
  modal_token_secret = st.secrets['MODAL_TOKEN_SECRET']
166
- except:
167
 
 
 
168
  st.write("Loading secrets from environment variables")
169
  api_key = os.environ['WEAVIATE_API_KEY']
170
  url = os.environ['WEAVIATE_ENDPOINT']
 
143
  data = load_data(data_path)
144
  cache = None # load_content_cache(cache_path)
145
 
146
+ if isinstance(st.secrets, dict) and 'secrets' in st.secrets:
147
+ # for streamlit online or local, which uses a [secrets] section
148
+ Wapi_key = st.secrets['secrets']['WEAVIATE_API_KEY']
149
+ url = st.secrets['secrets']['WEAVIATE_ENDPOINT']
150
+ openai_api_key = st.secrets['secrets']['OPENAI_API_KEY']
151
+
152
+ hf_token = st.secrets['secrets']['LLAMA2_ENDPOINT_HF_TOKEN_chris']
153
+ hf_endpoint = st.secret['secrets']['LLAMA2_ENDPOINT_UPLIMIT']
154
+ model_token_id = st.secrets['secrets']['MODAL_TOKEN_ID']
155
+ modal_token_secret = st.secrets['secrets']['MODAL_TOKEN_SECRET']
156
+
157
+ elif isinstance(st.secrets, dict):
158
  # for Huggingface (no [secrets] section)
159
  Wapi_key = st.secrets['WEAVIATE_API_KEY']
160
  url = st.secrets['WEAVIATE_ENDPOINT']
 
164
  hf_endpoint = st.secrets['LLAMA2_ENDPOINT_UPLIMIT']
165
  model_token_id = st.secrets['MODAL_TOKEN_ID']
166
  modal_token_secret = st.secrets['MODAL_TOKEN_SECRET']
 
167
 
168
+ else:
169
+ # if we want to use env file
170
  st.write("Loading secrets from environment variables")
171
  api_key = os.environ['WEAVIATE_API_KEY']
172
  url = os.environ['WEAVIATE_ENDPOINT']