Search by

hryvinskyi / magento2-cookie-consent-llm

hryvinskyi

Connects hryvinskyi/magento2-cookie-consent with hryvinskyi/magento2-llm: suggests a category, a provider and a description for storage names seen on the storefront

Package info

github.com/hryvinskyi/magento2-cookie-consent-llm

Type:magento2-module

pkg:composer/hryvinskyi/magento2-cookie-consent-llm

Statistics

Installs: 0

Dependents: 0

Suggesters: 1

Stars: 0

Open Issues: 0

1.0.0 2026-11-30 18:52 UTC

This package is auto-updated.

Last update: 2026-11-30 20:08:34 UTC


README

Connects hryvinskyi/magento2-cookie-consent with hryvinskyi/magento2-llm: suggests a category, a provider and a description for storage names seen on the storefront, and helps with tracker and banner texts in the admin.

What it does for a store

  • Suggests what an observed name is. The consent module's advising run asks this module's advisor (ai, after the built-in catalogue) about names waiting in Observed: the model chooses one of the store's active categories (never the essential one) and writes who sets the name and what it is for. A suggestion is data the consent module checks; it becomes a tracker only when a person accepts it, or through the consent module's automatic declaration and its limits.
  • Writes and translates texts in the admin. "Suggest a purpose" in Observed and Declaration, "Translate" in Declaration and "Translate with AI Models" in the consent setup wizard's Texts step. Nothing is saved until the form or the wizard is.
  • Every call goes through the AI module: its provider, key, daily limits, money budget and call journal. With the AI module off or not set up, the buttons say so and point to its setup.

Requirements

  • hryvinskyi/magento2-cookie-consent and hryvinskyi/magento2-llm (with at least one of its provider modules), the platform's Store and Config modules, psr/log, PHP 8.2 or higher with ext-intl and ext-mbstring (what composer.json and etc/module.xml declare).
  • The calls run from the admin, a cron job or a console command only, never in a storefront request.

Installation

composer require hryvinskyi/magento2-cookie-consent-llm
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:flush

Then switch the three features on in System › AI Models › Setup (Features step) or on the Usage page.

Configuration

Stores › Configuration › Hryvinskyi Extensions › Cookie Consent › AI Assistance: Store view for AI suggestions (hryvinskyi_cookie_consent/ai_assistance/description_store, default scope). The model chooses among that store view's active categories and writes descriptions in its language; empty follows whichever store view is the default.

What it adds

All in the global etc/di.xml:

  • the three features below in the AI module's FeatureRegistry (features);
  • the advisor ai (Model\ModelAdvisor) in the consent module's AdvisorPool;
  • the text-help provider ai (Model\TextHelp, sort order 100) in the consent module's textHelpProviders, with its wording (Model\TextHelpWordingInterface → Model\TextHelpWording).

Features

The module registers three features with the AI module. Each is off until switched on in the AI settings, and each has its own daily limit (200 attempts a day by default).

Feature (key) Runs What leaves the store
Suggest a purpose (cookie_consent_describe) When someone presses "Suggest a purpose" in Observed or Declaration, and as the description step of the background run For a name in Observed: the name, its kind, the host of the script that wrote it, a few similar declared trackers (pattern, category, provider), the offered categories (code, name, description) and the language to write in. For a tracker in Declaration: its pattern, kind and provider, its category's name and description, its purpose in the default language and the language to write in. The background run also sends a page path the name was seen on.
Translate a text (cookie_consent_translate) When someone presses "Translate" in Declaration or in the Texts step of the setup The text, its kind and the two languages. One text per request: translating the banner and the categories of one store view takes one request per text.
Sort waiting names in the background (cookie_consent_categorise) In the consent module's advising run, on names waiting in Observed A storage name, its kind, the host of the script that wrote it, a page path, a few similar declared trackers, and the categories' codes with their descriptions.

Never a value of a cookie and never anything about a visitor. The background run is a feature of its own so it can be switched off and limited apart from the buttons.

Answers

What a model writes is data: it is never executed, never shown as markup and never read as an instruction.

  • A provider, a purpose or a retention holding <, > or a control character is dropped; a provider link that is not an absolute https:// address is dropped; the texts are cut to their limits.
  • A suggested category is kept only when it is one of the codes offered for that request; the essential category is never offered.
  • A translation is used only as plain text within the kind's length and line-break rules, not empty, and not the source repeated between two different languages. Anything else is reported as unusable.
  • Nothing is saved: a suggestion or a translation fills the form, and is saved only when the form is.

Buttons in the consent pages

The module implements the consent module's text-help provider (Model\TextHelp) and joins its textHelpProviders list together with its words (Model\TextHelpWording). The consent pages draw every button themselves and take every word from here.

Screen Button What it sends (feature)
Observed, a waiting name's drawer "Suggest a purpose", then "Suggest another" The name, its kind, the host of the script that wrote it, a few similar declared trackers and the offered categories (cookie_consent_describe). It fills the purpose and may propose a category.
Declaration, a tracker's drawer in the default language "Suggest a purpose", then "Suggest another" The tracker's pattern, kind and provider, its category's name and description, and its purpose in the default language (cookie_consent_describe).
Declaration, a tracker's drawer in another language "Translate" The purpose, its kind and the two languages (cookie_consent_translate).
Setup › Texts, a store view shown texts in another language "Translate with AI Models" Each text of the banner and of the categories in its own request, one after another: the text, its kind and the two languages (cookie_consent_translate).

While a request runs the button reads "Writing…" (the Texts step also counts: "Translating… 3 of 12"). An answer fills the field and is marked "Suggested by AI Models" with "Read it before you add it." (Observed, with "Discard") or "Read it before you save."; nothing is saved until the form or the wizard is.

When an action cannot run, its feature's state says why:

State What the screen shows
AI Models switched off, or nothing set up "AI Models is not set up, so purposes are written by hand." (Texts: "…so texts are translated by hand.") with a link to the AI setup wizard for an admin allowed to set it up; anyone else reads "Ask an administrator to set up AI Models."
The feature switched off "Suggesting purposes is switched off in AI Models." / "Translating texts is switched off in AI Models.", with "Change" to the AI Models Usage page for an admin who may open it and switch features (Hryvinskyi_Llm::usage and Hryvinskyi_Llm::setup)
The provider refused the key "Not available: the AI provider refused the key.", with "Open AI Models" to the Usage page for an admin who may open it (Hryvinskyi_Llm::usage)
The month's money budget used up "Paused until (UTC): this month's AI budget is used up.", with "Open AI Models" as for a refused key
The feature's daily limit spent "Today's limit is reached. Try again tomorrow."

A request that gave no text says why, and the field keeps what was typed: "No answer. Press again to try once more.", "Try again in a moment.", "The model declined to write this.", "The answer could not be used. Write it by hand or try again.", "Something went wrong. Try again later.".

Translations

The admin wording ships in en_US and 25 more locales: the official languages of the European Union, Norwegian Bokmål and Ukrainian. The translations are machine-made; have them read by a native speaker before a store relies on them.

Tests

  • Unit: vendor/bin/phpunit -c app/code/Hryvinskyi/CookieConsentLlm/phpunit.xml.dist.
  • Integration: the platform's harness in dev/tests/integration; the tests answer through scripted protocols and never reach a provider.
  • Browser flows: Test/E2e/, run with the @hryvinskyi/magento2-e2e package from the shop's e2e/ directory.