Files
leocrm/app/plugins/builtins/ai_assistant/contracts.py
T

61 lines
1.6 KiB
Python
Raw Normal View History

2026-07-25 21:03:46 +02:00
"""Public contract for the ai_assistant plugin.
Exposes only the symbols that other builtins plugins need:
- Tool registry (register, unregister, list tools)
- get_default_provider (for LLM provider lookup)
Importers should use::
from app.plugins.builtins.contracts import get_contract
ai = get_contract("ai_assistant")
if ai:
registry = ai.get_tool_registry()
registry.register("my_tool", ...)
instead of importing from internal modules directly.
"""
from __future__ import annotations
from app.plugins.builtins.ai_assistant.services import get_default_provider
from app.plugins.builtins.ai_assistant.tool_registry import (
AITool,
ToolRegistry,
get_tool_registry,
)
from app.plugins.builtins.contracts import get_contract_registry
class AIAssistantContract:
"""Public API surface for the ai_assistant plugin.
Exposes the tool registry and the default-provider lookup so that
other plugins can register AI tools and obtain the tenant's default
LLM provider without importing internal modules.
"""
contract_name = "ai_assistant"
# ─── tool registry ───
get_tool_registry = staticmethod(get_tool_registry)
ToolRegistry = ToolRegistry
AITool = AITool
# ─── provider lookup ───
get_default_provider = staticmethod(get_default_provider)
# ─── self-registration ───
_contract = AIAssistantContract()
get_contract_registry().register("ai_assistant", _contract)
__all__ = [
"AIAssistantContract",
"AITool",
"ToolRegistry",
"get_tool_registry",
"get_default_provider",
]