Files
baserow/web-frontend/modules/core/plugins/realtimeProtocol.js
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

32 lines
1022 B
JavaScript

// `replay_events` cursor sentinels. Must match the constants in
// backend/src/baserow/ws/realtime_events.py.
//
// FIRST_CONNECT_CURSOR: first connect of a session, ask for a baseline only.
// NO_REPLAY_AVAILABLE: reconnect with no usable high-water mark, force refresh.
export const FIRST_CONNECT_CURSOR = -1
export const NO_REPLAY_AVAILABLE = -2
export const REALTIME_RECOVERY_HEADER = 'X-Baserow-Realtime-Recovery'
export const getRealtimeRecoveryRequestConfig = () => ({
headers: { [REALTIME_RECOVERY_HEADER]: 'true' },
})
/**
* Runs a realtime marker recovery and retries it once after a short delay.
* Marker events contain no usable snapshot, so a transient request failure must not
* leave the client stale until the next provider mutation.
*/
export const retryRealtimeRecovery = async (callback) => {
try {
return await callback()
} catch {
await new Promise((resolve) => setTimeout(resolve, 1000))
try {
return await callback()
} catch {
return undefined
}
}
}