ChatPDF
ChatPDF copied to clipboard
How the response from ChatGPT is written in the UI?
I see you have an input field with a callback process_input
:
st.text_input("Message", key="user_input", disabled=not is_openai_api_key_set(), on_change=process_input)
This callback process_input
is:
def process_input():
if st.session_state["user_input"] and len(st.session_state["user_input"].strip()) > 0:
user_text = st.session_state["user_input"].strip()
with st.session_state["thinking_spinner"], st.spinner(f"Thinking"):
query_text = st.session_state["pdfquery"].ask(user_text)
st.session_state["messages"].append((user_text, True))
st.session_state["messages"].append((query_text, False))
Here you are only writing the response from the model into the st.session_state["messages"]
. How the response is getting written the to the UI?
Will appreciate if you can please add an explanation. Thanks.