JPBianchi commited on
Commit
2c087ac
1 Parent(s): 083cd31

modifications for secrets on HF

Browse files
Files changed (1) hide show
  1. app.py +18 -7
app.py CHANGED
@@ -154,13 +154,24 @@ try:
154
  # st.write("Secrets loaded from secrets.toml")
155
  # st.write("HF_TOKEN", hf_token)
156
  except:
157
- st.write("Loading secrets from environment variables")
158
- api_key = os.environ['WEAVIATE_API_KEY']
159
- url = os.environ['WEAVIATE_ENDPOINT']
160
- openai_api_key = os.environ['OPENAI_API_KEY']
161
-
162
- hf_token = os.environ['LLAMA2_ENDPOINT_HF_TOKEN_chris']
163
- hf_endpoint = os.environ['LLAMA2_ENDPOINT_UPLIMIT']
 
 
 
 
 
 
 
 
 
 
 
164
  #%%
165
  # model_default = 'sentence-transformers/all-mpnet-base-v2'
166
  model_default = 'models/finetuned-all-mpnet-base-v2-300' if we_are_not_online \
 
154
  # st.write("Secrets loaded from secrets.toml")
155
  # st.write("HF_TOKEN", hf_token)
156
  except:
157
+ try:
158
+ # for Huggingface (no [secrets] section)
159
+ Wapi_key = st.secrets['WEAVIATE_API_KEY']
160
+ url = st.secrets['WEAVIATE_ENDPOINT']
161
+ openai_api_key = st.secrets['OPENAI_API_KEY']
162
+
163
+ hf_token = st.secrets['LLAMA2_ENDPOINT_HF_TOKEN_chris']
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
+ except:
168
+ st.write("Loading secrets from environment variables")
169
+ api_key = os.environ['WEAVIATE_API_KEY']
170
+ url = os.environ['WEAVIATE_ENDPOINT']
171
+ openai_api_key = os.environ['OPENAI_API_KEY']
172
+
173
+ hf_token = os.environ['LLAMA2_ENDPOINT_HF_TOKEN_chris']
174
+ hf_endpoint = os.environ['LLAMA2_ENDPOINT_UPLIMIT']
175
  #%%
176
  # model_default = 'sentence-transformers/all-mpnet-base-v2'
177
  model_default = 'models/finetuned-all-mpnet-base-v2-300' if we_are_not_online \