Skip to main content

agent

AI agent for chat.

def create_chat_agent(model: str | None = None, model_provider: str = 'anthropic', model_name: str = 'claude-sonnet-4-5', timeout: float = 60.0, mcp_server: pydantic_ai.mcp.MCPServerStreamableHTTP | None = None) -> pydantic_ai.agent.Agent | None

Create the main chat agent for JupyterLab.

Args: model: Optional full model string (e.g., "openai:gpt-4o", "azure-openai:gpt-4o-mini"). If not provided, uses model_provider and model_name. model_provider: Model provider name (default: "anthropic") model_name: Model/deployment name (default: "claude-sonnet-4-5") timeout: HTTP timeout in seconds for API requests (default: 60.0) mcp_server: Optional MCP server connection for Jupyter tools

Returns: Configured Pydantic AI agent, or None if creation fails (e.g., missing API keys)

Note: For Azure OpenAI, requires these environment variables: