====== N4V Assistant: configuration (AI and shared templates) ====== The **N4V Assistant** adds two features to the **N4V Settings panel** popup in Webi (N4V 2026.4+): * **The AI Assistant**: the user describes the style they want in plain language ("dark theme", "navy blue titles"), or attaches a screenshot. The assistant proposes widget settings, and the user approves them before they are applied. * **Shared ("Company") templates**: settings templates published once and offered to every popup user, next to their personal templates and the N4V library. Both features are configured from a **web administration console**, with no file to edit and no Tomcat restart. They are independent: you can enable shared templates without the AI. ===== 1. Prerequisites ===== * **Up-to-date N4V FOR WEBI**: the assistant relay is installed with the ''N4VCustomElements'' webapp. * **For the AI only**: an OpenAI-compatible AI engine (''/v1/chat/completions'' API), internal or cloud: * internal (nothing leaves your network): Ollama, vLLM, llama.cpp; * cloud: Mistral (EU), OpenAI, Claude (Anthropic)… * To send **screenshots**, the model must read images: Claude, GPT-4o / GPT-4.1, Mistral Small 3.1+, Pixtral, Qwen2.5-VL, Llama 3.2 Vision, Gemma 3… * **Network access** from the Tomcat server to the AI engine: firewall, and outbound proxy for a cloud engine. * **Several Tomcat servers (cluster)**: a shared network folder that the account running Tomcat on each server can read and write (see §6). ===== 2. Data sent to the AI engine ===== * **Sent**: the user's request, the widget type and name, the relevant settings with their current values, and the conversation history. * **Never sent**: report data. * **Exception**: a screenshot attached by the user is sent to the engine and may show data. This feature is disabled by default; have it approved by your DPO, especially with a cloud engine. The image is neither stored nor logged. * **API key**: it stays on the server and is never sent to the browser. ===== 3. Opening the administration console ===== Address: ''%%https:///N4VCustomElements/n4v-assistant/admin/%%'' ==== First login ==== - **Get the setup code.** The page asks for a one-time code, written in two places: * in the file ''n4v-assistant-setup-code.txt'', in ''N4VCustomElements/WEB-INF/''; * in the Tomcat log, on the line ''[n4v-assistant] Code d'initialisation de la page d'administration : ...''. - **Enter this code**, then choose the **administrator password** (at least 10 characters). - **Log in.** The session lasts 8 hours. After 5 failed logins in 15 minutes, access is temporarily blocked. The password is stored hashed, never in clear text. ==== Console layout ==== The console is available in English or French (EN / FR buttons at the top of the page). ^ Tab ^ Use ^ | **Settings** | all settings, by section (AI engine, security, log, shared templates, cluster, cache, advanced) | | **Business rules** | your company's own rules (corporate style guide…) | | **Shared templates** | manage the "Company" templates | | **Usage** | assistant usage statistics | | **Diagnostics** | AI engine test, answer cache, cluster server status | Each setting has built-in help. Click **Save** at the bottom of the section you changed: the change applies **immediately**, with no restart. ===== 4. Configuring the AI Assistant ===== ==== 4.1 Connecting the engine ==== **Settings** tab → **AI engine** section: - **Known engine…**: pick an engine from the list. The URL, model and temperature are filled in for you. * For an engine not in the list, enter the **Engine URL** without ''/chat/completions'', then the **Model**. - **API key**: required for a cloud engine. It is never shown again; leave the field empty to keep the current key. - Tick **Assistant enabled**. - **Save**. Examples: ^ Engine ^ Engine URL ^ Model (example) ^ | Ollama (internal server) | ''%%http://ai-srv:11434/v1%%'' | ''qwen2.5:7b-instruct'' | | vLLM (internal server) | ''%%http://ai-srv:8000/v1%%'' | name of the served model | | Mistral (EU cloud) | ''%%https://api.mistral.ai/v1%%'' | ''mistral-small-latest'' | | OpenAI | ''%%https://api.openai.com/v1%%'' | ''gpt-4.1-mini'' | | Claude (Anthropic) | ''%%https://api.anthropic.com/v1%%'' | ''claude-haiku-5-5'' | ==== 4.2 Checking ==== - **Diagnostics** tab → **Run the test**. The test checks that the configuration is read, that the engine is reachable, its response time, and that its answer is valid. - In Webi, open the **N4V Settings** popup on an N4V widget: an **Assistant** tab appears. - Try a simple request, for example "dark theme". ==== 4.3 Useful options ==== ^ Section ^ Setting ^ Effect ^ | AI engine | **Screenshots (vision engine)** | Users can attach, paste (Ctrl+V) or drop an image whose style the assistant reproduces. Once applied, the **"Compare with the original and refine"** button compares the rendering with the image and fine-tunes the settings. //Have it approved by your DPO (see §2).// | | AI engine | **Max answer length** | Increase it (8000) if large requests (full theme) are truncated | | Security and limits | **Call control** | ''origin'' (default): calls accepted from the popup on the same server. ''bo'': also requires a valid BO session. | | Security and limits | **Requests per user per hour** | Usage limit (default 60) | | Usage log | **Keep the request text** | Off by default. Useful to analyse usage; have it approved by your DPO. | | Usage log | **Retention (months)** | Automatic purge of old logs (default 12) | | Answer cache | **Cache enabled** | An identical request on a widget in the same state reuses the answer already produced: instant and free. | ==== 4.4 Your company's rules ==== **Business rules** tab: instructions added to every request, or to one widget type. For example, enforce the colours and fonts of your style guide. The rules supplied by Need4Viz are shown read-only. Your rules are never overwritten by an N4V update. ==== 4.5 Monitoring usage ==== **Usage** tab, month by month: * number of requests and errors; * tokens consumed and answers reused by the cache; * breakdown by day, by model and by widget type; * latest requests. **CSV export** button for Excel. ==== 4.6 Disabling the AI ==== Untick **Assistant enabled**: the Assistant tab disappears from the popup. Shared templates remain available if they are enabled. ===== 5. Configuring shared templates ===== ==== 5.1 Enabling ==== **Settings** tab → **Shared templates** section: * Tick **Sharing enabled**. * **BO group allowed to publish**: the group whose members can publish a template from the popup, in addition to the N4V administrators. * ''Everyone'' (default): every popup user can publish. * Another group (e.g. ''N4V Designers''): group membership, parent groups included, is checked in the CMS. In that case, fill in the **BO RESTful URL** in the Security and limits section (default ''%%http://localhost:8080/biprws%%''). * **Templates file**: leave the default, except in a cluster (see §6). * **Save**. This feature does **not** require an AI engine. ==== 5.2 In the popup ==== * **All users** see the shared templates in the template list (**Company** filter), with the mention "Shared by … on …". * **Publishing**: in the list, on one of their personal templates, an authorised user clicks the **Share with all users** icon. The same button then **updates** the shared template; **Remove from sharing** removes it for everyone. * **Changing or removing**: the author (from the browser used to publish) or an N4V administrator. ==== 5.3 Managing from the console ==== **Shared templates** tab: * list of templates (name, widget, published by, last update); * **Rename** or **Remove** a template; * **Export** all templates (JSON file), for example to copy them from a test environment to production; * **Import…** a file exported from this page or from the popup, either added or replacing everything. A backup copy (''n4v-templates-shared.json.bak'') is made on every change. ===== 6. Several Tomcat servers (cluster) ===== When BI Launchpad runs on several Tomcat servers behind a load balancer, the servers must share the same configuration and the same templates. **No change to the Tomcat configuration is needed.** ==== 6.1 How it works ==== Each server keeps a small local file that points to a **shared network folder**. Everything else is stored in that folder and common to all servers: * the configuration and the administrator password; * your company's rules; * the shared templates; * the usage logs. ==== 6.2 Setting it up ==== - **Create the shared folder**, for example ''%%\\file-srv\need4viz%%'' (Windows) or ''/mnt/need4viz'' (Linux). * The account running Tomcat on each server must be able to **read and write** in it. * On Windows, a Tomcat service running as "Local System" cannot reach network shares: use a domain account. - **Configure a first server** from its console, as described in §3 to §5. - **On this first server**, open ''N4VCustomElements/WEB-INF/n4v-assistant.properties'' and add at the top: cluster.sharedDir=\\file-srv\need4viz cluster.nodeId=bo-web-01 * ''cluster.nodeId'' is optional: it defaults to the machine name. * Write the path as is. * Within a few seconds, the configuration is copied to the shared folder. - **On each other server**, ''N4VCustomElements/WEB-INF/n4v-assistant.properties'' contains only these two lines, with that server's own name: cluster.sharedDir=\\file-srv\need4viz cluster.nodeId=bo-web-02 - **Check** in the console: **Diagnostics** tab → **Cluster**. Every server must appear as active, with the same version and the shared folder writable. ==== 6.3 Afterwards ==== * **Everything is set from the console**, on any server; the same password works everywhere. * A change (configuration, rules, templates) is visible on the other servers within **5 seconds**. * Two simultaneous publications on two servers are both kept. * The **Usage** tab adds up all servers. * **Clear the cache** (Diagnostics tab) clears it on every server. ==== 6.4 Variant: sharing only the templates ==== If each server must keep its own configuration, sharing the templates file is enough. In the console **of each server**, **Shared templates** section, set **Templates file** to the path on the share, written with ''/'': //file-srv/need4viz/n4v-templates-shared.json **Important:** without a shared folder or file, each server has its own configuration and its own templates. A template published on one server does not appear on the others. ===== 7. Troubleshooting ===== ^ Symptom ^ What to do ^ | No Assistant tab in the popup | Console → Settings: **Assistant enabled** ticked, URL and model filled in. Then Diagnostics → **Run the test**. | | "Engine unreachable" or timeout | Diagnostics → test. Check the firewall or proxy between the Tomcat server and the engine; increase **Timeout (seconds)** (Advanced section). | | Truncated or invalid answers | Increase **Max answer length**; if the engine rejects JSON mode, set **JSON mode** to ''none'' (Advanced section). | | No image button in the Assistant | Tick **Screenshots (vision engine)** and use a model that reads images. | | Setup code not found | File ''n4v-assistant-setup-code.txt'' in ''N4VCustomElements/WEB-INF/'' (in a cluster: in the shared folder), or the Tomcat log. | | The console keeps returning to the login page | Delete the site cookies or open a private browsing window. | | A user cannot publish a template | Check **BO group allowed to publish** and **BO RESTful URL**; the user must be a member of the group or of a child group. | | Cluster: a server does not appear | Tomcat account rights on the shared folder; the server's ''cluster.sharedDir''; same N4V version on every server. | | Cluster: template not visible on another server | Wait 5 seconds; check that all servers point to the same shared folder. | | The popup did not change after an N4V update | Clear the browser cache. | For any other question: Need4Viz support.