Skip to main content

parse_text_response

Function parse_text_response 

Source
pub(super) async fn parse_text_response<'a>(
    lines: Pin<Box<LinesStream<StreamReader<BoxStream<'a, Result<Bytes, Error>>, Bytes>>>>,
    full_response_text: Arc<Mutex<String>>,
    response_id: String,
) -> BoxStream<'a, ChatbotResult<TurnEvent>>
Expand description

Parses the rest of a round already classified as a text answer, to the end of the Azure stream.

Yields TurnEvent::Delta per streamed token, TurnEvent::Item for the non-message items that accompany it, and TurnEvent::Done with the finished answer, which the caller stores. Every delta is also appended to full_response_text, so that the cancellation guard knows what it may still save for a turn that never reaches Done. Errors if Azure reports a failure, if a tool call arrives mid-answer, or if the stream ends unfinished.