imio.omnia.core
Shared infrastructure for the Omnia AI-assisted features suite in Plone 6.
This package provides settings management, a shared tabbed control panel, an “AI assistant” content menu, HTTP client services wrapping the Omnia APIs, extensibility interfaces, and branding assets. Other imio.omnia.* packages (imio.omnia.tinymce, imio.omnia.classification, etc.) build on top of it.
Installation
Add the egg to your buildout:
[buildout]
...
eggs =
imio.omnia.core
Then run bin/buildout.
The package is auto-included in Plone via z3c.autoinclude.plugin, so no ZCML slug is needed.
Sub-packages that depend on imio.omnia.core should declare a GenericSetup dependency in their profiles/default/metadata.xml:
<?xml version="1.0"?>
<metadata>
<version>1000</version>
<dependencies>
<dependency>profile-imio.omnia.core:default</dependency>
</dependencies>
</metadata>
Configuration
Registry settings
Stored under the prefix imio.omnia.IOmniaCoreSettings:
Field |
Purpose |
|---|---|
core_api_url |
Omnia Core API base URL |
openai_api_url |
Omnia OpenAI-compatible gateway base URL |
openai_extra_headers |
Additional HTTP headers for the OpenAI-compatible API (dict) |
application_id |
Application identifier (sent as x-imio-application header) |
organization_id |
Default organization / municipality ID (x-imio-municipality) |
enable_proxy |
Enable @@omnia-api proxy endpoint (default: False) |
enable_openai_proxy |
Enable @@omnia-openai-api streaming proxy (default: False) |
api_timeout |
Timeout for outbound HTTP requests, in seconds (default: 30) |
core_auth_type |
Core API authentication: none / oauth2 (default) |
openai_auth_type |
Gateway authentication: none / api_key / oauth2 (default) |
openai_api_key |
Bearer token used when openai_auth_type is api_key |
oauth_grant_type |
password (ROPC, default) or client_credentials |
oauth_client_id |
Keycloak client ID |
oauth_client_secret |
Keycloak client secret |
oauth_token_url |
Token endpoint of the SSO-Apps realm |
oauth_scope |
Optional scope, usually empty |
oauth_client_auth_method |
client_secret_basic (default) or client_secret_post |
oauth_username |
Service-account username (password grant only) |
oauth_password |
Service-account password (password grant only) |
These settings are editable via the Omnia control panel at @@omnia-ai-settings (Site Setup > Omnia).
Authentication
Each service picks its own scheme, so the two APIs can move independently:
core_auth_type — oauth2 (default) or none.
openai_auth_type — oauth2 (default), api_key (sends the static openai_api_key as a Bearer token), or none.
With oauth2, outbound requests carry a Bearer token obtained from the Keycloak SSO-Apps realm. The token is fetched and refreshed by a process-level shared client, so it is acquired once per instance rather than per request. Both grant types are supported: password (ROPC, using oauth_username / oauth_password) and client_credentials.
As a safeguard, setting openai_auth_type to oauth2 while openai_api_url points outside imio.be raises ValueError instead of sending an iMio SSO-Apps token to a third-party provider.
Environment variables
Settings can also be driven by environment variables. They are synced to the Plone registry when the imio.omnia.core profile is installed and on every Zope startup (the startup sync requires SITE_ID to locate the Plone site):
Variable |
Registry field |
|---|---|
SITE_ID |
Plone site ID in the ZODB (not stored in registry) |
OMNIA_CORE_API_URL |
core_api_url |
OMNIA_OPENAI_API_URL |
openai_api_url |
OMNIA_OPENAI_API_KEY |
openai_api_key |
OMNIA_APPLICATION_ID |
application_id |
OMNIA_ORGANIZATION_ID |
organization_id |
SSO_APPS_CLIENT_ID |
oauth_client_id |
SSO_APPS_CLIENT_SECRET |
oauth_client_secret |
SSO_APPS_URL |
oauth_token_url |
SSO_APPS_USER_USERNAME |
oauth_username |
SSO_APPS_USER_PASSWORD |
oauth_password |
OMNIA_MCP_URL |
mcp_url of imio.omnia.assistant |
OMNIA_MCP_URL fills a record of imio.omnia.assistant: the sync skips it when the assistant isn’t installed. Installing the assistant doesn’t run the sync, so a new site gets the value on the next Zope startup.
Set them in buildout.cfg under [instance] environment-vars or export them in your shell before starting Plone.
The SSO_APPS_* names are shared across iMio applications, so one set of variables configures every Omnia-enabled instance of a deployment.
Only free-text settings are configurable this way. The fields backed by a vocabulary — core_auth_type, openai_auth_type, oauth_grant_type, oauth_client_auth_method — keep their defaults (oauth2, password, client_secret_basic) and are changed in the control panel, so a typo in a deployment environment can never persist a value the form would reject.
Extending imio.omnia.core
Adding a control panel tab
Each Omnia sub-package can contribute a tab to the shared control panel. The tabbed layout is rendered by OmniaCoreControlPanelFormWrapper, which reads tabs from portal_actions in the omnia_controlpanel_tabs category.
Step 1 — Define a settings schema and form (browser/controlpanel.py):
from imio.omnia.core.browser.controlpanel import OmniaCoreControlPanelFormWrapper
from plone.app.registry.browser.controlpanel import RegistryEditForm
from plone.z3cform import layout
from zope import schema
from zope.interface import Interface
from my.package import _
class IMySettings(Interface):
my_option = schema.TextLine(
title=_("My option"),
required=False,
)
class MyControlPanelForm(RegistryEditForm):
label = _("My add-on settings")
schema = IMySettings
MyControlPanelView = layout.wrap_form(
MyControlPanelForm, OmniaCoreControlPanelFormWrapper
)
Step 2 — Register the view (browser/configure.zcml):
<browser:page name="my-addon-settings" for="Products.CMFPlone.interfaces.IPloneSiteRoot" class=".controlpanel.MyControlPanelView" permission="cmf.ManagePortal" layer="my.package.interfaces.IMyBrowserLayer" />
Step 3 — Register the tab (profiles/default/actions.xml):
<?xml version="1.0"?>
<object name="portal_actions" meta_type="Plone Actions Tool"
xmlns:i18n="http://xml.zope.org/namespaces/i18n">
<object name="omnia_controlpanel_tabs" meta_type="CMF Action Category">
<object name="my.package" meta_type="CMF Action">
<property name="title" i18n:translate="">My add-on</property>
<property name="url_expr">string:${portal_url}/@@my-addon-settings</property>
<property name="icon_expr">string:gear</property>
</object>
</object>
</object>
Step 4 — Register the settings in the Plone registry (profiles/default/registry/main.xml):
<?xml version="1.0"?>
<registry>
<records interface="my.package.browser.controlpanel.IMySettings"
prefix="my.package.IMySettings" />
</registry>
Using the API services
Two HTTP client services wrap the upstream Omnia APIs. Both are multi-adapters on (context, request) and automatically send x-imio-application and x-imio-municipality headers resolved from the registry and the IOrganizationIDProvider adapter.
IOmniaCoreAPIService
Wraps the Omnia Core AI agents API (/imio/omnia/core/v1/agents/) and the Omnia Core OCR API (/imio/omnia/core/v1/ocr/).
Available methods:
expand_text(input, expansion_target=50)
improve_text(input)
reduce_text(input, reduction_target=30)
correct_text(input)
make_accessible(input)
translate_text(input, target_language)
suggest_titles(input)
convert_meeting_notes_to_minutes(meeting_name, meeting_notes)
categorize_content(input, vocabulary, unique=False)
deduce_metadata(input=None, image_url=None, image_file=None)
ocr_markdown(file=None, document_url=None, pages=None, extract_header_footer=False, table_format=None, image_descriptions=False, confidence=False, timeout=None)
ocr_extractions(output_schema, file=None, document_url=None, strict=True, instructions=None, pages=None, extract_header_footer=False, table_format=None, image_descriptions=False, confidence=False, timeout=None)
send(method, path, timeout=None, **kwargs) / post_json(path, payload) for raw calls
Usage:
from zope.component import getMultiAdapter
from imio.omnia.core.interfaces import IOmniaCoreAPIService
service = getMultiAdapter((context, request), IOmniaCoreAPIService)
result = service.improve_text("Le projet va bien.")
# result is a parsed JSON dict from the upstream API
Every call uses the api_timeout registry setting (30 seconds by default). send accepts a timeout in seconds for one call.
OCR
ocr_markdown converts a document to Markdown. ocr_extractions also extracts structured data that follows a JSON Schema. Both take exactly one document source and raise ValueError otherwise:
file: a (filename, content, content_type) tuple, where content is bytes or a binary file object (50 MB maximum);
document_url: a public https URL.
Options:
pages: zero-based page ranges, for example "0-4,7";
extract_header_footer, image_descriptions, confidence: booleans;
table_format: "markdown" or "html";
output_schema (ocr_extractions only): a JSON Schema of type object, as a dict or as a JSON string;
strict (ocr_extractions only): make the result follow the schema exactly (default True);
instructions (ocr_extractions only): extraction instructions, 2000 characters maximum;
timeout: seconds. An OCR call can last several minutes, so the default is 330 seconds (imio.omnia.core.services.OCR_TIMEOUT) and not the api_timeout registry setting.
An option left at its default value is not sent to the API.
Usage:
with open("/path/to/report.pdf", "rb") as pdf:
result = service.ocr_markdown(
file=("report.pdf", pdf, "application/pdf"),
pages="0-4",
)
result["markdown"] # Markdown of the whole document
result["pages"] # [{"index", "markdown", "header", "footer", "confidence"}, ...]
result["page_count"]
result["model"]
result = service.ocr_extractions(
{
"type": "object",
"properties": {"total": {"type": "number"}},
"required": ["total"],
},
document_url="https://example.org/invoice.pdf",
instructions="Read the total amount of the invoice.",
)
result["data"] # {"total": 1250.0}
Errors are raised as httpx2.HTTPStatusError: 413 (document too large), 422 (bad input, or the OCR provider refused the document or the schema), 502, 503 and 504 (the OCR provider did not answer in time). A call that exceeds timeout raises httpx2.TimeoutException.
A result needs two checks before a page shows it:
The API can answer without an error and without text. A damaged PDF file gives pages with an empty markdown.
The Markdown is the output of the OCR model. It can contain the HTML code that the document shows, for example an iframe tag. Sanitise the HTML that you make from it.
IOmniaOpenAIService
Wraps the Omnia OpenAI-compatible gateway (/imio/omnia/openai/v1/).
Available methods:
list_models()
chat_completions(model, messages, stream=False, temperature=None, max_tokens=None, tools=None, tool_choice=None)
Usage:
from zope.component import getMultiAdapter
from imio.omnia.core.interfaces import IOmniaOpenAIService
service = getMultiAdapter((context, request), IOmniaOpenAIService)
result = service.chat_completions(
model="Mistral Large",
messages=[{"role": "user", "content": "Hello"}],
)
Streaming:
for chunk in service.chat_completions(
model="Mistral Large",
messages=[{"role": "user", "content": "Hello"}],
stream=True,
):
# Each chunk is a parsed JSON dict (SSE data frame)
print(chunk)
Overriding organization ID resolution
The IOrganizationIDProvider adapter resolves which organization / municipality ID is sent with every API request. The default implementation reads from the registry (the organization_id setting).
To override the resolution for specific content types, register a more specific adapter:
from zope.component import adapter
from zope.interface import implementer
from imio.omnia.core.interfaces import IOrganizationIDProvider
from my.package.interfaces import IMyContentType
@adapter(IMyContentType)
@implementer(IOrganizationIDProvider)
class MyOrganizationIDProvider:
def __init__(self, context):
self.context = context
def __call__(self):
# Resolve the org ID from the content hierarchy
return self.context.municipality_code
Register in configure.zcml:
<adapter factory=".adapters.MyOrganizationIDProvider" />
Zope’s adapter specificity ensures your adapter is used for IMyContentType objects while the default adapter handles everything else.
Using the proxy view (@@omnia-api)
The @@omnia-api view forwards browser JavaScript requests to the Omnia Core API, adding authentication headers server-side. This avoids exposing API credentials to the browser.
Requirements:
The enable_proxy setting must be True (disabled by default).
The caller must have the imio.omnia.core: Access Omnia API proxy permission (granted to Authenticated by default).
Requests must be POST with a JSON body.
URL pattern: <context_url>/@@omnia-api/<path> where <path> maps to the upstream API path (e.g. /v1/agents/improve-text).
JavaScript example:
const response = await fetch(
`${portalUrl}/@@omnia-api/v1/agents/improve-text`,
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ input: selectedText }),
}
);
const data = await response.json();
Using the streaming proxy (@@omnia-openai-api)
The @@omnia-openai-api view proxies browser requests to the OpenAI-compatible gateway and streams the response back as Server-Sent Events (SSE). This lets browser-side chat widgets stream completions without exposing API credentials or the upstream URL to the client.
Requirements:
The enable_openai_proxy setting must be True (disabled by default).
The caller must have the imio.omnia.core: Access Omnia OpenAI proxy permission (granted to Authenticated by default).
Cross-origin requests are rejected: when an Origin header is present, its host must match the portal’s.
Requests must carry plone.protect’s CSRF token in an X-CSRF-TOKEN header (or an _authenticator parameter); otherwise the proxy answers 403.
No Authorization header is needed: a same-origin fetch() sends the visitor’s session cookie, and Zope checks the permission.
Token generation (server-side, e.g. in a viewlet):
from plone.protect.authenticator import createToken
token = createToken()
# Pass this token to the browser, e.g. in a JS settings object
For anonymous visitors the token is the same for everyone and stays valid until the keyring rotates (on user login, at most daily). It proves the caller loaded a page from the site; it does not replace rate limiting.
Projects that need anonymous access to @@omnia-openai-api can override the default role mapping in their own GenericSetup rolemap.xml by granting the imio.omnia.core: Access Omnia OpenAI proxy permission to Anonymous.
URL pattern: <context_url>/@@omnia-openai-api/<path> where <path> maps to the upstream API path (e.g. chat/completions).
JavaScript example:
const response = await fetch(
`${portalUrl}/@@omnia-openai-api/chat/completions`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
"X-CSRF-TOKEN": token,
},
body: JSON.stringify({
model: "Mistral Large",
messages: [{ role: "user", content: "Hello" }],
stream: true,
}),
}
);
const reader = response.body.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
for (const line of decoder.decode(value).split("\n")) {
if (!line.startsWith("data: ")) continue;
const data = line.slice(6);
if (data === "[DONE]") break;
const chunk = JSON.parse(data);
process.stdout.write(chunk.choices?.[0]?.delta?.content ?? "");
}
}
Available icons
The following icon names are registered in the Plone icon registry and can be used in icon_expr properties of portal actions:
Icon name |
Description |
|---|---|
omnia.ia.dark |
Omnia IA (dark) |
omnia.ia.light |
Omnia IA (light) |
omnia.monochrome.dark |
Monochrome (dark) |
omnia.monochrome.light |
Monochrome (light) |
omnia.picto.dark |
Pictogram (dark) |
omnia.picto.light |
Pictogram (light) |
omnia.logotype.dark |
Logotype (dark) |
omnia.logotype.light |
Logotype (light) |
omnia.imio.logotype.dark |
iMio logotype (dark) |
omnia.imio.logotype.light |
iMio logotype (light) |
The SVG files are served from ++plone++imio.omnia.core/.
License
The project is licensed under the GPLv2.
Contributors
Antoine Duchêne, antoineduchene@icloud.com
Changelog
2.0 (2026-12-01)
Support Python 3.14: add its classifier and test Plone 6.2 on it. [boulch]
Drop Plone 6.1: the package supports Plone 6.2 and later. Remove the 6.1 classifier, the 6.1 test environments and test_plone61.cfg. buildout.cfg now extends test_plone62.cfg and requirements.txt takes the content of requirements-6.2.txt. The 6.1 GitHub jobs also failed: the Plone 6.1 constraints pin robotframework-browser 19.10.1, whose Playwright does not support Ubuntu 26.04 (ubuntu-latest). [boulch]
Run the plone.meta circular and coverage GitHub jobs on Python 3.12. The shared workflows run tox on Python 3.11, and the tox environments without a pyXY factor took that Python, which python_requires (>=3.12) refuses. [boulch]
Document the plone.meta tox environments in DEVELOP.rst. [boulch]
Declare the packages the code imports in setup.py. [boulch]
Apply the plone.meta pre-commit hooks (pyupgrade, isort, black, zpretty). Remove an unused import and fix a typo in the uninstall profile description. [boulch]
Configure the package with plone.meta: generated tox.ini, pre-commit hooks, pyproject.toml and GitHub Actions workflows. The generated test-matrix.yml (Plone 6.1 and 6.2, Python 3.12 and 3.13) replaces the buildout-based plone-package-test-gha.yml workflow. Add the Python 3.13 and Development Status classifiers, declare the license as GPL-2.0-only. [boulch]
Fill the settings from the environment variables (OMNIA_OPENAI_API_URL, …) when the profile is installed, not only on Zope startup, so a new site gets them without a restart. [thomlamb]
Fill imio.omnia.assistant’s MCP servers URL (mcp_url) from OMNIA_MCP_URL. ENV_MAPPING also takes the full name of a record of another package, skipped when that package isn’t installed. [thomlamb]
Format the code with black. [boulch]
Fix test_sync_env_to_registry_ignores_vocabulary_fields: the database is not opened when no env var is synced, so the connection is not closed. [boulch]
Add a GitHub Actions workflow that runs the tests on Plone 6.2. [boulch]
Use native namespace packages (PEP 420). Remove the pkg_resources namespace declarations. Use importlib.resources in update_locale. Add the Plone 6.2 classifier. [boulch]
Add the missing imio.helpers dependency. [boulch]
Add test_plone62.cfg and requirements-6.2.txt to test on Plone 6.2. [boulch]
DELIBE-321: Add ocr_markdown and ocr_extractions to IOmniaCoreAPIService (Omnia Core OCR endpoints), with a default timeout of 330 seconds, and an optional per-call timeout to send. The audit log input_len now includes the size of uploaded files. [aduchene]
1.3 (2026-10-09)
Breaking: replace the custom HMAC Bearer token of @@omnia-openai-api by plone.protect’s CSRF token (X-CSRF-TOKEN header) and remove imio.omnia.core.tokens. [chris-adam]
1.2 (2026-08-11)
Set Plone as the default SITE_ID when not defined. [boulch]
1.1 (2026-08-03)
Fix an instance startup crash loop: when every mapped environment variable already matched the registry, sync_env_to_registry left the connection joined to a transaction (silencing the fingerpointing audit log writes to the registry unconditionally) and ConnectionStateError aborted Zope startup. [duchenean]
1.0 (2026-08-03)
DELIBE-289: Add configurable API timeout. [duchenean]
OIA-241: Authenticate outbound Omnia API calls with Keycloak SSO-Apps OAuth 2.0 (ROPC / client credentials via authlib), configurable in the control panel, with credentials supplied by the cross-application SSO_APPS_* environment variables. OAuth 2.0 is the default scheme for both the Omnia Core API and the OpenAI gateway. [duchenean]
DELIBE-322: Replace httpx with httpx2 (maintained pydantic fork). [duchenean]
Removed the unused Vite/React scaffold from browser/resources. [duchenean]
1.0a2 (2026-04-03)
Updated package description to better reflect its role as shared infrastructure. [duchenean]
1.0a1 (2026-04-03)
Initial release. [duchenean]
Added OmniaCoreAPIService multi-adapter wrapping the Omnia Core API (/imio/omnia/core/v1/agents/): expand, improve, reduce, correct, translate, make accessible, suggest titles, convert meeting notes, categorize content, and extract metadata. [duchenean]
Added OmniaOpenAIService multi-adapter wrapping the OpenAI-compatible Omnia gateway (/imio/omnia/openai/v1/): model listing and chat completions with streaming SSE support. [duchenean]
Added shared Omnia control panel (@@omnia-ai-settings) with tabbed navigation extensible via omnia_controlpanel_tabs portal actions. [duchenean]
Added “AI assistant” content menu with dynamic action collection via IOmniaActionsProvider utilities. [duchenean]
Added IOrganizationIDProvider adapter interface for context-aware organization ID resolution. [duchenean]
Added environment variable to registry sync on Zope startup (OMNIA_CORE_API_URL, OMNIA_OPENAI_API_URL, OMNIA_APPLICATION_ID, OMNIA_ORGANIZATION_ID). [duchenean]
Added HMAC-signed token generation for securing browser-to-proxy communication. [duchenean]
Added IImioOmniaControlPanelFieldProvider interface for extending the control panel schema from downstream packages. [duchenean]
Added Omnia SVG branding icons. [duchenean]
Added i18n support (en, fr). [duchenean]
Metadata
Release files for imio.omnia.core 2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| imio_omnia_core-2.0.tar.gz | 112.1 kB | Without provenance | Details for imio_omnia_core-2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| imio_omnia_core-2.0-py3-none-any.whl | Python 3 | none | any | Details for imio_omnia_core-2.0-py3-none-any.whl |
Total release size: 229.7 kB
Release files / imio_omnia_core-2.0.tar.gz
| Download URL | imio_omnia_core-2.0.tar.gz |
|---|---|
| Size | 112.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2a5f9a0bc850b7e033e1b4a9743f1fe7586b9cf93ef036a9df84e565bcddf726
|
|
BLAKE2b-256 checksum How to use checksums |
6311fa4a016ec419610804ea4739fdc95eec7e3ef71d07b0fc7d5c4eb2b602b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / imio_omnia_core-2.0-py3-none-any.whl
| Download URL | imio_omnia_core-2.0-py3-none-any.whl |
|---|---|
| Size | 117.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cee65b3e9b9816ebc6db1c99359f8038f478fb69668ab61466c987430379a0b4
|
|
BLAKE2b-256 checksum How to use checksums |
4ba90a3b08e1663bdbcb2a50479efb4e3eb7dd5da9314bd87fc7f56ac95fe475
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for imio.omnia.core 2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.