Skip to main content

chat

Tornado handlers for chat API compatible with Vercel AI SDK.

class TornadoRequestAdapter(handler: jupyter_server.base.handlers.APIHandler) -> None

Adapter to make Tornado request compatible with Starlette Request interface.

__init__(handler: jupyter_server.base.handlers.APIHandler) -> None

Initialize the adapter with a Tornado handler.

Args: handler: The Tornado RequestHandler instance

body() -> bytes

Get request body as bytes.

class ChatHandler(application: 'Application', request: tornado.httputil.HTTPServerRequest, **kwargs: Any) -> None

Handler for /api/chat endpoint.

This handler implements the Vercel AI protocol for streaming chat responses. It receives chat messages and streams back AI responses with support for:

  • Text responses
  • Tool calls
  • Reasoning steps
  • Source citations

post() -> None

Handle chat POST request with streaming.