Commit Graph
4 Commits
Author SHA1 Message Date
Davide SilvestriandBram Wiepjes 7c3525dc1a chore(embeddings): update the embeddings server and release it as 1.1.0 (#6300)
* chore(embeddings): replace transformers with tokenizers and drop pip from the image

* chore(embeddings): fix the dev health check and docs, add a changelog entry

* chore(embeddings): port the dependency and threading updates from #6379

Brings over the changes from #6379 that this branch didn't have yet:

- onnxruntime 1.26.0, tokenizers 0.23.3, starlette 1.8.0 and uvicorn 0.54.0,
  plus huggingface_hub 2.2.0 and transformers 5.19.0 in the build stage.
- The model download is pinned to its current revision.
- Inference uses as many threads as the container's CPU limit, which
  EMBEDDINGS_NUM_THREADS overrides.
- Inference runs in a worker thread behind a lock, so /health answers during
  long batches.
- An empty texts list returns 400 instead of 500.
- Helm, its README, Cloudron and the README point to baserow/embeddings:1.1.0.

Co-authored-by: Bram Wiepjes <bramw@protonmail.com>

* chore(embeddings): address review feedback

- The build stage writes tokenizer.json with the 512-token truncation and
  per-batch padding, so app.py only loads it. The build stage uses the
  tokenizers library for this and no longer installs transformers.
- tokenizers is installed with --no-deps. Its only dependency,
  huggingface-hub, is used by from_pretrained, which the app never calls.
- The README's local run installs the image's packages, downloads the model
  with _download_model.py into EMBEDDINGS_MODEL_DIR (default /model), and
  its snippet posts texts instead of text.

* chore(embeddings): fix the issues found while verifying the image

- requirements.txt pins all 13 runtime packages and is installed with
  --no-deps, so rebuilds are reproducible. The builder no longer installs
  git, and the build fails if the app can't be imported.
- Requests are processed 8 texts at a time and limited to 256 texts and a
  1 MiB body, so a single request can't OOM-kill the container anymore.
- Inference holds a lock in its worker thread, and a queued request whose
  client has gone is skipped.
- Malformed input, including lone surrogates, returns 400 instead of 500.
- The app refuses to start with a tokenizer.json that doesn't truncate at
  512 tokens, or with EMBEDDINGS_NUM_THREADS below 1.
- _download_model.py can be re-run.
- The README, docs, Cloudron manifest and changelog match the code, and the
  Cloudron manifest gets a 1.5 GiB memory limit and the /health check.

* chore(embeddings): correct the response size per text in a comment

---------

Co-authored-by: Bram Wiepjes <bramw@protonmail.com>
2026-10-15 14:18:02 +02:00
Davide Silvestri 64c9fff85e feat [6/8]: prepare AI provider management for rollout (#6070)
* feat: retire AI provider flag and add rollout audit

* test: remove obsolete AI provider flag setup and docs

* chore: clean up AI provider configuration and tests

* feat: deprecate legacy AI provider environment configuration

* docs: explain AI provider migration sizing and timing

* docs: mark AI provider migration audit for removal

* docs: explain AI provider migration audit usage

* fix: log AI provider env deprecations after logging setup

log_ai_provider_env_deprecations() ran at the tail of _setup_health_checks(),
which ready() calls before setup_logging(). The notice went out through
loguru's default sink and missed BASEROW_BACKEND_LOG_LEVEL, the Baserow
format, and the OpenTelemetry log exporter, so operators shipping logs to a
collector never saw it.

Also drop two references the flag removal invalidated: the getEffectiveAIAgentModels
JSDoc still described filtering as conditional on the removed provider flag, and
the AI field architecture doc still pointed provider authors at the deleted
legacy workspace-setting hook. That doc now names BuiltInGenerativeAIModelType,
which is what grants an integration override model inheritance.

* fix: reuse environment AI settings in generation workers

* feat: import legacy AI provider settings on upgrade

Removing the ai-providers flag makes database-backed providers the default, which
would leave every existing installation on an empty AI providers page with a
management command as the only way to populate it. A data migration imports the
environment and each workspace's stored settings instead, so a standard upgrade
needs no commands.

Both scopes are imported in one migration. Legacy workspace settings replaced the
instance ones entirely, while database providers inherit, so each imported workspace
is also switched off the instance provider of the same type. Without that a workspace
would silently gain models billed to the instance account.

Settings that cannot fit their columns are skipped and logged rather than raising
DataError and rolling back the whole upgrade. The migration reverses as a no-op
because the previous version does not read these tables, so deleting rows would only
discard edits made during a rollback window.

migrate_ai_provider_settings stays as the recovery path and now shares its planning
logic with the migration, so both agree on which legacy settings are complete. It
deliberately does not switch workspaces off inherited providers, and warns instead.

* chore: remove the temporary AI provider audit command

audit_ai_provider_settings existed to inventory legacy configuration before a manual
import. The upgrade now imports automatically, so the command has no remaining step
to support. Removal was already tracked in #5749.

* docs: reduce AI provider docs to lasting behaviour

The upgrade procedure, rehearsal plan and sizing query described a one-time
transition and do not help anyone after the release; they live in the pull request
instead. What remains explains how providers work: the two scopes, how they combine,
the inheritance switch, what the deprecated environment variables still do, and how
integration overrides and published applications behave.

Also corrects claims that no longer hold: published applications keep materialised
credentials only when they were published before the upgrade, the import is no longer
optional, and a workspace-owned provider suppresses the environment fallback too.

* docs: shorten the AI provider changelog entries

Bullet points render as single list items under the entry. The released entries
average around twenty characters; these ran to four hundred, so the detail belongs
in the AI providers guide rather than the changelog.

* docs: clarify where imported AI credentials are stored

The previous wording implied Baserow's own exports carry provider credentials.
They do not: AIIntegrationType lists ai_settings as a sensitive field and
ImportExportConfig excludes those by default, and AIProviderConfig is not part of
any export path.

* docs: explain the AI provider upgrade and where to configure providers

State that the upgrade imports the BASEROW_* provider variables once and no longer
reads them, list the exceptions, and give the exact navigation for instance admins
(Admin tools -> AI providers) and workspace admins (workspace Settings -> AI
providers). Map each deprecated variable to the field that replaces it.

* fix: renumber the legacy AI provider import after 0121_agent

Develop's core 0121_agent and this branch's import migration both depended on
0120, leaving two leaf nodes, so migrate refused to run and the startup check and
E2E shards failed. The import is now 0122 and depends on 0121_agent.

* feat: remove the legacy workspace generative AI settings endpoint

GET/PATCH /api/workspaces/{id}/settings/generative-ai/ had no caller left, yet a
PATCH was still honoured for any provider type without a workspace provider and
never shown in the AI providers UI. Remove it with the handler parameter,
receivers and frontend handler that only it could trigger.

* fix: stop instance AI provider changes from fanning out per workspace

An instance-level change queued one Celery task per 25 workspaces behind a global
blocking lock, sent a payload to every connected user, and made the premium receiver
serialize every AI field on the instance. Instance changes now notify staff only;
other users see them after a reload. The render lock is per scope, and the in-use
guards no longer read one row per workspace.

* fix: keep inherited Kuma when a workspace switches off the instance provider

The upgrade switches imported workspaces off the same-type instance provider, which
made an inherited instance Kuma model invalid there, so Kuma fell back to the
deprecated env model or turned off. Inheriting the instance Kuma selection now
ignores workspace switch-offs; explicit workspace selections stay strict and are
the only ones that block a switch-off.

* fix: skip malformed Ollama URLs during AI provider migration

* fix: preserve skipped legacy AI provider connections

* test: cover independent legacy AI workspace connections

* fix: skip malformed legacy AI provider settings

* fix: move legacy AI import after current core migrations

The linear rebase omitted the migration renumbering from the previous merge commit, while develop advanced through core 0124. Rename the existing AI import to 0125, depend on 0124, and update its historical migration test so core has a single leaf.
2026-09-25 17:05:10 +02:00
Davide Silvestri 5d3c90f9f6 chore (AI-Assistant): add embeddings to docker-compose.dev.yml; improve installation docs (#4563)
* chore (AI-Assistant): add embeddings to docker-compose.dev.yml; improve installation docs

* Fix flaky test

* Address feedback

* Fix just dev down to stop all services
2026-01-23 14:08:08 +01:00
Davide SilvestriandBram Wiepjes 784c7df891 Switch to udspy (#4153)
* Switch to udspy

* fix search tool and message history

* Added embeddings server docs

* Remove remaining litellm references

* bump udspy version to v0.1.6

* Added docs for setting up the AI-assistant

* fixed table

* port workflow formula generation tools to udspy

* Set a fake OPENAI_API_KEY for tests

* Fix flaky tests

---------

Co-authored-by: Bram Wiepjes <bramw@protonmail.com>
2025-11-12 21:17:24 +01:00