Update app.py
Browse files
app.py
CHANGED
|
@@ -12,22 +12,24 @@ def launch_bot():
|
|
| 12 |
def generate_response(question):
|
| 13 |
response = vq.submit_query(question)
|
| 14 |
return response
|
| 15 |
-
|
| 16 |
-
corpus_ids = str(os.environ['corpus_ids']).split(',')
|
| 17 |
-
questions = list(eval(os.environ['examples']))
|
| 18 |
-
cfg = OmegaConf.create({
|
| 19 |
-
'customer_id': str(os.environ['customer_id']),
|
| 20 |
-
'corpus_ids': corpus_ids,
|
| 21 |
-
'api_key': str(os.environ['api_key']),
|
| 22 |
-
'title': os.environ['title'],
|
| 23 |
-
'description': os.environ['description'],
|
| 24 |
-
'examples': questions,
|
| 25 |
-
'source_data_desc': os.environ['source_data_desc']
|
| 26 |
-
})
|
| 27 |
|
| 28 |
-
if
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
|
|
|
|
|
|
| 31 |
st.set_page_config(page_title=cfg.title, layout="wide")
|
| 32 |
|
| 33 |
# left side content
|
|
@@ -73,5 +75,4 @@ def launch_bot():
|
|
| 73 |
st.session_state.messages.append(message)
|
| 74 |
|
| 75 |
if __name__ == "__main__":
|
| 76 |
-
vq = None
|
| 77 |
launch_bot()
|
|
|
|
| 12 |
def generate_response(question):
|
| 13 |
response = vq.submit_query(question)
|
| 14 |
return response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
if 'cfg' not in st.session_state:
|
| 17 |
+
corpus_ids = str(os.environ['corpus_ids']).split(',')
|
| 18 |
+
questions = list(eval(os.environ['examples']))
|
| 19 |
+
cfg = OmegaConf.create({
|
| 20 |
+
'customer_id': str(os.environ['customer_id']),
|
| 21 |
+
'corpus_ids': corpus_ids,
|
| 22 |
+
'api_key': str(os.environ['api_key']),
|
| 23 |
+
'title': os.environ['title'],
|
| 24 |
+
'description': os.environ['description'],
|
| 25 |
+
'examples': questions,
|
| 26 |
+
'source_data_desc': os.environ['source_data_desc']
|
| 27 |
+
})
|
| 28 |
+
st.session_state.cfg = cfg
|
| 29 |
+
st.session_state.vq = VectaraQuery(cfg.api_key, cfg.customer_id, cfg.corpus_ids)
|
| 30 |
|
| 31 |
+
cfg = st.session_state.cfg
|
| 32 |
+
vq = st.session_state.vq
|
| 33 |
st.set_page_config(page_title=cfg.title, layout="wide")
|
| 34 |
|
| 35 |
# left side content
|
|
|
|
| 75 |
st.session_state.messages.append(message)
|
| 76 |
|
| 77 |
if __name__ == "__main__":
|
|
|
|
| 78 |
launch_bot()
|