Expand description
§Chat Completions functionality and route handler.
Structs§
- Streamer
- A streaming response handler.
Enums§
- Chat
Completion Responder - Represents different types of chat completion responses.
Constants§
- DEFAULT_
CHANNEL_ BUFFER_ SIZE - Default buffer size for the response channel used in streaming operations.
- DEFAULT_
KEEP_ ALIVE_ INTERVAL_ MS - Default keep-alive interval for Server-Sent Events (SSE) streams in milliseconds.
Functions§
- chatcompletions
- OpenAI-compatible chat completions endpoint handler.
- create_
chat_ streamer - Creates a SSE streamer for chat completions with optional callbacks.
- create_
response_ channel - Creates a channel for response communication.
- get_
keep_ alive_ interval - Gets the keep-alive interval for SSE streams from environment or default.
- handle_
chat_ completion_ error - Helper function to handle chat completion errors and logging them.
- match_
responses - Matches and processes different types of model responses into appropriate chat completion responses.
- parse_
request - Parses and validates a chat completion request.
- process_
non_ streaming_ chat_ response - Processes non-streaming chat completion responses.
- send_
request - Sends a request to the model processing pipeline.
Type Aliases§
- OnChunk
Callback - A callback function that processes streaming response chunks before they are sent to the client.
- OnDone
Callback - A callback function that is executed when the streaming response completes.