class documentation

class ZMSLLMConnector(ZMSItem.ZMSItem): (source)

Constructor: ZMSLLMConnector(id)

Implements interfaces: Products.zms.IZMSConfigurationProvider.IZMSConfigurationProvider, Products.zms.IZMSLLMConnector.IZMSLLMConnector, Products.zms.IZMSRepositoryProvider.IZMSRepositoryProvider

View In Hierarchy

ZMS LLM Connector – bridges ZMS to AI/LLM provider backends.

Method __init__ Constructor.
Method chat Send messages to the configured LLM provider.
Method chat_with_tools Agentic chat loop with ZMS tool calling.
Method get_ollama_models Fetch the list of locally available models from the configured Ollama server.
Method get_provider_info Return information about the currently configured LLM provider.
Method getAvailableLLMToolsConnectors Return available ``*_llmtools`` / ``*_connector`` ZMSLibrary meta-objects.
Method getConfProperty Return a configuration property for this connector.
Method getEnabledFeatures Return a dict of enabled AI feature flags.
Method isFeatureEnabled Check whether a specific AI feature is enabled.
Method manage_changeConfig Save connector configuration fields from the Config tab form.
Method manage_changeFeatures Save feature-flag checkboxes from the Features tab form.
Method manage_changeProperties Backwards-compatible shim: delegates to manage_changeConfig.
Method manage_options Return management options delegating to the parent ZMS object.
Method manage_sub_options Contribute the LLM tab to the ZMS main tab bar.
Method provideRepository Export connector configuration for repository.
Method updateRepository Import connector configuration from repository.
Class Variable __ac_permissions__ Undocumented
Class Variable __administratorPermissions__ Undocumented
Class Variable manage Undocumented
Class Variable manage_main Undocumented
Class Variable manage_options_default_action Undocumented
Class Variable manage_sub_options__roles__ Undocumented
Class Variable meta_type Undocumented
Class Variable security Undocumented
Class Variable zmi_icon Undocumented
Instance Variable id Undocumented
Method _as_bool Parse common truthy/falsy values from request-like sources.
Method _prepare_messages Normalize messages and optionally inject HTML-preservation guidance.
Instance Variable _config Undocumented
Instance Variable _p_changed Undocumented
def __init__(self, id='llm_connector'): (source)

Constructor.

def chat(self, messages, **kwargs): (source)

Send messages to the configured LLM provider.

Delegates to ``llmapi`` provider factory using this connector as the configuration context so ``getConfProperty()`` resolves correctly.

Parameters
messagesList of ``{"role": ..., "content": ...}`` dicts or a plain string.
**kwargsOptional overrides: temperature, top_p, max_tokens, etc.
Returns
dictResponse in OpenAI /v1/chat/completions format or error dict.
def chat_with_tools(self, messages, context, max_rounds=5, preserve_html=False): (source)

Agentic chat loop with ZMS tool calling.

Sends ``messages`` plus active tool definitions from ``llmtools.ZMSLLMToolsAdapter`` to the LLM. If the LLM responds with ``tool_calls``, each call is executed through the adapter (custom ``*_llmtools`` profile or built-in fallback), appended as ``tool`` role messages, and the conversation continues until the LLM produces a plain text response or ``max_rounds`` is reached.

Parameters
messagesList of ``{"role": ..., "content": ...}`` dicts or a plain string (auto-wrapped as user message).
contextZMS acquisition context exposing ``metaobj_manager``.
max_roundsMaximum tool-calling iterations to prevent infinite loops.
preserve_htmlUndocumented
Returns
dict

Dict with keys:

  • ``reply`` (str): Final assistant text response.
  • ``turns`` (list): All conversation turns including tool calls/results, each as ``{"role", "content", "tool_calls"?}`` for UI rendering.
  • ``error`` (str): Set only on unrecoverable errors.
def get_ollama_models(self): (source)

Fetch the list of locally available models from the configured Ollama server.

Returns
dictDict with 'models' list (name strings) or 'error'.
def get_provider_info(self): (source)

Return information about the currently configured LLM provider.

Returns
dictDict with provider type, model name, endpoint, etc.
def getAvailableLLMToolsConnectors(self): (source)

Return available ``*_llmtools`` / ``*_connector`` ZMSLibrary meta-objects.

Connectors are discovered from installed ZMSLibrary meta-objects and can be selected via ``llm.llmtools.id`` in connector config.

def getConfProperty(self, key, default=None): (source)

Return a configuration property for this connector.

Reads from connector's own ``_config`` dict first; falls back to the ZMS root confmanager for site-wide defaults.

Parameters
keyProperty key (e.g. 'llm.provider', 'llm.api.key').
defaultValue returned when key is absent.
Returns
Property value or default.
def getEnabledFeatures(self): (source)

Return a dict of enabled AI feature flags.

Keys: rte_assist, translate_assist, metadata_gen, rag_chat. Values: bool.

Returns
dictFeature flag dict.
def isFeatureEnabled(self, feature_key): (source)

Check whether a specific AI feature is enabled.

Parameters
feature_keyOne of 'rte_assist', 'translate_assist', 'metadata_gen', 'rag_chat'.
Returns
boolTrue if the feature is enabled.
def manage_changeConfig(self, btn, lang, REQUEST, RESPONSE=None): (source)

Save connector configuration fields from the Config tab form.

def manage_changeFeatures(self, btn, lang, REQUEST, RESPONSE=None): (source)

Save feature-flag checkboxes from the Features tab form.

def manage_changeProperties(self, btn, lang, REQUEST, RESPONSE=None): (source)

Backwards-compatible shim: delegates to manage_changeConfig.

def manage_options(self): (source)

Return management options delegating to the parent ZMS object.

def manage_sub_options(self): (source)

Contribute the LLM tab to the ZMS main tab bar.

def provideRepository(self, r, ids=None): (source)

Export connector configuration for repository.

def updateRepository(self, r): (source)

Import connector configuration from repository.

__ac_permissions__ = (source)

Undocumented

__administratorPermissions__: tuple[str, ...] = (source)

Undocumented

Undocumented

manage_main = (source)

Undocumented

manage_options_default_action: str = (source)

Undocumented

manage_sub_options__roles__ = (source)

Undocumented

meta_type: str = (source)

Undocumented

security = (source)

Undocumented

zmi_icon: str = (source)

Undocumented

Undocumented

def _as_bool(self, value): (source)

Parse common truthy/falsy values from request-like sources.

def _prepare_messages(self, messages, preserve_html=False): (source)

Normalize messages and optionally inject HTML-preservation guidance.

Undocumented

_p_changed: bool = (source)

Undocumented