Spaces:
Build error
Build error
changed guest box into smaller column
Browse files
app.py
CHANGED
|
@@ -141,20 +141,22 @@ encoding = encoding_for_model(model_nameGPT)
|
|
| 141 |
data_path = './data/impact_theory_data.json'
|
| 142 |
cache_path = 'data/impact_theory_cache.parquet'
|
| 143 |
data = load_data(data_path)
|
| 144 |
-
cache = None
|
| 145 |
|
| 146 |
-
if
|
|
|
|
| 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.
|
| 154 |
model_token_id = st.secrets['secrets']['MODAL_TOKEN_ID']
|
| 155 |
modal_token_secret = st.secrets['secrets']['MODAL_TOKEN_SECRET']
|
| 156 |
-
|
| 157 |
-
|
|
|
|
| 158 |
# for Huggingface (no [secrets] section)
|
| 159 |
Wapi_key = st.secrets['WEAVIATE_API_KEY']
|
| 160 |
url = st.secrets['WEAVIATE_ENDPOINT']
|
|
@@ -165,15 +167,15 @@ elif isinstance(st.secrets, dict):
|
|
| 165 |
model_token_id = st.secrets['MODAL_TOKEN_ID']
|
| 166 |
modal_token_secret = st.secrets['MODAL_TOKEN_SECRET']
|
| 167 |
|
| 168 |
-
else:
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
#%%
|
| 178 |
# model_default = 'sentence-transformers/all-mpnet-base-v2'
|
| 179 |
model_default = 'models/finetuned-all-mpnet-base-v2-300' if we_are_not_online \
|
|
@@ -403,11 +405,13 @@ def main():
|
|
| 403 |
|
| 404 |
|
| 405 |
st.write("\u21D0 Open the sidebar to change Search settings \n ") # https://home.unicode.org also 21E0, 21B0 B2 D0
|
| 406 |
-
guest = st.selectbox('Select A Guest',
|
| 407 |
-
options=guest_list,
|
| 408 |
-
index=None,
|
| 409 |
-
placeholder='Select Guest')
|
| 410 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 411 |
|
| 412 |
col1, col2 = st.columns([7,3])
|
| 413 |
with col1:
|
|
@@ -457,7 +461,7 @@ def main():
|
|
| 457 |
new_query = reworded_query['rewritten_question']
|
| 458 |
if guest.split(' ')[1] not in new_query and guest.split(' ')[0] not in new_query:
|
| 459 |
# if the guest name is not in the rewritten question, we add it
|
| 460 |
-
new_query = f"About {guest}, " + new_query
|
| 461 |
query = new_query
|
| 462 |
|
| 463 |
# we can arrive here only if a guest was selected
|
|
|
|
| 141 |
data_path = './data/impact_theory_data.json'
|
| 142 |
cache_path = 'data/impact_theory_cache.parquet'
|
| 143 |
data = load_data(data_path)
|
| 144 |
+
cache = None # load_content_cache(cache_path)
|
| 145 |
|
| 146 |
+
if 'secrets' in st.secrets:
|
| 147 |
+
# st.write("Loading secrets from [secrets] section")
|
| 148 |
# for streamlit online or local, which uses a [secrets] section
|
| 149 |
Wapi_key = st.secrets['secrets']['WEAVIATE_API_KEY']
|
| 150 |
url = st.secrets['secrets']['WEAVIATE_ENDPOINT']
|
| 151 |
openai_api_key = st.secrets['secrets']['OPENAI_API_KEY']
|
| 152 |
|
| 153 |
hf_token = st.secrets['secrets']['LLAMA2_ENDPOINT_HF_TOKEN_chris']
|
| 154 |
+
hf_endpoint = st.secrets['secrets']['LLAMA2_ENDPOINT_UPLIMIT']
|
| 155 |
model_token_id = st.secrets['secrets']['MODAL_TOKEN_ID']
|
| 156 |
modal_token_secret = st.secrets['secrets']['MODAL_TOKEN_SECRET']
|
| 157 |
+
|
| 158 |
+
else :
|
| 159 |
+
# st.write("Loading secrets for Huggingface")
|
| 160 |
# for Huggingface (no [secrets] section)
|
| 161 |
Wapi_key = st.secrets['WEAVIATE_API_KEY']
|
| 162 |
url = st.secrets['WEAVIATE_ENDPOINT']
|
|
|
|
| 167 |
model_token_id = st.secrets['MODAL_TOKEN_ID']
|
| 168 |
modal_token_secret = st.secrets['MODAL_TOKEN_SECRET']
|
| 169 |
|
| 170 |
+
# else:
|
| 171 |
+
# # if we want to use env file
|
| 172 |
+
# st.write("Loading secrets from environment variables")
|
| 173 |
+
# api_key = os.environ['WEAVIATE_API_KEY']
|
| 174 |
+
# url = os.environ['WEAVIATE_ENDPOINT']
|
| 175 |
+
# openai_api_key = os.environ['OPENAI_API_KEY']
|
| 176 |
+
|
| 177 |
+
# hf_token = os.environ['LLAMA2_ENDPOINT_HF_TOKEN_chris']
|
| 178 |
+
# hf_endpoint = os.environ['LLAMA2_ENDPOINT_UPLIMIT']
|
| 179 |
#%%
|
| 180 |
# model_default = 'sentence-transformers/all-mpnet-base-v2'
|
| 181 |
model_default = 'models/finetuned-all-mpnet-base-v2-300' if we_are_not_online \
|
|
|
|
| 405 |
|
| 406 |
|
| 407 |
st.write("\u21D0 Open the sidebar to change Search settings \n ") # https://home.unicode.org also 21E0, 21B0 B2 D0
|
|
|
|
|
|
|
|
|
|
|
|
|
| 408 |
|
| 409 |
+
col1, _ = st.columns([3,7])
|
| 410 |
+
with col1:
|
| 411 |
+
guest = st.selectbox('Select A Guest',
|
| 412 |
+
options=guest_list,
|
| 413 |
+
index=None,
|
| 414 |
+
placeholder='Select Guest')
|
| 415 |
|
| 416 |
col1, col2 = st.columns([7,3])
|
| 417 |
with col1:
|
|
|
|
| 461 |
new_query = reworded_query['rewritten_question']
|
| 462 |
if guest.split(' ')[1] not in new_query and guest.split(' ')[0] not in new_query:
|
| 463 |
# if the guest name is not in the rewritten question, we add it
|
| 464 |
+
new_query = f"About {guest}, " + new_query
|
| 465 |
query = new_query
|
| 466 |
|
| 467 |
# we can arrive here only if a guest was selected
|