Spaces:
Sleeping
Sleeping
Léo Bourrel
commited on
Commit
·
0802dfc
1
Parent(s):
7f82f4e
feat: add spinner
Browse files
app.py
CHANGED
@@ -60,18 +60,19 @@ def initialize_session_state():
|
|
60 |
|
61 |
|
62 |
def on_click_callback():
|
63 |
-
with
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
|
|
|
|
70 |
)
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
# insert_chat_history_articles(conn, history_id, llm_response["source_documents"])
|
75 |
|
76 |
|
77 |
load_css()
|
|
|
60 |
|
61 |
|
62 |
def on_click_callback():
|
63 |
+
with st.spinner('Wait for it...'):
|
64 |
+
with get_openai_callback() as cb:
|
65 |
+
human_prompt = st.session_state.human_prompt
|
66 |
+
llm_response = st.session_state.conversation(human_prompt)
|
67 |
+
st.session_state.history.append(Message("human", human_prompt))
|
68 |
+
st.session_state.history.append(
|
69 |
+
Message(
|
70 |
+
"ai", llm_response["answer"], documents=llm_response["source_documents"]
|
71 |
+
)
|
72 |
)
|
73 |
+
st.session_state.token_count += cb.total_tokens
|
74 |
+
# history_id = insert_chat_history(conn, human_prompt, llm_response["answer"])
|
75 |
+
# insert_chat_history_articles(conn, history_id, llm_response["source_documents"])
|
|
|
76 |
|
77 |
|
78 |
load_css()
|