Spaces:
Sleeping
Sleeping
Commit
·
41b589c
1
Parent(s):
dca80da
clean: rename callback && format
Browse files
app.py
CHANGED
@@ -59,8 +59,8 @@ def initialize_session_state():
|
|
59 |
)
|
60 |
|
61 |
|
62 |
-
def
|
63 |
-
with st.spinner(
|
64 |
with get_openai_callback() as cb:
|
65 |
human_prompt = st.session_state.human_prompt.strip()
|
66 |
if len(human_prompt) == 0:
|
@@ -69,7 +69,9 @@ def on_click_callback():
|
|
69 |
st.session_state.history.append(Message("human", human_prompt))
|
70 |
st.session_state.history.append(
|
71 |
Message(
|
72 |
-
"ai",
|
|
|
|
|
73 |
)
|
74 |
)
|
75 |
st.session_state.token_count += cb.total_tokens
|
@@ -134,7 +136,7 @@ with chat_column:
|
|
134 |
cols[1].form_submit_button(
|
135 |
"Submit",
|
136 |
type="primary",
|
137 |
-
on_click=
|
138 |
)
|
139 |
|
140 |
if st.session_state.token_count == 0:
|
|
|
59 |
)
|
60 |
|
61 |
|
62 |
+
def send_message_callback():
|
63 |
+
with st.spinner("Wait for it..."):
|
64 |
with get_openai_callback() as cb:
|
65 |
human_prompt = st.session_state.human_prompt.strip()
|
66 |
if len(human_prompt) == 0:
|
|
|
69 |
st.session_state.history.append(Message("human", human_prompt))
|
70 |
st.session_state.history.append(
|
71 |
Message(
|
72 |
+
"ai",
|
73 |
+
llm_response["answer"],
|
74 |
+
documents=llm_response["source_documents"],
|
75 |
)
|
76 |
)
|
77 |
st.session_state.token_count += cb.total_tokens
|
|
|
136 |
cols[1].form_submit_button(
|
137 |
"Submit",
|
138 |
type="primary",
|
139 |
+
on_click=send_message_callback,
|
140 |
)
|
141 |
|
142 |
if st.session_state.token_count == 0:
|