INNER CODE UNIT · Python
handle_rag_response_async
mfmezger/conversational-agent-langchain · frontend/assistant.py:83
async def handle_rag_response_async(prompt: str) -> None:
"""Handle the RAG response generation and display asynchronously."""
with st.chat_message("assistant"):
message_placeholder = st.empty()
status_container = st.status("Processing...", expanded=True)
try:
# Use the streaming endpoint via client
stream = client.chat_stream(messages=[{"role": "user", "content": prompt}], collection_name="default")
full_response, documents = await process_rag_stream(stream, status_container, message_placeholder)
message_placeholder.markdown(full_response)
status_container.update(label="Finished", state="complete", expanded=False)
display_sources(documents)
# Add assistant response to chat history