INNER CODE UNIT · Python

process_rag_stream

mfmezger/conversational-agent-langchain · frontend/assistant.py:57

async def process_rag_stream(
    stream: AsyncGenerator[str, None],
    status_container: st.delta_generator.DeltaGenerator,
    message_placeholder: st.delta_generator.DeltaGenerator,
) -> tuple[str, list]:
    """Process the RAG stream response."""
    full_response = ""
    documents = []
    async for line in stream:
        if line:
            data = json.loads(line)
            event_type = data.get("type")

            if event_type == "status":
                status_container.write(data.get("data"))

            elif event_type == "content":
                content = data.get("data")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…