mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 08:18:42 +00:00
* feat(chat-runs): limit active runs per run type, per user or workspace Each run type now counts only its own runs. The per-user limit keeps its default of 2, and a run type can add a per-workspace limit. * feat(chat-runs): follow any run over one core streaming endpoint GET /api/chat-runs/<run_id>/stream/ relays the output of any run type behind its read check. Helm and the install guides route /api/chat-runs/ to the ASGI service; the guides also gain Kuma's /assistant/ route. * feat(chat-runs): read the core run stream by default in the frontend The base ChatRunType reads the core stream, applies the resume baseline and retries once after a token refresh. * refactor(chat-runs): expose the output fold for lost runs Run types rebuild a lost run's partial text from the buffered output with fold_output. * perf(chat-runs): send heartbeat records and skip repeated run reads While no output arrives, an open stream sends run.heartbeat as a JSON record, so a follower can tell a quiet stream from a stalled one. The stream view hands follow_run the run state it read for its permission check, finish_run returns the ended run instead of letting callers read it again, and a lease renewal takes one statement while the run goes on. The per-workspace limit hook receives the workspace, so a run type can set the limit per plan. * perf(chat-runs): follow runs from their open stream in the frontend The store reads a run's status only while it has no stream or the stream lost its output, and restarts a stream that stays silent for 15 seconds, also after the computer slept. Following a run opens its stream directly, and Stop doesn't read a run whose stream is open. Each run type keeps one chat subscription, released with unsubscribeFromChat; refreshChat runs only when a subscription is confirmed on a new websocket, and window focus or a regained network only re-attach followers. The developer guide documents the subscription and heartbeat contract. * perf(chat-runs): write a reply's first words at once - The journal writes output after a quiet moment at once and batches what follows, so the first words no longer wait for the 250 ms timer. - The stream adapter settles when aborted. Chrome can fire the last progress event after the request is done, where aborting fires no event. - A stream refused with 503 is retried with the next status check instead of spending every reconnect attempt at once. * refactor(chat-runs): register the stream route by URL name
34 lines
1.0 KiB
JavaScript
34 lines
1.0 KiB
JavaScript
import { createStreamAdapter } from '@baserow/modules/core/chatRuns/stream'
|
|
|
|
export default (client) => {
|
|
return {
|
|
async get(runId) {
|
|
const { data } = await client.get(`/chat-runs/${runId}/`)
|
|
return data
|
|
},
|
|
|
|
async cancel(runId) {
|
|
const { data } = await client.post(`/chat-runs/${runId}/cancel/`)
|
|
return data
|
|
},
|
|
|
|
/**
|
|
* Reads a run's records after a cursor as they arrive, until the run ends.
|
|
*
|
|
* @param {string} runId The id of the run.
|
|
* @param {string|null} cursor The cursor of the last record received, or
|
|
* null to read from the start.
|
|
* @param {Function} onRecord Called with each record, in order.
|
|
* @param {AbortSignal} [signal] Aborting closes the response; the run
|
|
* continues.
|
|
* @returns {Promise<object>} Resolves once every record has been handled.
|
|
*/
|
|
stream(runId, cursor, onRecord, signal) {
|
|
return client.get(`/chat-runs/${runId}/stream/`, {
|
|
params: { cursor },
|
|
adapter: createStreamAdapter(onRecord, signal),
|
|
})
|
|
},
|
|
}
|
|
}
|