calute.ui.application#
Chainlit application entry point for Calute UI.
This module provides the main application setup and message handling for the Chainlit-based chat interface. It includes: - ChainlitLauncher class with Gradio-compatible .launch() API - Chainlit lifecycle handlers (on_chat_start, on_message, etc.) - Chat profile management for multi-agent selection - Settings management for runtime configuration - MCP (Model Context Protocol) connection handlers
The module supports dual operation modes: as a library import for application setup, and as a Chainlit module when loaded by the Chainlit runtime.
Example
>>> from calute.ui import launch_application
>>> from calute import Calute
>>> calute = Calute(llm=my_llm, agents=[my_agent])
>>> app = launch_application(executor=calute)
>>> app.launch(server_port=8000)
- class calute.ui.application.ChainlitLauncher(executor: Calute | CortexAgent | CortexTask | Cortex | TaskCreator | DynamicCortex, agent: Agent | Cortex | DynamicCortex | None = None)[source]#
Bases:
objectWrapper class to provide Gradio-like .launch() API for Chainlit.
This class enables backward compatibility with existing code that expects a .launch() method to be called on the UI object. It handles the setup of theme configuration and Chainlit server initialization.
- executor#
The Calute executor instance for processing conversations.
- agent#
Optional agent configuration for specialized behavior.
- launch(server_name: str = 'localhost', server_port: int = 8000, **kwargs)[source]#
Launch the Chainlit application.
Starts the Chainlit server with the configured executor and theme. This method blocks until the server is stopped (e.g., by Ctrl+C).
- Parameters
server_name – Host to bind the server to (default: “localhost”).
server_port – Port to run the server on (default: 8000).
**kwargs – Additional arguments (watch, headless) - currently unused.
- Returns
None - runs the server until stopped.
Note
The method sets up theme files and environment variables before starting Chainlit. The executor config is stored in builtins to survive module reimport by Chainlit.
- calute.ui.application.launch_application(executor: Calute | CortexAgent | CortexTask | Cortex | TaskCreator | DynamicCortex, agent: Agent | Cortex | DynamicCortex | None = None, server_name: str = 'localhost', server_port: int = 8000, **kwargs)[source]#
Launch the Chainlit application with the given executor.
Factory function that creates a ChainlitLauncher configured with the given executor. Returns a launcher object for deferred launch, allowing the caller to customize server settings before starting.
- Parameters
executor – Calute instance or Cortex component for managing conversations. Supported types include Calute, CortexAgent, CortexTask, Cortex, TaskCreator, and DynamicCortex.
agent – Optional agent configuration for specialized behavior. Can be an Agent instance, Cortex, DynamicCortex, or agent ID string.
server_name – Host to bind the server to (passed to launcher).
server_port – Port to run the server on (passed to launcher).
**kwargs – Additional arguments passed to the launcher.
- Returns
ChainlitLauncher object with .launch() method for starting the server.
Example
>>> app = launch_application(executor=calute, agent=my_agent) >>> app.launch(server_port=3000) # Start on custom port