Zum Hauptinhalt springen

AI Code Assistant

Purpose and Use Case

The zbsync_ai_code module (requires zbsync_mapper) adds AI-assisted generation and troubleshooting throughout zSYNC: writing/fixing code fields, auto-mapping fields between a Mapper's source and destination, scaffolding a whole pipeline from a description, and explaining a failed pipeline run. It connects directly to your own account with an LLM provider — there is no Zebroo-hosted proxy, and every AI action is billed to that account.

Setup: AI Providers

Before any AI feature works, configure at least one AI Provider (Configuration → AI Providers):

FieldDescription
NameA label for the configuration.
ProviderOpenAI, Anthropic, or Google Gemini.
ModelFree text — defaults per provider when you change Provider, but can be overwritten with any model string that provider supports.
API KeyYour own key from the provider. Masked in the UI; only users in the Manager group can read or write it.
Max TokensResponse length cap sent to the provider (default 4096) — a direct cost lever.
TimeoutHow long to wait for a response, in seconds (default 60).
Is DefaultMarks which configuration is used when a feature doesn't specify one. Multiple configurations can exist side by side.

Until at least one configuration exists, every AI feature fails with "No AI provider configured." Creating/editing configurations (and using any of the wizards below, aside from the floating AI chat) requires the Manager group.

Every generate/auto-map/analyze call is a real API request billed under your configured provider account — there's no caching or batching, so repeated use has a real, ongoing token cost.

Code Assistant

Available on a Mapper row's Code action and on a Python Code Worker's code field, via a "Generate with AI" button.

  • You provide free-text instructions describing what the code should do.
  • For a Mapper row, the AI is given the row's source/destination fields, its action type, the available runtime variables, and its existing code (if any) to improve.
  • For a Python Code Worker, the AI is given the worker's execution mode (whole-dataset vs. per-record), the available runtime variables, and its existing code (if any).
  • The generated code replaces the field's current code immediately — there is no diff or preview step, so review the result before relying on it (Odoo's own field history is the only way to recover the previous version).

Pipeline Generator

Available as a "Create Pipeline" button on the Pipelines list (creates a new pipeline) or a "Create" button on an existing pipeline's form (appends workers to that pipeline).

  • You provide a plain-language description of the integration, plus optional extra instructions.
  • The AI can only choose from zSYNC's real, registered worker types and their actual field/selection options — it cannot invent a worker type or an invalid field value.
  • By design, it never sets Connections, URLs, or other credential references, and it doesn't add Start/Stop workers (those are handled the usual way). Expect a generated pipeline to need connections wired up and configuration double-checked afterward.
  • There is no preview step — the pipeline and its workers are created immediately.

Auto-Map

Available as a "Map" button in a Mapper's mapping-row list.

Prerequisite: the Mapper must already have both a Source and a Destination Backend configured (see Mapper Workers) — without both, Auto-Map raises an error immediately rather than guessing at a shape.

  • Optionally select specific existing rows first to limit and force-update just those.
  • Optionally add free-text instructions for extra guidance (e.g. "map monetary values as strings").
  • An Update Existing toggle controls whether rows whose source field already has a mapping may be overwritten.

Auto-Map sends both backends' field schemas to the AI and asks it to propose Source → Action → Destination mappings, including nested Object/List Object structures where needed, then creates the corresponding Mapping rows — auto-creating placeholder backend fields for any path the AI references that doesn't exist yet. By default it's additive: existing mappings for fields the AI also suggests are left untouched unless Update Existing is enabled (or those rows were explicitly selected beforehand).

Error Analysis

Available as an "Analyze" button on a failed batch's Error tab (shown once an error is present).

  • The AI is given the pipeline and worker context, the error message, the traceback, and the failing record's data where available.
  • It returns a plain-language explanation of the likely root cause, suggested fix steps, and any configuration changes needed.
  • This is suggestion-only — there's no "apply fix" action. You make the actual change yourself based on the analysis.

Usage and Best Practices

Common Pitfalls

  • Generate with AI has no undo beyond Odoo's own change history — since it replaces code immediately, review generated code before running the pipeline against real data.
  • Auto-Map does nothing without backends configured — set up the Mapper's Source/Destination Backend first (see Mapper Workers).
  • Generated pipelines are intentionally incomplete — no connections, credentials, or URLs are ever set by the Pipeline Generator; this is expected behavior, not a bug to work around.
  • Manager-group only — aside from the floating AI chat widget, every wizard above (and provider configuration) requires the Manager group; other users won't see these options.