Skip to main content

begin_turn

Function begin_turn 

Source
async fn begin_turn(
    pool: PgPool,
    app_configuration: &ApplicationConfiguration,
    conversation_id: Uuid,
    user_context: ChatbotTurnContext,
    start: TurnStart<'_>,
) -> ChatbotResult<Pin<Box<dyn Stream<Item = ChatbotResult<Bytes>> + Send>>>
Expand description

Shared preamble of both ways a turn can begin: acquire a connection, repair any tool call a dead turn of this conversation left unanswered, build the request the turn runs with, and hand off to stream_turn — or, on a resume that is still waiting on another call, return the ChatbotChatStreamEvent::Suspended stream without ever reaching it.

Repairing before either path reads the conversation’s history is required, not incidental: an unanswered call from a dead turn makes the LLM reject every later message of the conversation. Only long-dead calls are touched: another request may be streaming a turn of this same conversation.