Search by

x-dep / ai-bundle

x-dep

Russian-language AI assistant core for Symfony: model provider gateway, tools and widgets, dialog turns, conversation storage port, budgets and per-person limits, call journal, admin pages

Package info

github.com/x-dep-labs/ai-bundle

Documentation

Type:symfony-bundle

pkg:composer/x-dep/ai-bundle

Statistics

Installs: 111

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 1

v2.2.0 2026-12-02 11:40 UTC

This package is auto-updated.

Last update: 2026-12-02 11:43:02 UTC


README

A Russian-language AI assistant core for Symfony: everything the person and the model see (prompts, refusals, notes, admin pages) is in Russian, and the documentation in docs/ is in Russian too.

The bundle is the single path from a Symfony application to an LLM provider. It runs a chat turn end to end — budget and limits, masking of personal data, tools that show the person their own data, answers grounded in your knowledge base, call journal, admin pages — so the project only writes business logic.

Features

  • Gateway. One service talks to the provider (adapter AiTunnelGateway for the AITunnel API: streamed chat completions, decisions for the classifier, key and cost lookups). Only models listed in the configuration are called; upstream providers that store requests are filtered out by default.
  • Chat turn. TurnRunner streams stages and text to your UI, picks tools, applies the rules below and returns one of seven outcomes (answered, handed off to a human, refused, failed, interrupted, cancelled, waiting).
  • Conversation storage. The Conversation facade loads the history, runs the turn and appends both messages to a store of your choice: x-dep/chat-bundle (conversations, messages and photos with owner and retention), your CRM via the ConversationStore port, or nothing at all. The bundle's own table (conversation_store: doctrine) is deprecated since 2.1 and goes away in 3.0.
  • Photos. A skill with images accepts photos in a turn: a vision model answers only with values of your schema (#[AsImageInspector]), your code decides (ImageVerdict), and the chat model gets notes instead of the photo. A document or a bank card in the frame refuses the message. TurnRunner::inspect() checks photos without a turn — for example, to fill a form from a photo.
  • Grounded answers. A skill with grounding answers only from evidence found by grounding providers (for example x-dep/rag-bundle); an answer that does not cite the evidence never reaches the person and the question goes to a human.
  • Tools and widgets. The model only chooses a tool; the person gets a widget built by your service, and the model never sees its data. Personal cards take the owner from the server session only.
  • Budget and limits. The budget is closed until set; per-day/week/month limits, per-skill shares, a guests' limit, per-person rate and spend limits, a per-turn cap. Every call reserves its upper cost before it is made.
  • Protection. Format-based masking of phones, e-mails, card and document numbers before the model, search, journal and logs; an optional classifier for off-topic, jailbreak and abuse with configurable actions and growing blocks.
  • Journal and admin pages. One row per provider call (tokens, roubles, timings, outcome — never texts), cost reconciliation, kill switches with a mandatory reason, skill settings with versions, spend charts, offenders.

Requirements

  • PHP 8.4+
  • Symfony 7.4 or 8.1+
  • Doctrine ORM 3.5+ / DBAL 4, DoctrineMigrationsBundle
  • MySQL 8.0 or 8.4 (SQLite is for tests only; PostgreSQL is not supported — the migration aborts with a message)
  • An AITunnel API key and base URL for real answers; without them the bundle still works, but every call is refused with no_key

Installation

composer require x-dep/ai-bundle

Symfony Flex registers the bundle. Minimal configuration:

# config/packages/xdep_ai.yaml
xdep_ai:
    api_key: '%env(default::trim:file:XDEP_AI_KEY_FILE)%'   # read from a secret file, never inline
    base_url: 'https://api.aitunnel.ru/v1'                  # example; there is no default
    models:
        deepseek-v4.1-flash:
            title: DeepSeek V4.1 Flash
            input_price: 30          # roubles per million tokens, upper bound
            output_price: 160
    budget:
        day_rub: 100
    skills:
        consultant:
            title: Консультант
            model: deepseek-v4.1-flash
            prompt: Ты — помощник интернет-магазина. Отвечай коротко и по делу.
# config/routes/xdep_ai.yaml
xdep_ai_admin:
    resource: '@XDepAiBundle/config/routes.php'
    prefix: /admin/ai

Grant ROLE_XDEP_AI_ADMIN to the people who manage the assistant, then create the tables:

php bin/console doctrine:migrations:migrate

A turn with storage (x-dep/chat-bundle or your own conversation_store):

$reply = $conversation->reply($conversationId, 'consultant', $userText, Subject::person($userId, $label), $listener);
$reply->result->text;   // what the person sees

Step-by-step instructions, including the key file, security and a chat controller template: docs/install.md.

Documentation (in Russian)

Document Contents
docs/install.md requirements, installation, configuration, key, budget, admin pages, first turn
docs/conversations.md conversation storage: Conversation, ConversationStore, CRM adapter, contract test, retention
docs/extending.md tools and widgets, personal cards, grounding, quick actions, admin sections, eval sets
docs/guarantees.md what the bundle guarantees (each backed by a test), what it does not, dangerous spots
docs/budget.md budget, limits, classifier and offenders, alerts
docs/operations.md kill switches, provider failures, cost reconciliation, cleanup, upgrades, incidents
CHANGELOG.md changes by version
UPGRADE.md upgrading between major versions
docs/bundle-development.md for contributors: principles, checks, releases

Tests

Tests are not part of the Packagist archive. Clone the repository to run them:

git clone https://github.com/x-dep-labs/ai-bundle.git && cd ai-bundle
composer install
make test          # or vendor/bin/phpunit

The suite never calls a provider: the gateway is tested on recorded streams. MySQL-specific tests (budget race, migrations, store contract) run with make test-mysql.

License, security, contributing