Commit Graph
86 Commits
Author SHA1 Message Date
Davide Silvestri 0bb39e36c6 [1/4] feat: AI assistant eval platform on self-hosted Phoenix (#5958)
* feat: add Phoenix LLM tracing service to the dev stack (ai profile)

* chore(deps): add openinference pydantic-ai instrumentation (dev)

* feat: export assistant traces to Phoenix when BASEROW_ASSISTANT_PHOENIX_URL is set

* fix: harden Phoenix tracing setup after review

* feat: Phoenix postgres storage, ai-evals profile and auth support

* docs: ADR 007 and assistant tracing/evals guides

* feat: assistant eval platform core (types, registries, scenarios)

* feat: eval harness with shared assistant factory

* feat: phoenix dataset sync for assistant evals

* feat: assistant eval experiments via phoenix client + CLI

* feat: migrate core, database and docs evals to the platform

Ports the 42 kuma-core/kuma-database/kuma-docs pytest evals into
declarative EvalCase/EvalScenario registrations, plus structure-level
tests asserting dataset counts, ids, and scenario wiring.

* feat: migrate builder and automation evals to the platform

Ports the 12 builder + 2 proactive + 2 user-source cases into
evals/datasets/builder.py (kuma-builder, 16 cases) and the 7 automation
cases into evals/datasets/automation.py (kuma-automation), following the
Task 5 pattern established in core.py/database.py. Extends
eval_platform/test_datasets.py with counts, id lists, a mode-per-case
assertion, and pre_state snapshot checks for the two cases that need one.

* fix: link traces and final counts for single-case eval runs

* fix: root spans for single-case eval runs use the assistant tracer provider

* feat: assistant eval runner service with run page

Adds the assistant_eval_runner management command (migrate -> instrumentation
-> dataset sync -> single worker thread -> wsgiref server) and its
runner.py module: a stdlib WSGI app serving a plain server-rendered page
(GET /, POST /run, GET /healthz) backed by a bounded in-memory run history
and one background worker draining a queue.Queue via run.run_experiment_for.

Wires the assistant-eval-runner compose service (ai-evals profile, own
baserow_evals DB), renames phoenix-db-init to ai-evals-db-init and extends
it to also create baserow_evals, and adds BASEROW_EVAL_RUNNER_PORT to both
env example files and the dev docs.

* fix: eval runner integration fixes

assistant-eval-runner needs its own SECRET_KEY/DATABASE_*/REDIS_* env vars:
dev-overlay compose services don't inherit docker-compose.yml's
x-backend-variables anchor (that's file-scoped YAML), so the container was
starting without a Django SECRET_KEY and without a Redis password, crashing
on auth. Also links to finished experiments pointed at the container-internal
BASEROW_ASSISTANT_PHOENIX_URL (http://phoenix:6006), unreachable from the
developer's browser.

Adds BASEROW_ASSISTANT_PHOENIX_PUBLIC_URL (defaulting to
http://localhost:${BASEROW_PHOENIX_PORT:-6060}) and has runner.py build the
Phoenix link from it, deep-linking straight to the finished run's experiment
compare view when its dataset_id/experiment_id are known, falling back to
the datasets list otherwise.

* refactor: retire the pytest eval harness

All 65 eval cases now live in baserow_enterprise.assistant.evals.datasets;
delete the legacy pytest-based suite and its `eval` markers.

* docs: rewrite assistant evals guide for the Phoenix platform

* feat: docs judge, prompt sync, git stamping and UI-contributed eval examples

- answer_quality LLM-as-judge evaluator for kuma-docs (BASEROW_EVAL_JUDGE_MODEL)
- Kuma prompts versioned into Phoenix on sync; experiments stamped with
  prompt hashes, git branch/commit and judge model
- sync preserves UI-added dataset examples with prompt-match adoption;
  eval-export emits paste-ready docs.py snippets
- final-review fixes: skip-safe scoring, runner CSRF/bind hardening,
  doc corrections

* feat: eval runner UI round — tabs, fan-out, reference answers, 64-case docs dataset

- Runner page: dataset tabs with selection badges, per-dataset and global
  all/none, cross-dataset fan-out (one experiment per dataset), 5s
  auto-refresh of runs, persistent run history across restarts, per-dataset
  Phoenix links, in-page Help tab rendering the repo docs via /docs.json.
- Reference answers for kuma-docs: EvalCase.reference_answer, judge grades
  against it, sync preserves UI-curated ones, eval-export round-trips them.
- kuma-docs grown to 64 cases: reference answers for all, PostHog-mined
  frequent questions, and cannot-do guardrail cases.
- Gemini (google:gemini-3.6-flash) in the eval model list.

* feat: runnable UI examples, prompt overrides, eval baseline and results view

- UI-added Phoenix examples now execute: docs questions get the standard
  docs checks + judge; tool cases declare scenario/expected_tools/
  answer_contains in metadata (empty-workspace default scenario). They are
  tickable per dataset on the runner page and run in whole-dataset
  experiments too.
- Prompt overrides: run any experiment with a prompt's latest Phoenix
  version instead of the code constant (runner checkbox panel with soft
  per-tab ordering, or --override-prompt). Agent singletons keep their
  dynamic instructions; effective hashes + override list stamped on the
  experiment.
- Committed baseline snapshot (evals/baseline.json, 111 cases) with
  just b eval-baseline capture/import; the runner imports it on startup so
  every Phoenix instance gets a baseline experiment per dataset,
  idempotent by content hash and run count.
- Results tab: all datasets in one view for a named experiment, with
  baseline deltas and a case-weighted overall row, via Phoenix experiment
  annotation summaries.
- New evaluation guide (docs/testing/ai-assistant-eval-analysis.md) served
  in the Help tab; layout uses horizontal space better (single tab row,
  fluid case columns).

* feat: time and cost in eval results, frozen into the baseline snapshot

- Results tab gains time (sum of run latencies) and cost/token columns per
  dataset and summed overall, with lower-is-better baseline deltas.
- eval-baseline capture freezes each dataset's time/cost/token totals into
  baseline.json; import stamps them as metadata so imported baselines
  (which carry no traces to price) still show time and cost.
- Importing a new baseline supersedes the previously imported one instead
  of accumulating duplicates.
- Changelog entry for the eval platform.

* fix: OpenInference attributes on subset-run task root spans

Bare wrapper spans rendered as kind 'unknown' with Unset status and empty
input/output in Phoenix. The Task root span now carries the CHAIN kind, the
case prompt as input, the run result as JSON output, and an explicit OK
status.

* polish; minor fixes

* fix: address eval platform review feedback

Apply production model settings and retries, isolate automation checks, and fix runner configuration, links, and result status.

Defer GPT-5.6 compatibility and baseline comparisons to #6034.

* fix: preserve model profiles in rebased eval harness

Use an explicit model profile for evals and share concrete models with tools. Manage model clients through the existing lifecycle helper and preserve regression coverage from the retired harness.

* fix: harden eval persistence and Phoenix access
2026-09-09 17:06:07 +02:00
Jérémie PardouandTsering Paljor 40c18a3c9f feat: add separate domain for preview (#5682)
Co-authored-by: Tsering Paljor <tsering@baserow.io>
2026-09-09 08:53:47 +02:00
Davide Silvestri ab45c2346a feat [4/8]: per-feature AI model settings (#5796)
* feat: per-feature and workspace-level AI model settings

Baserow could only point every AI feature at one instance-wide model. An
administrator can now register provider models, declare which AI features each
model may serve, and pick the default model per feature; a workspace admin can
inherit that choice, override it, or disable the feature locally.

The assistant resolves its model once per logical request and threads that
snapshot through its nested agents and tools, so a single run can no longer
re-read settings repeatedly or pick a model other than the one it validated.
The scoped provider state is memoized for the duration of a request, keeping
workspace serialization from loading it once per workspace.

Also:
- add Google and Groq provider types, and keep these database-only providers
  out of the legacy workspace settings they cannot round-trip through;
- prune orphaned feature selections so an unloaded feature type's RESTRICT FK
  no longer blocks provider and model deletion;
- record whether a configured model answers text and tool-calling probes, and
  invalidate that result when its credentials or identifier change;
- broadcast provider and availability changes over the existing realtime
  channel so open clients update without reloading;
- read the assistant model from the shared configmap, so frontend pods no
  longer miss it on Helm installs.

Manual test instructions live in docs/testing/kuma-model-settings-test-plan.md.

* fix: address AI provider settings review feedback
2026-09-04 10:53:53 +02:00
Davide Silvestri f27bb387fe feat [3/8]: add workspace AI provider management and complete AI Field resolution (#5785)
* feat: add workspace AI providers for AI fields

* fix: address workspace AI provider review feedback

* fix: address remaining AI provider review feedback

* fix: resolve core migration conflict

* fix: stabilize premium AI provider tests

* address feedback for local imports
2026-08-20 10:49:57 +02:00
alamin-br 3b2ab433bf feat[1/6]: Add button field type with URL button behind feature flag (#1722) (#5767)
* refactor: move formula field-reference visitors from premium to core

* feat: add ButtonField model and fixture (#1722)

* feat: add read-only button field type backend (#1722)

* feat: resolve database formulas client-side for the button field (#1722)

* feat: add button field type frontend (#1722)

* chore: add changelog entry for button field (#1722)

* fix: disable button field cells when the url formula is broken (#1722)

* fix: encode whitespace in resolved button field urls (#1722)

* fix: rename button field visitor tests to avoid pytest module collision

* test: add button field to expected premium export outputs

* test: add button field to remaining interesting-table test expectations

Registering the button field in construct_all_possible_field_kwargs
changed the interesting test table used by several golden-output
tests. Update the affected expectations (serialized row value, CSV
export column, and generated schema entry) to match actual behavior.

* feat: put the button field behind the button-field feature flag

* fix: address button field review nits

* fix: renumber button field migration after develop merge

* docs: describe the button field as an action field in API docs

* fix: handle raw formulas and missing field references in button fields

* fix(review): remap binary-op field refs, cache parse trees, extend button field tests

- visit both operands in BaserowFormulaReplaceFieldReferences.visitBinaryOp so
  get() references inside binary expressions are remapped on import/duplication
- cache client-side formula parse trees so large grids do not re-parse the same
  button formula for every row
- add tests for the urlInvalid submission block, the field-store fallback in
  functional grid cells, and duplication with broken field references

* fix: keep button field type registered when the feature flag is off

Gating registration behind the flag meant that disabling it after button
fields existed made every registry lookup for those fields raise, breaking
all row, field and export endpoints for the affected tables.

The type is now always registered on both backend and frontend, matching
how other gated field types work. Creating a button field (or converting
a field to one) is rejected with ERROR_FEATURE_DISABLED while the flag is
off, and the field type dropdown hides the type entirely via the new
isVisibleInDropdown hook. Existing button fields keep rendering and their
tables keep working.

* fix: keep brackets when remapping field references in formulas

* fix: keep the button url formula mode when remapping field references

Assigning the remapped formula string to `url_formula` made the patched
`save()` re-wrap it through `to_python` as `simple` mode, undoing the
raw-mode guard in `replace_field_id_references`. A raw literal URL then
became an unparseable formula, so duplicating a table left the button
broken. Assign the whole formula object so mode and version survive.

* fix(review): share the formula field id cache and cover the flag-off cases

Move `get_table_field_ids` and its `table_schema_changed` invalidation into
core next to the visitors, so validating a button field's url formula no
longer costs a query per field on every field response. The AI prompt
validation now reads the same cache instead of its own copy.

Also list the edited field's own type in the field form dropdown even when
hidden, otherwise an existing button field renders with a blank type once
the feature flag is turned back off, and drop the always-null cell backup
on type conversion.

* chore(review): tidy the button field export branch and flag docs spacing

* test: cover the formula parse tree cache

The cache is shared by every resolveFormula caller, including the builder,
so record what it guarantees: one parse per distinct formula, raw formulas
never parsed, failures not cached, and oldest-first eviction at the cap.
Also state the read-only invariant the reuse depends on.

* fix: guard and cache the formula field reference helpers (#1722)

`get()` and `get('fields')` both parse and both pass the create API, so
remapping them raised an uncaught IndexError that aborted the whole
duplication or import job. Guard every index instead.

`extract_field_id_dependencies` also parsed raw formulas, unlike its two
sibling helpers, and re-parsed on every call. It now short-circuits raw
mode and caches the extracted ids per formula string.

* fix: keep the AI prompt's mode when remapping field references (#1722)

Moving the reference visitors to core added a raw short-circuit that
returns a bare string. `AIFieldType.after_import_serialized` re-saved
that string, so `to_python` re-wrapped a raw natural language prompt as
`simple` mode and every row's generation then failed on parsing the
prose.

Assign the whole formula object instead, the same way the button field
already does, and cover a raw prompt surviving an export/import.

* feat: add the encode_uri and encode_uri_component formula functions (#1722)

A button field's URL is built by concatenating row values, so a value
holding a reserved character corrupts it: `shoes#7` truncates to a
fragment and `a&b=1` injects a parameter. Encoding every value
automatically is not an option, because a value can legitimately be the
whole URL.

These mirror the two functions that already exist in the database
formula language and let a formula escape the parts that need it. The
backend and the browser encode identically, since button URLs resolve
client-side and everything else resolves on the server.

* fix: address review on the button field backend (#1722)

The field no longer creates a database column. It held nothing but an
always-null boolean, and that boolean leaked into the API docs and the
Local Baserow schema. `get_model_field` returns None and a
`NoDatabaseColumnField` is contributed to the generated model instead,
which Django treats as non concrete. A `ButtonFieldConverter` handles
conversion in both directions, since the lenient schema editor cannot
alter into or out of a column-less field, and the serializer is now
always-null while staying writable so the read-only validator still
rejects a write.

Also from review: only creation is gated by the feature flag, so an
existing button field stays editable with the flag off; dependencies are
read off the cached table model rather than two queries per field; and
the client is only told to re-fetch when a referenced field appears or
disappears, not when one is renamed or retyped.

* fix: address review on the button field frontend (#1722)

Without a label the button showed the percent-encoded URL. The URL is
now resolved once as the user built it and only the href is encoded, so
the label reads `https://example.com/Red Button` while the link points
at `Red%20Button`. With no label and no URL it reads "Click me".

Also from review: a read-only field the search cannot match no longer
disables optimistic row updates for every edit in a searched view, which
a valueless field like this one did; the parse tree cache evicts the
least recently used entry rather than the oldest inserted one; and the
field type reports its icon class statically and no longer claims its
cells are booleans in the API docs.

* fix: hide button fields from public views and require a label (#1722)

Button fields are no longer handed to visitors of a publicly shared view.
A new `FieldType.can_be_in_public_view` flag drives the exclusion, applied
to the public view info endpoint, the public rows queryset and the two
public websocket signal paths, so a visible field option isn't enough to
expose the label and the URL formula.

The label is now mandatory. It's the only text a button shows, so it must
be set when the field is created or converted into a button, and it can't
be emptied afterwards. The client-side fallbacks to the resolved URL and
to a default label are gone with it.
2026-07-29 14:53:38 +02:00
Davide Silvestri c3706658a2 feat [1/8]: add instance AI provider management behind a feature flag (#5740)
* feat: add instance AI provider management

* fix: simplify AI provider testing

* fix: remove extra model list spacing

* fix: show AI provider form errors inline

* fix: use icons for AI provider row actions

* fix: place model errors before help text

* chore: polish code

* fix: address feedback

* fix: address remaining frontend CI failures
2026-07-27 14:12:37 +00:00
Davide Silvestri e6f2a44e85 chore: scale OpenTelemetry sampling and preserve traffic metrics (#5726)
* feat: scale OpenTelemetry sampling and metrics

* feat: add per-user invitation metric

* fix: monitor every queue in OpenTelemetry

* docs: explain retaining every eligible trace

* feat: retain all eligible traces with -1

* fix: address feedback; trace ActionType.do and several important handlers methods
2026-07-22 11:57:11 +02:00
dimmur-brw 8eeb53e4fc feat: User presence (part 2) - user presence on grid (#5570) 2026-07-06 08:04:35 +02:00
Davide Silvestri 0aa7147db3 Collapsible group-by grid view (#5470)
* feat: add collapsible group-by grid view

* fix: address copilot feedback, plus some other cleanup/fixes

* fix: harden grid e2e navigation

* Add e2e tests; improve performance; clean up code

* feat: show resolved values for reference fields in group-by headers

- Resolve collaborator, link-row and select group values to renderable display
  objects in the group-by data API, batched once per field per page (O(1) lookups,
  no per-group queries).
- Order many-to-many groups identically to the rows via correlated-subquery
  ordering, since the relation column is shadowed by the aggregated array
  annotation in group-by queries.
- Render the display values as chips in the group-by banner via dedicated
  multiple-select / multiple-collaborators components; shrink the collaborator
  badge, reduce the field-name size and keep the label on one line.

* fix: group many-to-many fields by their set of values

Grouping a grid by a collaborator, multiple-select or link-row field
produced empty groups with orphaned rows and duplicate headers for the
same set of values. The group key (an id array) was order-sensitive: the
backend's aggregated array order was unstable row-to-row and the cell
appends new values, so an optimistically-created group's key diverged
from the server's and rows were rejected by rowBelongsToGroupBySection.

- pathKey and the group-row Vue keys now sort m2m id arrays numerically,
  so a group is identified by its set of ids, not their order.
- The backend aggregates the group value ordered by related id and sorts
  the group's unique value, making grouping deterministic and set-based.
- Optimistically-emptied groups (row_count 0) are no longer rendered (the
  node is kept for reconciliation), and the leading group gap is fixed so
  the first visible group has no spurious gap.
- A newly created collaborator group resolves its badge name from the
  workspace store instead of requiring the name on the value.

* fix: keep cell multi-select when dragging in a group-by view

A multi-select drag ends with a click whose target is the rows
container (the common ancestor of the dragged cells). cancelMultiSelect-
IfActive cancels the selection unless that container is recognised as
part of the rows area, but its whitelist only knew the flat-grid classes
(grid-view__rows / grid-view__row). The collapsible group-by feature
renders rows in grid-view__group-by-rows containers, so the post-drag
click was treated as "outside the rows" and the selection was cleared on
mouseup. Add the group-by row containers to the whitelist.

* test: expect emptied group-by banners to disappear

The optimistic empty-group hiding (a group disappears once its last row
moves out) made the e2e contract that kept the emptied source group
visible at row_count 0 obsolete. Update the 2.2.7/2.4.4 assertions to
expect the emptied group's banner to be gone (new expectNoGroupByBanner
helper), and correct the tree-maintenance comments: the node is still
kept for reconciliation, but the layout no longer renders its banner.

* perf: load the collapsible group-by grid in one bounded request

Grouping a wide table by many fields took several seconds and a request
waterfall to render the first screen. The group tree was fetched one HTTP
request per depth, a budget that ran out before reaching any leaf forced
a per-parent fallback, and the rows endpoint resolved group-by metadata
unconditionally.

Backend
- Walk the descendant tree with one batched windowed query per group-by
  level (get_group_by_data_for_parents) instead of one query per parent,
  so a single include_descendants request returns the whole visible
  subtree in O(depth) queries.
- Scale the descent window to the viewport: row_budget = ceil(limit /
  depth). A deep group-by stacks each leaf row under its ancestor
  banners, so far fewer leaf rows fill the first screen; the window now
  returns a viewport-sized slice (~264 -> ~68 groups on a 12-level grid)
  and the rest lazy-loads on scroll.
- Gate the rows endpoint's group-by metadata behind
  include=group_by_metadata so it is not computed when unused.
- Resolve reference/link-row display values in one id__in query per field
  across all pages instead of once per page.

Frontend
- Initial load issues one group-by-data prefetch and one viewport rows
  request; expand mode no longer takes the per-depth path.
- Cap the banner indent (<=50px) and shrink the per-level arrow spacing
  as the group-by count grows, keeping the count aligned and the field
  name ellipsised; render multi-level loading skeletons for the
  not-yet-loaded levels.
- Guard walkPage against a cyclic page-resolution stack overflow and keep
  activeGroupBys filtered to fields that still exist.

Plus e2e env isolation (configurable ports, cookie prefix) and docs.

* fix: address review feedback

Addresses the review comments on the collapsible group-by grid PR.

- Gate the group-by add-row "+" on the same condition as the flat grid
  (not read-only, not a one-way data sync, has create-row permission), so
  it no longer renders buttons that error on click for data-sync tables.
- Show the "(Empty)" label for empty array-valued groups (multiple select,
  link row, collaborators), matching the text-field behaviour.
- Stop the flat-grid row placeholder from rendering in group-by mode
  (v-else-if instead of v-else).
- Render formula group-by headers via the result field type's group-by
  component instead of RowCardFieldFormula, removing the dev-only
  "Missing required prop: row" Vue warning.
- Keep the cell selected at the first/last field for both Tab and arrow
  keys (restore the pre-refactor behaviour); navigating past the edge no
  longer drops the selection in either flat or group-by mode.
- Re-enable and de-flake the "sorted add outside buffer" e2e test: assert
  on the re-resolved last row instead of a snapshotted renderedRowCount()
  index, which raced with the create-confirmation re-render in CI.

* fix: keep rows inserted below in a grouped grid view in their group

Insert-below and add-row in a grouped view now derive the new row's group
path from the neighbouring row, so it inherits all writable group-by values
and lands in the same group; `before` is set only when the next row shares
that group.

* feat: soft-cap adding group-bys at 5 in the view UI

Once a view reaches 5 group-bys the add button is disabled with a tooltip;
views that already have more keep working and only offer to remove them.

* limit group-bys; fix css

* refactor: polish code and comments

* fix: address Bram's feedback

* feat: add vertical gap between sibling sub-groups and indent banner labels with their chevron

* fix: address remaining feedback

* fix: row-coloring and fixed-height for add-row

* fix: address Bram's feedback v2

* fix regression in last commit

* fix: address grid group review comments
2026-07-03 09:09:52 +02:00
dimmur-brw 0b0562ec93 feat: User presence (part 1) - infrastructure and grid avatars (#5399) 2026-07-01 07:10:01 +00:00
Davide Silvestri 53cde32108 docs: align contribution guidelines with new external PR policy (#5600)
Stop accepting unsolicited external pull requests and remove the internal
external-contributions triage doc, per the decision announced in #5598.
Update the task issue template and README pointer accordingly.
2026-06-29 08:54:14 +02:00
Jérémie Pardou b3aa83514b feat: add code service (#5425) 2026-06-09 15:41:31 +00:00
alamin-br 3fd9fdc09e chore: add zed config for debugging (#5441) 2026-06-02 09:05:27 +02:00
alamin-br 40b8371c68 chore: improve pre commit performance (#5406)
* chore: improve pre-commit hook trigger and make sure only applies to
staged/unstaged changes.

* docs: update code-quality doc

* docs: improve doc
2026-05-21 15:05:32 +00:00
alamin-br 4373a68e35 chore: integrate pre-commit hooks (#5392)
* chore: integrate pre-commit hooks for backend and frontend code quality enforcement

* fix: uv.lock

* refactor: consolidate pre-commit hooks to use just recipes and add a pre-commit-uninstall command

* docs: document pre-commit branch linting and update pre-commit configuration to increase file size limits and remove serial execution requirements.
2026-05-21 14:16:38 +02:00
Davide SilvestriandJérémie Pardou 400fa482f7 chore: update contributing guidelines and issue templates (#5096)
* chore: update contributing guidelines and issue templates

* address copilot feedback

* Update docs/development/external-contributions.md

Co-authored-by: Jérémie Pardou <571533+jrmi@users.noreply.github.com>

* address feedback

* address Jeremie's feedback v2

---------

Co-authored-by: Jérémie Pardou <571533+jrmi@users.noreply.github.com>
2026-05-21 09:24:45 +02:00
Davide Silvestri cf15a4a02f refactor (MCP): refactor MCP tools; share AI Assistant capabilities (#4980)
* feat(mcp): refactor tools to service layer and add database/table/field CRUD

Replace internal API request pattern with a dedicated service module for
MCP operations. Simplify tool architecture from dynamic per-table tools
to static tools with explicit table_id parameters. Add new tools for
managing databases, tables, fields, and batch row operations.

* fix(mcp): address Copilot review feedback

- Let exceptions propagate from MCPTool.call() so call_tool() logs them
- Fix N+1 queries in get_table_schema using enhance_field_queryset hook
- Fetch fields for all tables in a single specific_iterator pass
- Clamp list_rows pagination to safe bounds (ROW_PAGE_SIZE_LIMIT)
- Fix update_fields docstring to reflect type-change support
- Fix module path in utils.py comment
- Update "Adding a new tool" docs to match current MCPTool pattern

* fix: comment risky tools; waiting for a proper permission check

* feat(mcp): add enabled flag to MCPTool and disable risky tools

Add `enabled` attribute to MCPTool base class so tools can be registered
but hidden from MCP clients. Disable database/table/field CRUD tools
until users can control tool availability through the UI.

Also add docs/testing/mcp-test-plan.md with manual testing instructions.

* fix(mcp): replace list[dict] with typed Pydantic models for field/row specs

Validate required keys (name+type for field create, id for field update,
id for row update) at the schema level instead of relying on KeyError
from dict.pop() in the service layer.

Uses extra="allow" so type-specific options and field values pass through.

* fix: wrap update_rows in a transaction

* address feedback
2026-04-01 08:52:59 +00:00
Davide Silvestri 40c9f48081 feat (assistant) 3/3: add themes to templates and a set_theme tool (#4970)
* feat(assistant): add theme catalog, apply_theme, and theme templates

Add 20 new theme templates and theme infrastructure:
- THEME_CATALOG with 22 themes, ThemeName type, _load_theme_data(), apply_theme()
- BuilderItemCreate.theme field with auto-apply on creation
- set_theme() tool for changing themes on existing applications
- Unit tests and eval tests for theme functionality

* refactor(assistant): migrate theme evals to EvalChecklist pattern

Replace removed assert_no_tool_errors with EvalChecklist + count_tool_errors
in test_agent_creates_app_with_theme and test_agent_changes_theme. Remove
stale test_navigate_to_workspace test.

* refactor(assistant): move theme code from core/types to builder/themes

Theme catalog, apply_theme, and related helpers are a builder concern,
not core. Move them to tools/builder/themes.py so core never imports
from builder. Also make apply_theme return bool so set_theme can report
errors instead of silently claiming success, and fix "Thank youb" typo
across all 23 theme templates.

* refactor (AI field): remove langchain and use pydantic-ai (#5017)

* refactor(ai): replace langchain with pydantic-ai for LLM calls and structured output

Replace langchain dependency with pydantic-ai as the LLM abstraction
layer. Each GenerativeAIModelType now implements get_ai_model() returning
a pydantic-ai Model instance, and the base class provides prompt() and
prompt_structured() using Agent.run_sync().

- Remove langchain, langchain-openai, and direct openai/anthropic/mistralai
  deps (pydantic-ai-slim extras install them)
- Add prompt_structured() with PromptedOutput for Pydantic model output
  (e.g. BaserowFormulaModel)
- Add output_choices parameter to prompt() for constrained choice selection
  with fuzzy matching, compatible with all models including those without
  tool support
- Remove custom output_parsers.py (StrictEnumOutputParser, JsonOutputParser
  replacements)
- Update AI field job flow to use prompt(output_choices=...) for choice
  output and prompt_with_files fallback for file-based prompts

* refactor(ai): replace deprecated Assistants API with pydantic-ai multi-modal content

Replace OpenAI's deprecated Assistants API (file_search, threads, polling)
with pydantic-ai's native BinaryContent support. Files are now read from
storage and passed directly in the prompt as multi-modal content — no
upload/delete lifecycle needed.

- Add content parameter to prompt() for multi-modal file attachments
- Remove GenerativeAIWithFilesModelType abstract class and its upload/
  delete/prompt_with_files methods
- Remove get_client() from BaseOpenAIGenerativeAIModelType (no longer
  needed without file operations)
- Replace AIFileManager.upload_files_from_file_field() with
  get_file_contents() returning BinaryContent objects
- Simplify job_types.py: file+choice paths merge into single prompt()
  call with content and output_choices parameters
- Remove format_prompt/parse_output hooks (no longer needed)
- Remove FileId type alias and AIFileError exception
- Works with any provider that supports documents (OpenAI, Anthropic,
  Mistral, Google) instead of only OpenAI

* refactor(ai): unify prompt API into single method with output_type parameter

Merge prompt_structured() into prompt() via the output_type parameter:
- None (default): plain text response
- list[str]: choice selection with fuzzy matching
- Pydantic BaseModel/TypedDict: structured output via PromptedOutput

Remove prompt_structured(), output_choices parameter, and dead code
(format_prompt, parse_output hooks, AIFileError, FileId type).

* refactor(ai): clean file handling API with model type owning processing logic

Redesign file handling so the model type owns all file processing decisions
(embed vs upload, size limits, count limits) while the manager only reads
metadata from storage and provides a lazy reader callback.

- Add supports_files flag and prepare_files() to GenerativeAIModelType base
- OpenAI implementation: embeds images inline (BinaryContent, 50MB/500 limit),
  uploads documents (UploadedFile via Responses API)
- Use OpenAIResponsesModel instead of OpenAIChatModel for OpenAI provider
  (supports all file types via input_file/input_image)
- AIFileManager.prepare_file_content() collects metadata, passes lazy
  read_file callback — no data read until model type requests it
- Remove is_file_compatible/get_max_file_size from public API (moved into
  prepare_files)
- Add type hints throughout

* fix(assistant): fix generate_formula tests and grid view row_height

- Add output_type param to TestGenerativeAIModelTypePromptError.prompt()
- Return BaserowFormulaModel in test mocks instead of raw JSON string
- Use correct ORM field name row_height_size in grid view from_django_orm

* docs: add AI field test plan

* refactor(ai): improve docstrings, fix prompt signature and empty prompt handling

* refactor(ai): merge ERROR_OUTPUT_PARSER into ERROR_GENERATIVE_AI_PROMPT

The distinction between output parsing errors and prompt errors didn't
provide actionable info to the user. Both now surface as a single
ERROR_GENERATIVE_AI_PROMPT error code.

* refactor(ai): move value generation into AIFieldHandler with AIFile abstraction

Introduce AIFile dataclass that wraps serialized UserFile dicts with
lazy read_content(). Move the core generation logic from
AIValueGenerator._generate_value_for into AIFieldHandler.generate_value_with_ai
so the handler owns the full flow: prompt resolution, file preparation,
AI call, file cleanup, and choice resolution.

- prepare_files() now takes list[AIFile] and returns only processed files
- cleanup_files() mirrors prepare_files() for provider file cleanup
- delete_file() takes AIFile instead of raw file_id string
- AIFieldEmptyPromptError raised when prompt resolves to empty
- Delete AIFileManager (absorbed into handler + model type)

* docs: add AI field architecture overview

* fix(ai): handle missing files and partial upload cleanup in prepare_files

- OpenAI prepare_files() now catches per-file errors (missing files,
  upload failures) and skips them instead of failing the whole generation
- Handler cleanup uses ai_files instead of prepared so files uploaded
  before a mid-prepare failure are still cleaned up

* fix(ai): normalize LLM responses before choice matching

Strip quotes, markdown bold, backticks, and trailing punctuation from
model responses before fuzzy matching. Use case-insensitive comparison
so responses like "POSITIVE" correctly match "Positive".

* address feedback

* Address feedback
2026-04-01 10:41:10 +02:00
Bram 032e4d50ca Remove plugin boilerplate (#4875) 2026-02-26 20:38:50 +01:00
Davide SilvestriandCopilot d89f474df5 chore (deps): upgrade base image to trixie and python 3.14 (#4718)
* trixie and python 3.13

* Fix backend tests

* Fix various references to previous python 3.11

* Upgrade to python 3.14

* Use official version of caddy

* Update backend/Dockerfile

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fix dev build

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-11 15:15:24 +01: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
Petr Stříbný 3f95309b30 Upgrade to Postgres 14 and Django 5.2.X (#4584) 2026-01-23 13:17:23 +01:00
Davide Silvestri 8e05debbfb fix (CI): add missing docs folder to docker images (#4559) 2026-01-20 09:03:13 +01:00
Davide Silvestri 80502fee12 chore (CI): fix all-in-one image build (#4552)
* Fix versions in dockerfiles; remove all-in-one-dev

* Add manual trigger to build all-in-one image

* add build_args for all-in-one images
2026-01-19 14:15:54 +01:00
Davide Silvestri e25988ea0d chore: switch to uv and justfile (#4369)
* create backend justfile; switch to uv

* Add deploy and dc-deploy recipes to build images

* Add uv.lock for reproducible builds

* CI fixes + improvements

* Reduce build time

* improve CI caching

* Improve exit early conditions

* Set requires_python==3.11.*; add backend/media to gitignore

* Fix all-in-one Dockerfiles and some other fixes

* Introduce frontend justfile + some other useful recipes

* Fix permissions issue with dev containers

* Improve dockerfiles and docs on how to use the dev env

* Fix mjml-email-compiler service

* Update docs + address feedback

* Fix containers healthchecks

* Fix yarn test in dev container

* Minor fixes to docs and justfile attach command

* Address Petr's feedback

* Address additional feedback

* Add changelog entry

* Address feedback: Petr and Przemek

* address feedback + prepare for saas PR

* minor fixes

* Address Bram's feedback 2
2026-01-15 11:22:22 +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
Peter Evans fffdb8d2da Preparing for WA beta. (#4189)
* Preparing for WA beta.

* Reintroducing Instance.compat_type to ensure that we still support our old node types for compat reasons.

* Revert the periodic type name.

* Post rebase linting

* Show the automation settings modal, but only show the General sidepanel in development.

* Fix e2e test
2025-11-11 16:01:34 +00:00
Bram 8682b8661c Switch GitHub actions to PGVector (#4094) 2025-10-19 23:49:02 +02:00
Bram d311aec1bd Update README and replace GitLab with GitHub (#4091) 2025-10-19 22:45:31 +02:00
Davide Silvestri f125a53de3 Add debug logs to SAML and Oauth 2025-10-08 09:13:38 +02:00
Bram Wiepjes bc94ce5d1c Upgrade without Django 5.1 2025-09-29 19:12:14 +00:00
Bram Wiepjes d407b52e16 Fix broken links and titles in docs 2025-08-12 20:23:49 +00:00
Davide Silvestri bb248241dd Remove obsolete compose version 2025-07-16 16:00:27 +02:00
Bram Wiepjes 61ae8986bb Allow configuring read only PostgreSQL replicas 2025-06-16 13:18:17 +00:00
Davide Silvestri 903763fba1 Speed up database setup in tests 2025-03-05 15:49:53 +01:00
Davide Silvestri 64e403302c Custom .env for tests 2025-01-15 12:40:01 +00:00
Tsering Paljor cdfdf3c73b Add lost context back into vscode-setup.md 2024-12-24 09:11:37 +04:00
Tsering Paljor a7cf0a248c Update e2e-testing.md with Node.js version info 2024-12-23 13:41:28 +00:00
Jérémie Pardou 63117027a6 Add builder first e2e tests 2024-11-14 12:30:42 +00:00
Przemyslaw Kukulski e84fbb0525 Enchance feature flags in backend 2024-09-23 10:00:36 +00:00
Davide Silvestri b560d819ef Fix broken links in our website docs 2024-09-12 10:34:45 +00:00
Bram Wiepjes e77535c172 Added force full trace docs 2024-09-02 20:00:22 +02:00
Bram Wiepjes e63565b9f5 Introduce Celery Flower 2024-06-25 11:35:04 +00:00
Davide Silvestri 9b68bd6c00 Add translations target to the backend Makefile 2024-01-22 11:19:19 +00:00
Petr Stribny bcd6e461bc Improve dev.sh docs 2024-01-11 20:01:07 +08:00
Afonso Silva 9b05298563 Update IntelliJ setup instruction docs 2023-11-22 09:43:29 +00:00
Nigel Gott 6d77cbb9d6 Add/enhance/consididate docs 2023-10-10 09:54:53 +00:00
Jonathan Adeline 4321aaea9a Replace icons 2023-09-28 13:39:41 +00:00
Nigel Gott 65961f9d69 Resolve "Investigate and fix OTEL metrics being sent too frequently" 2023-05-23 09:40:12 +00:00
Nigel Gott a8d93a3c6d Deprecate old full health check endpoint, add new admin only health check and page with email tester. 2023-05-15 11:24:15 +00:00