Skip to main content

Module azure_chatbot

Module azure_chatbot 

Source

Structs§

AISearchOutput
ArrayProperty
ChatbotUserContext
Context about the user and course for a chatbot interaction. Passed to tool implementations so they can access user-specific data.
ContentFilter
ContentFilterResult
ContentFilterResults
GuardedStream 🔒
Custom stream that encapsulates both the response stream and the cancellation guard. Makes sure that the guard is always dropped when the stream is dropped.
IncompleteReason
Response received from LLM API
IncompleteResponse
Incomplete response received from LLM API
JsonItem
LLMRequest
LLMRequestResponseFormatParam
MistralParams
NonThinkingParams
Reasoning
ReasoningOutput
RequestCancelledGuard 🔒
RequestTextOptions
Response
Response received from LLM API
ResponseError
Error object returned by the LLM API on a failed response. Fields are optional so any error shape deserializes rather than crashing the stream parser.
ResponseOutput
Streamed token of the response text
Schema
Defines LLM structured output shape and types
StreamEventError
StreamItem 🔒
ThinkingParams

Enums§

ArrayItem
ChatbotChatStreamEvent
ContentFilterSource
InputItem
JSONType
LLMRequestParams
LLMToolChoice
MessagePhase
Phase determines how to react to the message. Commentary-phase can have e.g. a reasoning preamble, and final answer is self-explanatory.
OutputItem
ParsedResponseLine 🔒
ResponseStreamType
SchemaPropertyType
StreamEvent 🔒
For passing streamed events and data between streaming functions.
SummaryType

Constants§

ALL_EXPECTED_EVENTS 🔒
These are the events we expect to receive from Azure API but will not handle. This list doesn’t include the events we explicitly handle.
CONTENT_FIELD_SEPARATOR
SEARCH_GROUNDING_INSTRUCTION 🔒
Appended to the system prompt when course-material search is enabled, to ground answers in retrieved course material.

Functions§

answer_unfinished_tool_calls 🔒
check_error_should_terminate_stream 🔒
These types of ChatbotErrors shouldn’t be shown to the user and are likely created from an unrecoverable error in our code that should make the stream fail.
error_event_string_from_message 🔒
Creates a ChatbotChatStreamEvent::Error from the message and returns it in string form. Either message or error should be Some. If message is Some, use it as the StreamEvent message. Else, use ChatbotError’s message. error is either a ResponseError received from Azure and stored in ChatbotError, or ChatbotError’s error message, or None.
make_request_and_create_stream
Makes a request to Azure and returns the resulting stream.
parse_text_response 🔒
Streams and parses an LLM response from Azure that contains a text response. Consumes the lines (stream) from Azure, because the stream ends when a text response is finished. Returns a stream to be consumed in the caller.
parse_tool 🔒
Streams and parses a LLM response from Azure that contains function calls. Calls the functions and yields a Vec of function results to be sent to Azure. Consumes the lines (stream), because it ends when a custom function call is made. Returns a stream to be consumed in the caller.
process_output_item
For saving output items that are not text messages or function calls, i.e. that don’t need further processing and are not streamed to the user. Saves reasoning and Azure AI Search items.
send_chat_request_and_parse_stream
Send and parse a Chatbot message and response and stream it to the user. Controls the whole operation.
stream_and_detect_response_stream_type 🔒
Stream from Azure and return the stream when a text response or tool call response is detected. Tool calls and text responses are processed later with differing logic. Returns a stream to be consumed in the caller. Yields the lines (stream) argument, which is the Azure stream.

Type Aliases§

PeekableLinesStream 🔒
A LinesStream that is peekable. Needed to determine which type of LLM response is being received.