Commit Graph
70 Commits
Author SHA1 Message Date
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
Bram Wiepjes b432334fa1 Changed repository URL to baserow/baserow [1/2] 2023-04-25 11:19:43 +00:00
Peter Evans 369759c386 Resolve "Rename group to workspace in the backend" 2023-03-14 14:43:35 +00:00
Nigel Gott 2bbb22be2f Resolve "Export useful opentelemetry metrics." 2023-03-03 16:58:45 +00:00
Petr Stribny fda53607c7 CI for e2e tests 2023-02-27 16:05:07 +00:00
Alexander Haller c67005434a Resolve "Automate changelog" 2023-02-10 10:25:49 +00:00
Petr Stribny 462848efbc Resolve "Add e2e tests" 2023-01-30 13:26:33 +00:00
Nigel Gott f81da4181e Add wildcard feature flag and change RBAC ones from nonspecific WIP to RBAC. 2022-12-19 10:40:49 +00:00
Nigel Gott ebd6e1390e Various doc and plugin fixes. 2022-10-03 08:01:50 +00:00
Jeremie Pardou-Piquemal 2f34b99fb9 Add enterprise plugin 2022-09-22 10:00:59 +02:00
Marc Seitz 8b2fb9185b fix: documentation for dev environment 2022-08-04 11:36:41 +01:00
Josh Soref 02ab31c8aa Spelling 2022-07-29 09:12:43 +00:00
Petr Stribny aeaa2a1ecd Remove references to other databases 2022-07-26 15:28:32 +02:00
Davide Silvestri eccd076ad9 Resolve "Share VSCode config for baserow" 2022-07-19 06:15:27 +00:00
Nigel Gott 68d30b690d Add docker upgrade docs 2022-05-10 15:44:28 +00:00
Nigel Gott 74666087e9 Resolve "Add basic feature flag support" 2022-04-15 14:12:11 +00:00
Davide Silvestri 070f6ed455 Resolve "Upgrade Node.js runtime" 2022-04-14 10:02:23 +00:00