Files
Docwell/Database/pb_migrations/1764200000_ai_limits.js
T
tajniak81andClaude Opus 5.5 0ebf064173
CI / go (Server) (push) Failing after 25m5s
CI / go (Web-App) (push) Canceled after 0s
CI / frontend (push) Failing after 8m38s
CI / desktop (ubuntu-latest) (push) Successful in 1h41m20s
CI / mobile (push) Failing after 4m19s
CI / docker (push) Failing after 44m8s
Docs / build (push) Successful in 17m11s
Docs / deploy (push) Skipped
CI / desktop (macos-latest) (push) Canceled after 0s
CI / desktop (windows-latest) (push) Canceled after 0s
Add audio transcripts, monthly AI limits, PDF sources and AI chat on phones
Follow-ups to Phase E (ADR-15):

- Transcription (E2): OpenAI-compatible profiles can name a speech-to-text
  model; POST /files/{id}/transcribe turns an audio or video attachment
  (up to 25 MB) into text and a summary with key points and action items.
  The editor gets a Transcribe button on media files that inserts the
  summary and the transcript in a toggle.
- Monthly token limits: ai_usage counts requests and tokens per workspace
  and month. Workspace admins can cap their workspace; superadmins can cap
  what each workspace uses through the server's providers, after which
  the workspace's own providers keep working. The admin panel lists usage.
- PDF text for extra retrieval files (ledongthuc/pdf, pure Go).
- Phone app: an AI chat screen for the workspace or a page, with streamed
  answers and sources that open the cited block.
- OpenAPI, generated clients, migration, translations and docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 22:26:27 +01:00

47 lines
1.8 KiB
JavaScript

// SPDX-License-Identifier: AGPL-3.0-or-later
/// <reference path="../pb_data/types.d.ts" />
// AI follow-ups (ADR-15):
//
// - ai_usage: tokens a workspace used per calendar month (UTC), so workspace
// admins can cap their spending and superadmins can cap what each
// workspace spends through the server's providers (instance_tokens).
// The cap itself lives in workspaces.ai_settings and in the "ai" key of
// instance_settings.
// - ai_profiles.transcribe_model: the speech-to-text model of an
// OpenAI-compatible profile, for audio attachments (E2).
migrate(
(app) => {
const workspaces = app.findCollectionByNameOrId("workspaces");
app.save(
new Collection({
type: "base",
name: "ai_usage",
fields: [
{ name: "workspace", type: "relation", collectionId: workspaces.id, maxSelect: 1, required: true, cascadeDelete: true },
{ name: "month", type: "text", required: true, max: 7 },
{ name: "requests", type: "number" },
{ name: "input_tokens", type: "number" },
{ name: "output_tokens", type: "number" },
{ name: "instance_tokens", type: "number" },
{ name: "created", type: "autodate", onCreate: true, onUpdate: false },
{ name: "updated", type: "autodate", onCreate: true, onUpdate: true },
],
indexes: ["CREATE UNIQUE INDEX idx_ai_usage_month ON ai_usage (workspace, month)"],
}),
);
const profiles = app.findCollectionByNameOrId("ai_profiles");
profiles.fields.add(new TextField({ name: "transcribe_model", max: 200 }));
app.save(profiles);
},
(app) => {
app.delete(app.findCollectionByNameOrId("ai_usage"));
const profiles = app.findCollectionByNameOrId("ai_profiles");
profiles.fields.removeByName("transcribe_model");
app.save(profiles);
},
);