pub(super) async fn parse_tool<'a, C>(
conn: C,
app_config: &'a ApplicationConfiguration,
lines: Pin<Box<LinesStream<StreamReader<BoxStream<'a, Result<Bytes, Error>>, Bytes>>>>,
conversation_id: Uuid,
response_id: String,
user_context: &'a ChatbotTurnContext,
calls_from_classification: Vec<OutputItem>,
) -> BoxStream<'a, ChatbotResult<TurnEvent>>Expand description
Streams and parses one tool-call round of a response from Azure, consuming lines.
Runs the calls the server answers, stores each call beside its output, and ends the round by
yielding TurnEvent::Messages with the items the next round is sent. Those items are
converted from the rows this round wrote, not from what it meant to write, so that a round
continued in memory and one replayed from the conversation hand Azure the same prefix. A call
only the client can answer is stored without an output and ends the turn with
TurnEvent::Suspended instead: the answer arrives in a later request, which rebuilds its
input from the conversation.
calls_from_classification are this round’s function calls that arrived before the response
was classified. They have already been streamed to the client; the round takes them over so
that it, and only it, records them.
Takes conn by value rather than by reference so that the caller can hand over the pooled
connection it no longer needs, instead of keeping one borrowed for as long as this stream lives.