Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(topics): save Topics setup with automatic processing off and turn it on separately (#18682)

Lysander Kiesel5a92762c326a
diff --git a/packages/shared/AGENTS.md b/packages/shared/AGENTS.md
index f749432c0e..4ea945c841 100644
--- a/packages/shared/AGENTS.md
+++ b/packages/shared/AGENTS.md
@@ -100,12 +100,16 @@
worker model calls own tracing allowlisting, organization consent, usage,
cost and vector validation.
- `model-config.ts`: per-project `topic_configs` (three connection +
- model slots and the automatic-processing switch). Saving tests every slot
- with a real call; Anthropic works for summaries and clustering but fails the
- embedding test. The embedding model and dimensions are locked once embeddings
- exist. `setup.ts` tests the models, then commits the single Topics rule,
- models, and per-project trace idle time together. Refresh the Redis readiness
- setting only after that transaction commits.
+ model slots and the automatic-processing state). Saving keeps the stored
+ state and pause (a first save starts off) and tests every slot with a real
+ call while processing is on, otherwise only the changed slots; Anthropic
+ works for summaries and clustering but fails the embedding test. The
+ embedding model and dimensions are locked once embeddings exist. `setup.ts`
+ tests the models, then commits the single Topics rule, models, and
+ per-project trace idle time together. Refresh the Redis readiness setting
+ only after that transaction commits. `setTopicsAutomaticProcessing` is the
+ only path that turns processing on (after testing all stored models when it
+ was off or paused), clears a pause, or changes the rule's sampling rate.
- `processing-gate.ts`: `isTopicsProcessingActive`, the ingestion gate for
trace batching (allowlisted, enabled with all three models, and an active
rule with an unblocked facet), cached in Redis both ways. Any write to a
diff --git a/packages/shared/src/server/topics/model-config.test.ts b/packages/shared/src/server/topics/model-config.test.ts
index 28edc0a24f..eb1317550d 100644
--- a/packages/shared/src/server/topics/model-config.test.ts
+++ b/packages/shared/src/server/topics/model-config.test.ts
@@ -44,7 +44,6 @@ const settings = {
embedding: slot("openai", "text-embedding-3-small"),
embeddingDimensions: 1024 as const,
clustering: slot("openai", "gpt-5.6-terra"),
- enabled: true,
};
const saveTopicsModelSettings = async (
@@ -82,20 +81,45 @@ describe("prepareTopicsModelSettings", () => {
expect(mocks.upsert).toHaveBeenCalledOnce();
});
- it("saves a partial setup but enables Topics only with all three models", async () => {
+ it("saves a partial setup only while automatic processing is off", async () => {
await saveTopicsModelSettings("project", {
...settings,
clustering: null,
- enabled: false,
});
expect(mocks.upsert).toHaveBeenCalledOnce();
+ expect(mocks.upsert.mock.calls[0][0].create).not.toHaveProperty("enabled");
+
+ mocks.current.mockResolvedValue({ enabled: true });
await expect(
saveTopicsModelSettings("project", { ...settings, clustering: null }),
- ).rejects.toThrow("before turning Topics on");
+ ).rejects.toThrow("while automatic processing is on");
expect(mocks.upsert).toHaveBeenCalledOnce();
});
- it("tests every configured slot and names the ones that fail", async () => {
+ it("skips the test calls for unchanged models while automatic processing is on", async () => {
+ mocks.current.mockResolvedValue({
+ enabled: true,
+ summaryLlmApiKeyId: "openai",
+ summaryModel: "gpt-6-luna",
+ embeddingLlmApiKeyId: "openai",
+ embeddingModel: "text-embedding-3-small",
+ embeddingDimensions: 1024,
+ clusteringLlmApiKeyId: "openai",
+ clusteringModel: "gpt-5.6-terra",
+ });
+ await saveTopicsModelSettings("project", {
+ ...settings,
+ clustering: slot("openai", "gpt-6.1-sol"),
+ });
+ expect(mocks.testCall).toHaveBeenCalledOnce();
+ expect(mocks.testCall).toHaveBeenCalledWith(
+ expect.objectContaining({ model: "gpt-6.1-sol" }),
+ );
+ expect(mocks.embed).not.toHaveBeenCalled();
+ });
+
+ it("tests every changed slot and names the ones that fail", async () => {
+ mocks.current.mockResolvedValue({ enabled: true });
mocks.testCall.mockImplementation(async ({ model }) => {
if (model === "gpt-5.6-terra")
throw new Error("Model not found (HTTP 404)");
diff --git a/packages/shared/src/server/topics/model-config.ts b/packages/shared/src/server/topics/model-config.ts
index 4313fada82..31db238b0e 100644
--- a/packages/shared/src/server/topics/model-config.ts
+++ b/packages/shared/src/server/topics/model-config.ts
@@ -145,9 +145,9 @@ export async function pauseTopicsModels(
}
/**
- * Pauses Topics in every config that uses a connection about to be deleted.
- * Callers that pass a transaction call `invalidateTopicsProcessingActive`
- * after it commits.
+ * Pauses Topics in every running config that uses a connection about to be
+ * deleted. Callers that pass a transaction call
+ * `invalidateTopicsProcessingActive` after it commits.
*/
export async function pauseTopicsModelsUsingConnection(
params: { projectId: string; llmApiKeyId: string; provider: string },
@@ -157,6 +157,7 @@ export async function pauseTopicsModelsUsingConnection(
await tx.topicConfig.updateMany({
where: {
projectId,
+ enabled: true,
OR: [
{ summaryLlmApiKeyId: llmApiKeyId },
{ embeddingLlmApiKeyId: llmApiKeyId },
@@ -167,12 +168,15 @@ export async function pauseTopicsModelsUsingConnection(
enabled: false,
blockedAt: new Date(),
blockReason: EvaluatorBlockReason.LLM_CONNECTION_MISSING,
- blockMessage: `The LLM connection "${provider}" was deleted. Choose another connection and turn Topics on again.`,
+ blockMessage: `The LLM connection "${provider}" was deleted. Choose another connection in Configure Topics, then turn automatic processing back on.`,
},
});
}
-/** Settings shown in the Topics page; never includes secrets. */
+/**
+ * Settings shown in the Topics page; never includes secrets. `enabled` is null
+ * until the project saves Topics for the first time.
+ */
export async function readTopicsModelSettings(projectId: string) {
const row = await prisma.topicConfig.findUnique({
where: { projectId },
@@ -190,7 +194,7 @@ export async function readTopicsModelSettings(projectId: string) {
row?.clusteringLlmApiKeyId ?? null,
row?.clusteringModel ?? null,
),
- enabled: row?.enabled ?? false,
+ enabled: row ? row.enabled : null,
blockedAt: row?.blockedAt ?? null,
blockReason: row?.blockReason ?? null,
blockMessage: row?.blockMessage ?? null,
@@ -231,52 +235,156 @@ export async function checkTopicsModelSettings(
/**
* Validates and tests the settings without writing them, so callers can save
- * related configuration first and commit the models last.
+ * related configuration first and commit the models last. Saving keeps the
+ * stored automatic-processing state and pause; a first save starts off.
*/
export async function prepareTopicsModelSettings(
projectId: string,
settings: TopicsModelSettings,
) {
const keys = await loadTopicsModelKeys(projectId, settings);
+ const current = await prisma.topicConfig.findUnique({
+ where: { projectId },
+ });
+ const running = current?.enabled ?? false;
if (
- settings.enabled &&
+ running &&
(!settings.summary || !settings.embedding || !settings.clustering)
)
throw new InvalidRequestError(
- "Choose a summary, embedding, and clustering model before turning Topics on.",
+ "Choose a summary, embedding, and clustering model while automatic processing is on, or turn it off first.",
);
- const current = await prisma.topicConfig.findUnique({
- where: { projectId },
- });
+ const slots = resolveSavedSlots(settings, current);
const embeddingChanged =
current?.embeddingModel &&
- (settings.embedding?.model !== current.embeddingModel ||
- settings.embeddingDimensions !== current.embeddingDimensions);
+ (slots.embedding.model !== current.embeddingModel ||
+ slots.embeddingDimensions !== current.embeddingDimensions);
if (embeddingChanged && (await hasTopicEmbeddings(projectId)))
throw new InvalidRequestError(
"The embedding model and dimensions cannot change after summaries were embedded; existing vectors could no longer be clustered together.",
);
- await testTopicsModels(settings, keys);
+ // Only changed models are tested: the dialog tests each pick, turning
+ // processing on tests all three, and a broken stored connection pauses Topics.
+ await testTopicsModels(changedSlots(settings, current), keys);
const data = {
- enabled: settings.enabled,
- // Saving the settings acknowledges the last pause.
- blockedAt: null,
- blockReason: null,
- blockMessage: null,
- summaryLlmApiKeyId: settings.summary?.llmApiKeyId ?? null,
- summaryModel: settings.summary?.model ?? null,
- embeddingLlmApiKeyId: settings.embedding?.llmApiKeyId ?? null,
- embeddingModel: settings.embedding?.model ?? null,
- embeddingDimensions: settings.embeddingDimensions,
- clusteringLlmApiKeyId: settings.clustering?.llmApiKeyId ?? null,
- clusteringModel: settings.clustering?.model ?? null,
+ summaryLlmApiKeyId: slots.summary.llmApiKeyId,
+ summaryModel: slots.summary.model,
+ embeddingLlmApiKeyId: slots.embedding.llmApiKeyId,
+ embeddingModel: slots.embedding.model,
+ embeddingDimensions: slots.embeddingDimensions,
+ clusteringLlmApiKeyId: slots.clustering.llmApiKeyId,
+ clusteringModel: slots.clustering.model,
};
return data;
}
+type StoredTopicConfig = Awaited<
+ ReturnType<typeof prisma.topicConfig.findUnique>
+>;
+
+/**
+ * The slots to store. Saving with automatic processing off keeps the stored
+ * model of every slot that arrives empty, for example after its connection was
+ * deleted, so saving never discards a model.
+ */
+function resolveSavedSlots(
+ settings: TopicsModelSettings,
+ current: StoredTopicConfig,
+) {
+ const keep = current && !current.enabled ? current : null;
+ const slot = (
+ name: TopicsModelSlotName,
+ stored: { llmApiKeyId: string | null; model: string | null },
+ ) => {
+ const requested = settings[name];
+ if (requested) return requested;
+ return keep ? stored : { llmApiKeyId: null, model: null };
+ };
+ return {
+ summary: slot("summary", {
+ llmApiKeyId: current?.summaryLlmApiKeyId ?? null,
+ model: current?.summaryModel ?? null,
+ }),
+ embedding: slot("embedding", {
+ llmApiKeyId: current?.embeddingLlmApiKeyId ?? null,
+ model: current?.embeddingModel ?? null,
+ }),
+ embeddingDimensions:
+ keep && !settings.embedding
+ ? keep.embeddingDimensions
+ : settings.embeddingDimensions,
+ clustering: slot("clustering", {
+ llmApiKeyId: current?.clusteringLlmApiKeyId ?? null,
+ model: current?.clusteringModel ?? null,
+ }),
+ };
+}
+
+function changedSlots(
+ settings: TopicsModelSettings,
+ current: StoredTopicConfig,
+): TopicsModelSettings {
+ const changed = (
+ slot: TopicsModelSettings[TopicsModelSlotName],
+ llmApiKeyId: string | null | undefined,
+ model: string | null | undefined,
+ extraChange = false,
+ ) =>
+ slot &&
+ (extraChange || slot.llmApiKeyId !== llmApiKeyId || slot.model !== model)
+ ? slot
+ : null;
+ return {
+ ...settings,
+ summary: changed(
+ settings.summary,
+ current?.summaryLlmApiKeyId,
+ current?.summaryModel,
+ ),
+ embedding: changed(
+ settings.embedding,
+ current?.embeddingLlmApiKeyId,
+ current?.embeddingModel,
+ settings.embeddingDimensions !== current?.embeddingDimensions,
+ ),
+ clustering: changed(
+ settings.clustering,
+ current?.clusteringLlmApiKeyId,
+ current?.clusteringModel,
+ ),
+ };
+}
+
+/**
+ * Requires all three stored models before automatic processing is turned on,
+ * and tests them with real calls after a pause.
+ */
+export async function checkStoredTopicsModels(
+ config: NonNullable<StoredTopicConfig>,
+): Promise<void> {
+ const slot = (llmApiKeyId: string | null, model: string | null) =>
+ llmApiKeyId && model ? { llmApiKeyId, model } : null;
+ const settings = {
+ summary: slot(config.summaryLlmApiKeyId, config.summaryModel),
+ embedding: slot(config.embeddingLlmApiKeyId, config.embeddingModel),
+ embeddingDimensions: config.embeddingDimensions,
+ clustering: slot(config.clusteringLlmApiKeyId, config.clusteringModel),
+ };
+ if (!settings.summary || !settings.embedding || !settings.clustering)
+ throw new InvalidRequestError(
+ "Choose a summary, embedding, and clustering model in Configure Topics before turning on automatic processing.",
+ );
+ // Saved models were tested on save; a pause means a connection failed since.
+ if (!config.blockedAt) return;
+ await testTopicsModels(
+ settings,
+ await loadTopicsModelKeys(config.projectId, settings),
+ );
+}
+
export async function writeTopicsModelSettings(
projectId: string,
data: Awaited<ReturnType<typeof prepareTopicsModelSettings>>,
diff --git a/packages/shared/src/server/topics/postgres.ts b/packages/shared/src/server/topics/postgres.ts
index 64046aec24..bd0a8f6cb5 100644
--- a/packages/shared/src/server/topics/postgres.ts
+++ b/packages/shared/src/server/topics/postgres.ts
@@ -248,7 +248,7 @@ export async function writeTopicRule(
throw new InvalidRequestError("Select facets from this project.");
const rules = await tx.evaluationRule.findMany({
where: topicRuleWhere(input.projectId),
- select: { id: true, name: true },
+ select: { id: true, name: true, sampling: true },
});
if (rules.length > 1)
throw new InvalidRequestError(
@@ -262,7 +262,12 @@ export async function writeTopicRule(
);
if (input.id && input.id !== ruleId)
throw new InvalidRequestError("Topic rule not found in this project.");
- const config = topicRuleSettingsSchema.parse(input);
+ // Sampling belongs to automatic processing; a write without it keeps the rate.
+ const config = topicRuleSettingsSchema.parse({
+ ...input,
+ sampling:
+ input.sampling ?? (rules[0] ? Number(rules[0].sampling) : undefined),
+ });
const data = {
name,
filter: JSON.parse(JSON.stringify(config.filter)) as Prisma.InputJsonValue,
diff --git a/packages/shared/src/server/topics/setup.test.ts b/packages/shared/src/server/topics/setup.test.ts
index 1a6ceaa840..860c1d435b 100644
--- a/packages/shared/src/server/topics/setup.test.ts
+++ b/packages/shared/src/server/topics/setup.test.ts
@@ -48,13 +48,11 @@ const setup = {
embedding: { llmApiKeyId: "key", model: "embed" },
embeddingDimensions: 1024,
clustering: { llmApiKeyId: "key", model: "cluster" },
- enabled: true,
facets: facets.map((facet) => ({
name: facet.name,
enabled: facet.enabled,
})),
filter: [{ column: "name", type: "string", operator: "=", value: "billing" }],
- sampling: 0.25,
traceIdleMs: 120_000,
} satisfies Parameters<typeof saveTopicsSetup>[1];
@@ -63,7 +61,7 @@ describe("Topics setup", () => {
vi.resetAllMocks();
mocks.ensureFacets.mockResolvedValue(facets);
mocks.saveRule.mockResolvedValue({ id: "rule-a" });
- mocks.prepareModels.mockResolvedValue({ enabled: true });
+ mocks.prepareModels.mockResolvedValue({ summaryModel: "gpt" });
});
it("creates the built-in facets and one rule for the enabled ones", async () => {
@@ -74,19 +72,17 @@ describe("Topics setup", () => {
embedding: setup.embedding,
embeddingDimensions: 1024,
clustering: setup.clustering,
- enabled: true,
});
expect(mocks.ensureFacets).toHaveBeenCalledWith(projectId);
expect(mocks.saveRule).toHaveBeenCalledWith("tx", {
projectId,
filter: setup.filter,
- sampling: 0.25,
facetIds: facets.flatMap((facet) => (facet.enabled ? [facet.id] : [])),
userId: "user-a",
});
expect(mocks.writeModels).toHaveBeenCalledWith(
projectId,
- { enabled: true },
+ { summaryModel: "gpt" },
{ userId: "user-a", tx: "tx" },
);
expect(mocks.writeReadiness).toHaveBeenCalledWith(
diff --git a/packages/shared/src/server/topics/setup.ts b/packages/shared/src/server/topics/setup.ts
index 4fba401402..938fd684c0 100644
--- a/packages/shared/src/server/topics/setup.ts
+++ b/packages/shared/src/server/topics/setup.ts
@@ -1,7 +1,12 @@
import type { z } from "zod";
import { InvalidRequestError } from "../../errors";
-import { topicsSetupSchema, type TopicRule } from "../../topics";
import {
+ topicsAutomaticProcessingSchema,
+ topicsSetupSchema,
+ type TopicRule,
+} from "../../topics";
+import {
+ checkStoredTopicsModels,
prepareTopicsModelSettings,
writeTopicsModelSettings,
} from "./model-config";
@@ -12,12 +17,20 @@ import {
} from "../tracingReadinessSettings";
import {
ensureDefaultTopicFacets,
+ getTopicRule,
+ listTopicRules,
writeTopicRule,
type TopicRuleInput,
} from "./postgres";
-import { invalidateTopicsProcessingActive } from "./processing-gate";
+import {
+ invalidateTopicsProcessingActive,
+ topicRuleWhere,
+} from "./processing-gate";
-/** One Topics setup: models, the four built-in facets, and a single rule. */
+/**
+ * One Topics setup: models, the four built-in facets, and a single rule. It
+ * keeps the stored automatic-processing state, pause and sampling rate.
+ */
export async function saveTopicsSetup(
projectId: string,
input: z.input<typeof topicsSetupSchema>,
@@ -46,7 +59,6 @@ export async function saveTopicsSetup(
embedding: setup.embedding,
embeddingDimensions: setup.embeddingDimensions,
clustering: setup.clustering,
- enabled: setup.enabled,
});
return saveTopicRuleAndModels(
{
@@ -54,7 +66,6 @@ export async function saveTopicsSetup(
projectId,
userId,
filter: setup.filter,
- sampling: setup.sampling,
facetIds,
},
models,
@@ -89,3 +100,52 @@ export async function saveTopicRuleAndModels(
await invalidateTopicsProcessingActive(rule.projectId);
return saved;
}
+
+/**
+ * Turns automatic processing of new traces on or off. Turning it on requires all
+ * three stored models and re-tests them after a pause; either direction clears
+ * a pause.
+ * Sampling, when given, is written to the project's Topics rule.
+ */
+export async function setTopicsAutomaticProcessing(
+ projectId: string,
+ input: z.input<typeof topicsAutomaticProcessingSchema>,
+ userId: string | null = null,
+): Promise<{ ruleBefore: TopicRule; ruleAfter: TopicRule }> {
+ const { enabled, sampling } = topicsAutomaticProcessingSchema.parse(input);
+ const [config, rules] = await Promise.all([
+ prisma.topicConfig.findUnique({ where: { projectId } }),
+ listTopicRules(projectId),
+ ]);
+ const rule = rules[0];
+ if (!config || !rule)
+ throw new InvalidRequestError(
+ "Save the Topics setup in Configure Topics first.",
+ );
+ if (rules.length > 1)
+ throw new InvalidRequestError(
+ "This project has more than one Topics rule.",
+ );
+ if (enabled) await checkStoredTopicsModels(config);
+
+ await prisma.$transaction(async (tx) => {
+ await tx.topicConfig.update({
+ where: { projectId },
+ data: {
+ enabled,
+ blockedAt: null,
+ blockReason: null,
+ blockMessage: null,
+ updatedBy: userId,
+ },
+ });
+ if (sampling !== undefined && sampling !== rule.sampling)
+ await tx.evaluationRule.update({
+ where: { ...topicRuleWhere(projectId), id: rule.id },
+ data: { sampling },
+ });
+ });
+ await invalidateTopicsProcessingActive(projectId);
+ const ruleAfter = (await getTopicRule(projectId, rule.id)) ?? rule;
+ return { ruleBefore: rule, ruleAfter };
+}
diff --git a/packages/shared/src/topics/index.ts b/packages/shared/src/topics/index.ts
index 061a0b7e6e..d3d81a1a87 100644
--- a/packages/shared/src/topics/index.ts
+++ b/packages/shared/src/topics/index.ts
@@ -67,7 +67,6 @@ export const topicsModelSettingsSchema = z.object({
embeddingDimensions:
topicEmbeddingConfigSchema.shape.embeddingDimensions.unwrap(),
clustering: topicsModelSlotSchema.nullable(),
- enabled: z.boolean(),
});
export type TopicsModelSettings = z.infer<typeof topicsModelSettingsSchema>;
export const topicProcessingConfigSchema = z.object({
@@ -149,10 +148,21 @@ export const topicsSetupSchema = topicsModelSettingsSchema.extend({
// Enabled custom facets keep their rule assignment; they are edited elsewhere.
customFacetIds: z.array(topicIdSchema).default([]),
filter: topicRuleConfigSchema.shape.filter,
- sampling: z.number().min(0).max(1),
});
export type TopicsSetup = z.infer<typeof topicsSetupSchema>;
+/**
+ * Turns automatic processing of new traces on or off. Sampling applies only to
+ * automatic processing; omit it to keep the rule's stored rate.
+ */
+export const topicsAutomaticProcessingSchema = z.object({
+ enabled: z.boolean(),
+ sampling: z.number().min(0).max(1).optional(),
+});
+export type TopicsAutomaticProcessing = z.infer<
+ typeof topicsAutomaticProcessingSchema
+>;
+
export type TopicRule = z.infer<typeof topicRuleSettingsSchema> & {
id: string;
projectId: string;
diff --git a/web/.storybook/main.ts b/web/.storybook/main.ts
index f9eeb5c48a..15a1aeac7c 100644
--- a/web/.storybook/main.ts
+++ b/web/.storybook/main.ts
@@ -194,6 +194,12 @@ const config: StorybookConfig = {
find: /^@langfuse\/shared\/in-app-agent$/,
replacement: `${sharedSrc}/in-app-agent`,
},
+ // Client-safe Topics schemas and constants; no rule for
+ // `/topics/server`, for the same reason.
+ {
+ find: /^@langfuse\/shared\/topics$/,
+ replacement: `${sharedSrc}/topics`,
+ },
{
find: /^\.prisma\/client\/index-browser$/,
replacement: prismaBrowserStub,
diff --git a/web/src/__tests__/server/topics-setup.servertest.ts b/web/src/__tests__/server/topics-setup.servertest.ts
new file mode 100644
index 0000000000..116c976d25
--- /dev/null
+++ b/web/src/__tests__/server/topics-setup.servertest.ts
@@ -0,0 +1,296 @@
+import { randomUUID } from "crypto";
+import { DEFAULT_TOPIC_FACETS } from "@langfuse/shared/topics";
+import { EvaluatorBlockReason, prisma } from "@langfuse/shared/src/db";
+import { createOrgProjectAndApiKey, redis } from "@langfuse/shared/src/server";
+import { LLMAdapter } from "@langfuse/shared";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+
+const mocks = vi.hoisted(() => ({
+ testModelCall: vi.fn(),
+ generateTopicEmbeddings: vi.fn(),
+}));
+vi.mock("@langfuse/shared/src/server/llm/testModelCall", () => ({
+ testModelCall: mocks.testModelCall,
+}));
+vi.mock(
+ "@langfuse/shared/src/server/topics/embeddings",
+ async (importOriginal) => ({
+ ...(await importOriginal<Record<string, unknown>>()),
+ generateTopicEmbeddings: mocks.generateTopicEmbeddings,
+ }),
+);
+
+import {
+ listTopicRules,
+ pauseTopicsModelsUsingConnection,
+ saveTopicsSetup,
+ setTopicsAutomaticProcessing,
+} from "@langfuse/shared/topics/server";
+
+const pause = {
+ blockedAt: new Date(),
+ blockReason: EvaluatorBlockReason.LLM_CONNECTION_AUTH_INVALID,
+ blockMessage: "The provider rejected the API key.",
+};
+const clearedBlock = { blockedAt: null, blockReason: null, blockMessage: null };
+
+/** A project with stored models; `stored` sets the automatic-processing state. */
+async function topicsProject(
+ stored: { enabled: boolean } & Partial<typeof pause> = { enabled: false },
+) {
+ const { projectId } = await createOrgProjectAndApiKey();
+ const connection = await prisma.llmApiKeys.create({
+ data: {
+ projectId,
+ provider: `openai-${randomUUID()}`,
+ adapter: LLMAdapter.OpenAI,
+ secretKey: "encrypted",
+ displaySecretKey: "...key",
+ },
+ });
+ const slot = (model: string) => ({ llmApiKeyId: connection.id, model });
+ await prisma.topicConfig.create({
+ data: {
+ projectId,
+ ...stored,
+ summaryLlmApiKeyId: connection.id,
+ summaryModel: "gpt-6-luna",
+ embeddingLlmApiKeyId: connection.id,
+ embeddingModel: "text-embedding-3-small",
+ embeddingDimensions: 1024,
+ clusteringLlmApiKeyId: connection.id,
+ clusteringModel: "gpt-5.6-terra",
+ },
+ });
+ const setup = {
+ summary: slot("gpt-6-luna"),
+ embedding: slot("text-embedding-3-small"),
+ embeddingDimensions: 1024,
+ clustering: slot("gpt-5.6-terra"),
+ facets: DEFAULT_TOPIC_FACETS.map((facet) => ({
+ name: facet.name,
+ enabled: true,
+ })),
+ filter: [],
+ traceIdleMs: 600_000,
+ };
+ return { projectId, connection, setup };
+}
+
+const storedConfig = (projectId: string) =>
+ prisma.topicConfig.findUniqueOrThrow({ where: { projectId } });
+
+const modelsWork = () => {
+ mocks.testModelCall.mockResolvedValue(undefined);
+ mocks.generateTopicEmbeddings.mockImplementation(
+ async ({ summaries, dimensions }) => ({
+ embeddings: summaries.map(() => Array(dimensions).fill(0.1)),
+ }),
+ );
+};
+const modelsFail = () => {
+ mocks.testModelCall.mockRejectedValue(new Error("Invalid API key."));
+ mocks.generateTopicEmbeddings.mockRejectedValue(
+ new Error("Invalid API key."),
+ );
+};
+
+beforeEach(() => {
+ mocks.testModelCall.mockReset();
+ mocks.generateTopicEmbeddings.mockReset();
+});
+
+describe("saveTopicsSetup", () => {
+ it("starts with automatic processing off on the first save", async () => {
+ const { projectId, setup } = await topicsProject();
+ await prisma.topicConfig.delete({ where: { projectId } });
+ modelsWork();
+
+ await saveTopicsSetup(projectId, setup);
+
+ expect(await storedConfig(projectId)).toMatchObject({
+ enabled: false,
+ ...clearedBlock,
+ });
+ });
+
+ it("keeps automatic processing on without testing unchanged models", async () => {
+ modelsFail();
+ const { projectId, setup } = await topicsProject({ enabled: true });
+
+ await saveTopicsSetup(projectId, setup);
+
+ expect(mocks.testModelCall).not.toHaveBeenCalled();
+ expect(mocks.generateTopicEmbeddings).not.toHaveBeenCalled();
+ expect(await storedConfig(projectId)).toMatchObject({ enabled: true });
+ });
+
+ it("keeps a pause and its reason without testing unchanged models", async () => {
+ modelsFail();
+ const { projectId, setup } = await topicsProject({
+ enabled: false,
+ ...pause,
+ });
+
+ await saveTopicsSetup(projectId, setup);
+
+ expect(mocks.testModelCall).not.toHaveBeenCalled();
+ expect(mocks.generateTopicEmbeddings).not.toHaveBeenCalled();
+ expect(await storedConfig(projectId)).toMatchObject({
+ enabled: false,
+ blockReason: pause.blockReason,
+ blockMessage: pause.blockMessage,
+ });
+ });
+
+ it("keeps the stored models of empty slots while off", async () => {
+ const { projectId, setup } = await topicsProject({
+ enabled: false,
+ ...pause,
+ });
+
+ await saveTopicsSetup(projectId, {
+ ...setup,
+ summary: null,
+ embedding: null,
+ embeddingDimensions: 512,
+ clustering: null,
+ });
+
+ expect(await storedConfig(projectId)).toMatchObject({
+ summaryModel: "gpt-6-luna",
+ embeddingModel: "text-embedding-3-small",
+ embeddingDimensions: 1024,
+ clusteringModel: "gpt-5.6-terra",
+ });
+ });
+
+ it("tests only the changed models while off", async () => {
+ mocks.testModelCall.mockRejectedValue(new Error("Unknown model."));
+ const { projectId, setup } = await topicsProject();
+
+ await expect(
+ saveTopicsSetup(projectId, {
+ ...setup,
+ clustering: { ...setup.clustering, model: "gpt-unknown" },
+ }),
+ ).rejects.toThrow("Unknown model.");
+ expect(mocks.testModelCall).toHaveBeenCalledOnce();
+ expect(mocks.generateTopicEmbeddings).not.toHaveBeenCalled();
+ });
+
+ it("keeps the rule's sampling rate", async () => {
+ const { projectId, setup } = await topicsProject();
+ const { id: ruleId } = await saveTopicsSetup(projectId, setup);
+ await setTopicsAutomaticProcessing(projectId, {
+ enabled: false,
+ sampling: 0.25,
+ });
+
+ await saveTopicsSetup(projectId, { ...setup, ruleId });
+
+ const [rule] = await listTopicRules(projectId);
+ expect(rule?.sampling).toBe(0.25);
+ });
+});
+
+describe("setTopicsAutomaticProcessing", () => {
+ it("tests the models, clears the pause and saves sampling when turned on", async () => {
+ const { projectId, setup } = await topicsProject({
+ enabled: false,
+ ...pause,
+ });
+ await saveTopicsSetup(projectId, setup);
+ modelsWork();
+ const cacheKey = `langfuse:topics:processing-active:${projectId}`;
+ await redis?.set(cacheKey, "0");
+
+ const { ruleBefore, ruleAfter } = await setTopicsAutomaticProcessing(
+ projectId,
+ { enabled: true, sampling: 0.5 },
+ );
+
+ expect(mocks.testModelCall).toHaveBeenCalledTimes(2);
+ expect(mocks.generateTopicEmbeddings).toHaveBeenCalledOnce();
+ expect(await storedConfig(projectId)).toMatchObject({
+ enabled: true,
+ ...clearedBlock,
+ });
+ expect([ruleBefore.sampling, ruleAfter.sampling]).toEqual([1, 0.5]);
+ expect(await redis?.get(cacheKey)).toBeNull();
+ });
+
+ it("stays paused when a model test fails", async () => {
+ const { projectId, setup } = await topicsProject({
+ enabled: false,
+ ...pause,
+ });
+ await saveTopicsSetup(projectId, setup);
+ modelsFail();
+
+ await expect(
+ setTopicsAutomaticProcessing(projectId, { enabled: true }),
+ ).rejects.toThrow("Invalid API key.");
+ expect(await storedConfig(projectId)).toMatchObject({
+ enabled: false,
+ blockReason: pause.blockReason,
+ });
+ });
+
+ it("refuses to turn on after a connection was deleted while off", async () => {
+ modelsWork();
+ const { projectId, connection, setup } = await topicsProject();
+ await saveTopicsSetup(projectId, setup);
+ await prisma.llmApiKeys.delete({ where: { id: connection.id } });
+
+ await expect(
+ setTopicsAutomaticProcessing(projectId, { enabled: true }),
+ ).rejects.toThrow("before turning on automatic processing");
+ expect(await storedConfig(projectId)).toMatchObject({
+ enabled: false,
+ ...clearedBlock,
+ });
+ });
+
+ it("turns off and clears a pause without testing the models", async () => {
+ modelsFail();
+ const { projectId, setup } = await topicsProject({
+ enabled: false,
+ ...pause,
+ });
+ await saveTopicsSetup(projectId, setup);
+
+ await setTopicsAutomaticProcessing(projectId, { enabled: false });
+
+ expect(mocks.testModelCall).not.toHaveBeenCalled();
+ expect(await storedConfig(projectId)).toMatchObject({
+ enabled: false,
+ ...clearedBlock,
+ });
+ });
+
+ it("refuses before the setup was saved", async () => {
+ const { projectId } = await topicsProject();
+
+ await expect(
+ setTopicsAutomaticProcessing(projectId, { enabled: true }),
+ ).rejects.toThrow("Save the Topics setup");
+ });
+});
+
+describe("pauseTopicsModelsUsingConnection", () => {
+ it("does not mark a switched-off config paused", async () => {
+ const { projectId, connection } = await topicsProject();
+
+ await pauseTopicsModelsUsingConnection({
+ projectId,
+ llmApiKeyId: connection.id,
+ provider: "openai",
+ });
+
+ expect(await storedConfig(projectId)).toMatchObject({
+ enabled: false,
+ ...clearedBlock,
+ });
+ });
+});
diff --git a/web/src/__tests__/server/unit/topics.servertest.ts b/web/src/__tests__/server/unit/topics.servertest.ts
index ca90e0b2d8..628abe2db3 100644
--- a/web/src/__tests__/server/unit/topics.servertest.ts
+++ b/web/src/__tests__/server/unit/topics.servertest.ts
@@ -21,7 +21,6 @@ const mocks = vi.hoisted(() => ({
readLatestTopicAssignments: vi.fn(),
getLatestFacetSummaries: vi.fn(),
getPublishedTopicRun: vi.fn(),
- ensureDefaultTopicFacets: vi.fn(),
getTopicFacetVersion: vi.fn(),
createTopicFacet: vi.fn(),
createTopicFacetVersion: vi.fn(),
@@ -38,6 +37,7 @@ const mocks = vi.hoisted(() => ({
getTopicsModels: vi.fn(),
checkTopicsModelSettings: vi.fn(),
saveTopicsSetup: vi.fn(),
+ setTopicsAutomaticProcessing: vi.fn(),
enqueueTopicExecution: vi.fn(),
getTopicExecutionQueueState: vi.fn(),
queryClickhouse: vi.fn(),
@@ -267,12 +267,9 @@ describe("Topics project allowlist", () => {
it("keeps reads and facet configuration available when processing is disabled", async () => {
mocks.isTopicsProjectEnabled.mockReturnValue(false);
mocks.listTopicFacets.mockResolvedValue([]);
- mocks.ensureDefaultTopicFacets.mockResolvedValue([]);
await expect(caller().facets({ projectId })).resolves.toEqual([]);
- await expect(caller().initialize({ projectId })).resolves.toEqual([]);
expect(mocks.listTopicFacets).toHaveBeenCalledWith(projectId);
- expect(mocks.ensureDefaultTopicFacets).toHaveBeenCalledWith(projectId);
});
});
@@ -1288,7 +1285,6 @@ describe("Topics model settings", () => {
embedding: { llmApiKeyId: "key", model: "text-embedding-3-small" },
embeddingDimensions: 1024,
clustering: null,
- enabled: false,
};
it("returns the slot check to a writer and rejects a viewer before testing", async () => {
@@ -1312,7 +1308,6 @@ describe("Topics model settings", () => {
embedding: settings.embedding,
embeddingDimensions: 1024,
clustering: null,
- enabled: false,
});
});
});
@@ -1324,7 +1319,6 @@ describe("Topics setup", () => {
embedding: { llmApiKeyId: "key", model: "embed" },
embeddingDimensions: 1024,
clustering: { llmApiKeyId: "key", model: "cluster" },
- enabled: true,
facets: DEFAULT_TOPIC_FACETS.map((facet) => ({
name: facet.name,
enabled: facet.name !== "Sentiment",
@@ -1337,7 +1331,6 @@ describe("Topics setup", () => {
value: "billing",
},
],
- sampling: 0.25,
traceIdleMs: 120_000,
};
@@ -1361,11 +1354,9 @@ describe("Topics setup", () => {
embedding: setup.embedding,
embeddingDimensions: 1024,
clustering: setup.clustering,
- enabled: true,
facets: setup.facets,
customFacetIds: [],
filter: setup.filter,
- sampling: 0.25,
traceIdleMs: 120_000,
},
"user-a",
@@ -1393,6 +1384,71 @@ describe("Topics setup", () => {
});
});
+describe("Topics automatic processing", () => {
+ const rule = {
+ id: "rule-a",
+ projectId,
+ name: "Topics",
+ filter: [],
+ facetIds: [facetId],
+ updatedAt: "2026-10-13T00:00:00Z",
+ };
+
+ it("turns processing on with sampling and audit-logs the sampling change", async () => {
+ mocks.isTopicsProjectEnabled.mockReturnValue(true);
+ mocks.setTopicsAutomaticProcessing.mockResolvedValue({
+ ruleBefore: { ...rule, sampling: 1 },
+ ruleAfter: { ...rule, sampling: 0.25 },
+ });
+
+ await expect(
+ caller().setAutomaticProcessing({
+ projectId,
+ enabled: true,
+ sampling: 0.25,
+ }),
+ ).resolves.toEqual({ enabled: true, sampling: 0.25 });
+ expect(mocks.setTopicsAutomaticProcessing).toHaveBeenCalledWith(
+ projectId,
+ { enabled: true, sampling: 0.25 },
+ "user-a",
+ );
+ expect(mocks.auditLog).toHaveBeenCalledWith(
+ expect.objectContaining({
+ resourceType: "job",
+ resourceId: "rule-a",
+ action: "update",
+ before: expect.objectContaining({ sampling: 1 }),
+ after: expect.objectContaining({ sampling: 0.25 }),
+ }),
+ );
+ });
+
+ it("refuses to turn on a project that is not on the Topics allowlist", async () => {
+ mocks.isTopicsProjectEnabled.mockReturnValue(false);
+
+ await expect(
+ caller().setAutomaticProcessing({ projectId, enabled: true }),
+ ).rejects.toMatchObject({ code: "BAD_REQUEST" });
+ expect(mocks.setTopicsAutomaticProcessing).not.toHaveBeenCalled();
+ });
+
+ it("turns processing off for a project that is not on the allowlist", async () => {
+ mocks.isTopicsProjectEnabled.mockReturnValue(false);
+ mocks.setTopicsAutomaticProcessing.mockResolvedValue({
+ ruleBefore: { ...rule, sampling: 1 },
+ ruleAfter: { ...rule, sampling: 1 },
+ });
+
+ await expect(
+ caller().setAutomaticProcessing({ projectId, enabled: false }),
+ ).resolves.toEqual({ enabled: false, sampling: 1 });
+ expect(mocks.auditLog).not.toHaveBeenCalledWith(
+ expect.objectContaining({ resourceType: "job" }),
+ );
+ });
+});
+
describe("Topics write access", () => {
const facetDraft = {
name: "Intent",
@@ -1405,13 +1461,11 @@ describe("Topics write access", () => {
embedding: slot,
embeddingDimensions: 1024,
clustering: slot,
- enabled: true,
};
const writes: Record<
string,
(api: ReturnType<typeof caller>, projectId: string) => Promise<unknown>
> = {
- initialize: (api, projectId) => api.initialize({ projectId }),
saveFacet: (api, projectId) => api.saveFacet({ projectId, ...facetDraft }),
saveRule: (api, projectId) =>
api.saveRule({
@@ -1431,20 +1485,21 @@ describe("Topics write access", () => {
enabled: true,
})),
filter: [],
- sampling: 1,
traceIdleMs: 120_000,
}),
+ setAutomaticProcessing: (api, projectId) =>
+ api.setAutomaticProcessing({ projectId, enabled: true, sampling: 0.5 }),
trigger: (api, projectId) => api.trigger({ ...input, projectId }),
retry: (api, projectId) =>
api.retry({ projectId, executionId: "execution-a" }),
};
const writeMocks = [
- mocks.ensureDefaultTopicFacets,
mocks.createTopicFacet,
mocks.createTopicFacetVersion,
mocks.saveTopicRule,
mocks.checkTopicsModelSettings,
mocks.saveTopicsSetup,
+ mocks.setTopicsAutomaticProcessing,
mocks.createTopicExecution,
mocks.enqueueTopicExecution,
mocks.auditLog,
diff --git a/web/src/components/ui/sheet.tsx b/web/src/components/ui/sheet.tsx
index fcfb7c4ce2..c88baa5d95 100644
--- a/web/src/components/ui/sheet.tsx
+++ b/web/src/components/ui/sheet.tsx
@@ -65,34 +65,27 @@ const sheetVariants = cva(
interface SheetContentProps
extends
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,
- VariantProps<typeof sheetVariants> {
- overlayClassName?: string;
-}
+ VariantProps<typeof sheetVariants> {}
const SheetContent = React.forwardRef<
React.ComponentRef<typeof SheetPrimitive.Content>,
SheetContentProps
->(
- (
- { side = "right", className, children, overlayClassName, ...props },
- ref,
- ) => (
- <SheetPortal>
- <SheetOverlay className={overlayClassName} />
- <SheetPrimitive.Content
- ref={ref}
- className={cn(sheetVariants({ side }), className)}
- {...props}
- >
- {children}
- <SheetPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-2 right-2 inline-flex size-8 items-center justify-center rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none">
- <X className="icon-base" />
- <span className="sr-only">Close</span>
- </SheetPrimitive.Close>
- </SheetPrimitive.Content>
- </SheetPortal>
- ),
-);
+>(({ side = "right", className, children, ...props }, ref) => (
+ <SheetPortal>
+ <SheetOverlay />
+ <SheetPrimitive.Content
+ ref={ref}
+ className={cn(sheetVariants({ side }), className)}
+ {...props}
+ >
+ {children}
+ <SheetPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-2 right-2 inline-flex size-8 items-center justify-center rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none">
+ <X className="icon-base" />
+ <span className="sr-only">Close</span>
+ </SheetPrimitive.Close>
+ </SheetPrimitive.Content>
+ </SheetPortal>
+));
SheetContent.displayName = SheetPrimitive.Content.displayName;
const SheetHeader = ({
diff --git a/web/src/features/topics/AutomaticProcessingControl.stories.tsx b/web/src/features/topics/AutomaticProcessingControl.stories.tsx
new file mode 100644
index 0000000000..aa8d0f9b26
--- /dev/null
+++ b/web/src/features/topics/AutomaticProcessingControl.stories.tsx
@@ -0,0 +1,34 @@
+import { expect, fn, userEvent, within } from "storybook/test";
+
+import preview from "../../../.storybook/preview";
+import { AutomaticProcessingControl } from "./AutomaticProcessingControl";
+
+const meta = preview.meta({
+ component: AutomaticProcessingControl,
+ parameters: { layout: "centered" },
+ args: { canWrite: true, onOpen: fn() },
+});
+
+export default meta;
+
+export const Unconfigured = meta.story({
+ args: { state: { status: "unconfigured" } },
+});
+
+export const Off = meta.story({
+ name: "(Test) Opens the dialog to turn on",
+ args: { state: { status: "off" } },
+ play: async ({ args }) => {
+ const body = within(document.body);
+ await userEvent.click(
+ body.getByRole("button", { name: /Automatic processing/ }),
+ );
+ await expect(args.onOpen).toHaveBeenCalledOnce();
+ },
+});
+
+export const On = meta.story({ args: { state: { status: "on" } } });
+
+export const Paused = meta.story({
+ args: { state: { status: "paused", shortLabel: "LLM connection missing" } },
+});
diff --git a/web/src/features/topics/AutomaticProcessingControl.tsx b/web/src/features/topics/AutomaticProcessingControl.tsx
new file mode 100644
index 0000000000..66d3d3dc3e
--- /dev/null
+++ b/web/src/features/topics/AutomaticProcessingControl.tsx
@@ -0,0 +1,76 @@
+import { Tooltip } from "@/src/components/design-system/Tooltip/Tooltip";
+import { cn } from "@/src/utils/tailwind";
+
+export type AutomaticProcessingState =
+ | { status: "unconfigured" }
+ | { status: "unavailable" }
+ | { status: "off" }
+ | { status: "on" }
+ | { status: "paused"; shortLabel: string };
+
+type AutomaticProcessingControlProps = {
+ state: AutomaticProcessingState;
+ canWrite: boolean;
+ onOpen: () => void;
+};
+
+/**
+ * Topics header status for automatic processing. Turning it on or off and the
+ * sampling rate happen in the dialog it opens, next to the models that run.
+ */
+export function AutomaticProcessingControl({
+ canWrite,
+ onOpen,
+ state,
+}: AutomaticProcessingControlProps) {
+ const reason = disabledReason(state, canWrite);
+ const button = (
+ // Matches the secondary header buttons; the live dot is StatusBadge's.
+ <button
+ type="button"
+ className="bg-secondary text-secondary-foreground hover:bg-secondary/80 ring-offset-background focus-visible:ring-ring inline-flex h-7 shrink-0 items-center gap-2 rounded-md px-2 text-xs whitespace-nowrap transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50"
+ aria-label={`Automatic processing: ${statusLabel(state)}`}
+ disabled={reason !== null}
+ onClick={onOpen}
+ >
+ <span aria-hidden className="relative inline-flex size-2 shrink-0">
+ {state.status === "on" ? (
+ <span className="bg-dark-green absolute inline-flex size-full animate-ping rounded-full opacity-75" />
+ ) : null}
+ <span
+ className={cn(
+ "relative inline-flex size-2 rounded-full",
+ dotClass(state),
+ )}
+ />
+ </span>
+ Automatic processing
+ </button>
+ );
+ if (!reason) return button;
+ return (
+ <Tooltip label={state.status === "paused" ? state.shortLabel : reason}>
+ {({ getTriggerProps }) => <span {...getTriggerProps()}>{button}</span>}
+ </Tooltip>
+ );
+}
+
+function dotClass(state: AutomaticProcessingState) {
+ if (state.status === "on") return "bg-dark-green";
+ if (state.status === "paused") return "bg-dark-yellow";
+ return "bg-muted-foreground";
+}
+
+function statusLabel(state: AutomaticProcessingState) {
+ if (state.status === "on") return "On";
+ if (state.status === "paused") return "Paused";
+ return "Off";
+}
+
+function disabledReason(state: AutomaticProcessingState, canWrite: boolean) {
+ if (state.status === "unconfigured") return "Configure Topics first.";
+ if (state.status === "unavailable")
+ return "Topics processing is not enabled for this project.";
+ if (!canWrite) return "You need permission to edit Topics.";
+ return null;
+}
diff --git a/web/src/features/topics/AutomaticProcessingDialog.stories.tsx b/web/src/features/topics/AutomaticProcessingDialog.stories.tsx
new file mode 100644
index 0000000000..f55aff3068
--- /dev/null
+++ b/web/src/features/topics/AutomaticProcessingDialog.stories.tsx
@@ -0,0 +1,103 @@
+import * as DialogPrimitive from "@radix-ui/react-dialog";
+import { expect, fn, userEvent, within } from "storybook/test";
+
+import preview from "../../../.storybook/preview";
+import { AutomaticProcessingDialog } from "./AutomaticProcessingDialog";
+
+const models = {
+ summary: "us.openai.gpt-6-luna",
+ embedding: "us.cohere.embed-v4:0",
+ clustering: "us.openai.gpt-5.6-terra",
+};
+
+const meta = preview.meta({
+ component: AutomaticProcessingDialog,
+ parameters: { layout: "fullscreen" },
+ decorators: [
+ (Story) => (
+ <DialogPrimitive.Root open>
+ <Story />
+ </DialogPrimitive.Root>
+ ),
+ ],
+ args: {
+ initialEnabled: false,
+ initialSampling: 1,
+ traceIdleMs: 600_000,
+ models,
+ paused: null,
+ saving: false,
+ error: null,
+ onSave: fn(),
+ },
+});
+
+export default meta;
+
+export const Enable = meta.story({});
+
+export const EditSampling = meta.story({
+ args: { initialEnabled: true, initialSampling: 0.25 },
+});
+
+export const Paused = meta.story({
+ args: {
+ paused: {
+ shortLabel: "LLM connection authentication failed",
+ message:
+ 'The facet summaries model us.openai.gpt-6-luna on LLM connection "Amazon Bedrock" failed (HTTP 401). Check the connection\'s credentials, the model ID, and provider availability. Automatic processing was paused. Fix the connection, then turn automatic processing back on.',
+ },
+ },
+});
+
+export const MissingModel = meta.story({
+ name: "(Test) A deleted connection blocks turning on",
+ args: {
+ models: { ...models, clustering: null },
+ paused: {
+ shortLabel: "LLM connection missing",
+ message:
+ 'The LLM connection "Amazon Bedrock" was deleted. Choose another connection in Configure Topics, then turn automatic processing back on.',
+ },
+ },
+ play: async () => {
+ const body = within(document.body);
+ await expect(await body.findByText("Not set")).toBeInTheDocument();
+ await userEvent.click(
+ body.getByRole("switch", { name: "Automatic processing" }),
+ );
+ await expect(body.getByRole("button", { name: "Save" })).toBeDisabled();
+ },
+});
+
+export const SubmitsSampling = meta.story({
+ name: "(Test) Turning on saves the chosen sampling rate",
+ args: { initialSampling: 0.25 },
+ play: async ({ args }) => {
+ const body = within(document.body);
+ await userEvent.click(
+ body.getByRole("switch", { name: "Automatic processing" }),
+ );
+ await userEvent.click(body.getByRole("button", { name: "Save" }));
+ await expect(args.onSave).toHaveBeenCalledWith({
+ enabled: true,
+ sampling: 0.25,
+ });
+ },
+});
+
+export const TurnsOff = meta.story({
+ name: "(Test) Turning off saves processing as off",
+ args: { initialEnabled: true, initialSampling: 0.25 },
+ play: async ({ args }) => {
+ const body = within(document.body);
+ await userEvent.click(
+ body.getByRole("switch", { name: "Automatic processing" }),
+ );
+ await userEvent.click(body.getByRole("button", { name: "Save" }));
+ await expect(args.onSave).toHaveBeenCalledWith({
+ enabled: false,
+ sampling: 0.25,
+ });
+ },
+});
diff --git a/web/src/features/topics/AutomaticProcessingDialog.tsx b/web/src/features/topics/AutomaticProcessingDialog.tsx
new file mode 100644
index 0000000000..fee8564fbf
--- /dev/null
+++ b/web/src/features/topics/AutomaticProcessingDialog.tsx
@@ -0,0 +1,146 @@
+import { useState } from "react";
+import { Info } from "lucide-react";
+import { Alert } from "@/src/components/design-system/Alert/Alert";
+import { Dialog } from "@/src/components/design-system/Dialog/Dialog";
+import { SwitchInput } from "@/src/components/design-system/SwitchInput/SwitchInput";
+import { RuleSamplingSection } from "@/src/features/evals/v2/components/Rules/RuleSetup/components/RuleSamplingSection";
+import { createRuleSetupStore } from "@/src/features/evals/v2/stores/createRuleSetupStore";
+import {
+ TOPICS_MODEL_SLOT_DETAILS,
+ TOPICS_MODEL_SLOTS,
+ type TopicsModelSlotName,
+} from "@langfuse/shared/topics";
+
+type AutomaticProcessingDialogProps = {
+ initialEnabled: boolean;
+ initialSampling: number;
+ traceIdleMs: number;
+ models: Record<TopicsModelSlotName, string | null>;
+ paused: { shortLabel: string; message: string } | null;
+ saving: boolean;
+ error: string | null;
+ onSave: (input: { enabled: boolean; sampling: number }) => void;
+};
+
+const COST_NOTE =
+ "Each sampled trace makes LLM calls on your connections, so cost depends on your trace volume, the selected models, and the sampling rate.";
+
+/** Dialog content; render it inside a Radix `Dialog.Root`. */
+export function AutomaticProcessingDialog({
+ error,
+ initialEnabled,
+ initialSampling,
+ models,
+ onSave,
+ paused,
+ saving,
+ traceIdleMs,
+}: AutomaticProcessingDialogProps) {
+ const [samplingStore] = useState(() =>
+ createRuleSetupStore({
+ name: "",
+ filter: [],
+ sampling: initialSampling,
+ assignments: [],
+ }),
+ );
+ const [enabled, setEnabled] = useState(initialEnabled);
+ const missingModel = TOPICS_MODEL_SLOTS.some((slot) => !models[slot]);
+ return (
+ <Dialog
+ title="Automatic processing"
+ actions={[
+ {
+ label: "Save",
+ loading: saving,
+ disabled: saving || (enabled && missingModel),
+ onClick: () =>
+ onSave({ enabled, sampling: samplingStore.getState().sampling }),
+ },
+ ]}
+ >
+ <Dialog.Body>
+ <div className="flex flex-col gap-4">
+ <p className="text-sm">
+ New traces are summarized with your saved facets and models once
+ they have been idle for {idleTimeLabel(traceIdleMs)}. The sampling
+ rate below applies only to automatic processing. For manual
+ processing, such as backfills, you set the sampling for each run.
+ </p>
+ {paused ? (
+ <Alert variant="warning">
+ <Alert.Title>Paused: {paused.shortLabel}</Alert.Title>
+ <Alert.Description>
+ <p className="break-words">{paused.message}</p>
+ </Alert.Description>
+ </Alert>
+ ) : null}
+ <Alert variant="info" icon={Info}>
+ <Alert.Description>
+ Only traces from v4-ready ingestion are processed automatically.
+ Legacy ingestion is not included.
+ </Alert.Description>
+ </Alert>
+ <section className="flex flex-col gap-2">
+ <h3 className="text-sm font-bold">Models</h3>
+ <dl className="grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-sm">
+ {TOPICS_MODEL_SLOTS.map((slot) => (
+ <ModelRow
+ key={slot}
+ label={TOPICS_MODEL_SLOT_DETAILS[slot].label}
+ model={models[slot]}
+ />
+ ))}
+ </dl>
+ <p className="text-muted-foreground text-xs">
+ {modelsHint(paused !== null, missingModel)}
+ </p>
+ </section>
+ <RuleSamplingSection
+ store={samplingStore}
+ description="The share of new traces Topics summarizes automatically."
+ tooltip="Topics summarizes this share of new traces. A lower rate costs less. For manual processing, you set the sampling for each run."
+ />
+ <SwitchInput
+ id="topics-automatic-processing"
+ aria-label="Automatic processing"
+ description={`Summarize new traces automatically. ${COST_NOTE}`}
+ checked={enabled}
+ onCheckedChange={setEnabled}
+ />
+ {error ? <p className="text-destructive text-sm">{error}</p> : null}
+ </div>
+ </Dialog.Body>
+ </Dialog>
+ );
+}
+
+function ModelRow({ label, model }: { label: string; model: string | null }) {
+ return (
+ <>
+ <dt className="text-muted-foreground">{label}</dt>
+ {model ? (
+ <dd className="truncate" title={model}>
+ {model}
+ </dd>
+ ) : (
+ <dd className="text-destructive">Not set</dd>
+ )}
+ </>
+ );
+}
+
+function modelsHint(paused: boolean, missingModel: boolean) {
+ if (missingModel)
+ return "Choose every model in Configure Topics before turning this on.";
+ return paused
+ ? "Turning this back on tests each model with one call."
+ : "Change models in Configure Topics.";
+}
+
+function idleTimeLabel(traceIdleMs: number) {
+ const seconds = Math.round(traceIdleMs / 1000);
+ if (seconds % 60 !== 0) return `${seconds} seconds`;
+ const minutes = seconds / 60;
+ return minutes === 1 ? "1 minute" : `${minutes} minutes`;
+}
diff --git a/web/src/features/topics/ConfigureTopicsDialog.stories.tsx b/web/src/features/topics/ConfigureTopicsDialog.stories.tsx
index 4fe1701ac2..77dd11c400 100644
--- a/web/src/features/topics/ConfigureTopicsDialog.stories.tsx
+++ b/web/src/features/topics/ConfigureTopicsDialog.stories.tsx
@@ -39,9 +39,9 @@ const emptyDraft = {
clustering: null,
facets: builtInFacets,
filters: [],
- sampling: 1,
idleSeconds: "600",
embeddingLocked: false,
+ automaticProcessing: false,
} satisfies ConfigureTopicsDraft;
const filledDraft = {
@@ -63,8 +63,8 @@ const filledDraft = {
filters: [
{ column: "name", type: "string", operator: "=", value: "billing" },
],
- sampling: 0.4,
embeddingLocked: true,
+ automaticProcessing: true,
} satisfies ConfigureTopicsDraft;
const meta = preview.meta({
@@ -96,7 +96,7 @@ export const Configured = meta.story({
});
export const SavesTheSheet = meta.story({
- name: "(Test) Save sends facets, filter, idle time, and sampling",
+ name: "(Test) Save sends facets, filter, and idle time",
args: {
draft: filledDraft,
defaultOpen: true,
@@ -116,7 +116,6 @@ export const SavesTheSheet = meta.story({
await expect(args.onSave).toHaveBeenCalledWith(
expect.objectContaining({
idleSeconds: "90",
- sampling: 0.4,
filters: filledDraft.filters,
facets: expect.arrayContaining([
expect.objectContaining({ name: "Intent", enabled: true }),
@@ -129,13 +128,54 @@ export const SavesTheSheet = meta.story({
export const Paused = meta.story({
args: {
- draft: filledDraft,
+ draft: { ...filledDraft, automaticProcessing: false },
defaultOpen: true,
notice: "paused",
shortLabel: "LLM connection missing",
pausedAgo: "3 days ago",
message:
- "No LLM connection found for the provider used by facet summaries. Add or restore the LLM connection, then reactivate Topics.",
+ 'The LLM connection "Amazon Bedrock" was deleted. Choose another connection in Configure Topics, then turn automatic processing back on.',
triggerVariant: "primary",
},
});
+
+export const SavesTurnedOffWithoutModelTests = meta.story({
+ name: "(Test) Save with automatic processing off ignores failing unchanged models",
+ args: {
+ draft: { ...filledDraft, automaticProcessing: false },
+ defaultOpen: true,
+ notice: "none",
+ triggerVariant: "secondary",
+ slotChecks: {
+ summary: { status: "ok" },
+ embedding: { status: "ok" },
+ clustering: { status: "error", message: "Invalid API key." },
+ },
+ },
+ play: async ({ args }) => {
+ const body = within(document.body);
+ const save = body.getByRole("button", { name: "Save" });
+ await expect(save).toBeEnabled();
+ await userEvent.click(save);
+ await expect(args.onSave).toHaveBeenCalledOnce();
+ },
+});
+
+export const BlocksSaveWhileRunningWithFailingModel = meta.story({
+ name: "(Test) Save with automatic processing on needs every model to pass",
+ args: {
+ draft: filledDraft,
+ defaultOpen: true,
+ notice: "none",
+ triggerVariant: "secondary",
+ slotChecks: {
+ summary: { status: "ok" },
+ embedding: { status: "ok" },
+ clustering: { status: "error", message: "Invalid API key." },
+ },
+ },
+ play: async () => {
+ const body = within(document.body);
+ await expect(body.getByRole("button", { name: "Save" })).toBeDisabled();
+ },
+});
diff --git a/web/src/features/topics/ConfigureTopicsDialog.tsx b/web/src/features/topics/ConfigureTopicsDialog.tsx
index f2ab90b324..d36262aec7 100644
--- a/web/src/features/topics/ConfigureTopicsDialog.tsx
+++ b/web/src/features/topics/ConfigureTopicsDialog.tsx
@@ -1,23 +1,13 @@
-import { useMemo, useState } from "react";
-import {
- AlertTriangle,
- ExternalLinkIcon,
- Info,
- RefreshCcw,
-} from "lucide-react";
-import { Alert } from "@/src/components/design-system/Alert/Alert";
+import { useId, useMemo, useState } from "react";
+import * as DialogPrimitive from "@radix-ui/react-dialog";
+import { AlertTriangle, ExternalLinkIcon } from "lucide-react";
import { Button } from "@/src/components/design-system/Button/Button";
+import { Dialog } from "@/src/components/design-system/Dialog/Dialog";
+import DocPopup from "@/src/components/layouts/doc-popup";
import { Input } from "@/src/components/design-system/Input/Input";
import { Switch } from "@/src/components/design-system/Switch/Switch";
import { Button as LegacyButton } from "@/src/components/ui/button";
import { PopoverTrigger } from "@/src/components/ui/popover";
-import {
- Sheet,
- SheetContent,
- SheetDescription,
- SheetHeader,
- SheetTitle,
-} from "@/src/components/ui/sheet";
import {
Tooltip,
TooltipContent,
@@ -34,9 +24,6 @@ import {
import { SectionHeader } from "@/src/features/evals/v2/components/Evaluators/Testing/components/SectionHeader/SectionHeader";
import { Tabs } from "@/src/components/design-system/Tabs/Tabs";
import { Badge } from "@/src/components/design-system/Badge/Badge";
-import { RuleSamplingSection } from "@/src/features/evals/v2/components/Rules/RuleSetup/components/RuleSamplingSection";
-import { createRuleSetupStore } from "@/src/features/evals/v2/stores/createRuleSetupStore";
-import type { RuleSetupStore } from "@/src/features/evals/v2/types/rules";
import { Stepper } from "@/src/features/evals/v2/components/Stepper/Stepper";
import type { EvaluatorFilterExperience } from "@/src/features/evals/v2/types/evaluatorFilterExperience";
import {
@@ -80,7 +67,6 @@ export type ConfigureTopicsSaveDraft = {
clustering: JudgeModel | null;
facets: FacetDraft[];
filters: FilterState;
- sampling: number;
idleSeconds: string;
};
@@ -91,9 +77,13 @@ export type ConfigureTopicsDraft = {
clustering: JudgeModel | null;
facets: FacetDraft[];
filters: FilterState;
- sampling: number;
idleSeconds: string;
embeddingLocked: boolean;
+ /**
+ * Automatic processing of new traces is on, so Save tests every model.
+ * Otherwise Save tests only the models that changed.
+ */
+ automaticProcessing: boolean;
};
type ConfigureTopicsDialogProps = {
@@ -101,6 +91,9 @@ type ConfigureTopicsDialogProps = {
embeddingProviderGroups?: Array<[string, string[]]>;
draft: ConfigureTopicsDraft;
defaultOpen: boolean;
+ /** Controls the dialog from outside, e.g. an empty state that opens it. */
+ open?: boolean;
+ onOpenChange?: (open: boolean) => void;
onConfigureProviders: () => void;
onSave: (draft: ConfigureTopicsSaveDraft) => void | Promise<void>;
onSlotCommit?: (
@@ -131,15 +124,19 @@ type ConfigureTopicsDialogProps = {
const SLOT_COPY = {
summary: {
label: "Facet summaries",
- hint: "A small, fast model. It runs once per trace.",
+ recommendation:
+ "Choose a strong but cost-efficient model, such as GPT-6 Luna or Claude Haiku 5.5. It runs once per trace.",
},
embedding: {
label: "Embeddings",
- hint: "Locked after the first summaries are embedded.",
+ lockedHint: "Locked after the first summaries are embedded.",
+ recommendation:
+ "Choose an embedding model your connection offers, such as text-embedding-3-small.",
},
clustering: {
label: "Topic clustering",
- hint: "Names each topic when topics are updated.",
+ recommendation:
+ "Choose a slightly stronger model, such as GPT-5.6 Terra, GPT-6.1 Sol, or Claude Sonnet. It runs when topics are updated, manually or once or twice a day.",
},
} as const;
@@ -168,7 +165,10 @@ export function ConfigureTopicsDialog(props: ConfigureTopicsDialogProps) {
message: props.message,
}
: null;
- const [open, setOpen] = useState(defaultOpen);
+ const [localOpen, setLocalOpen] = useState(defaultOpen);
+ const open = props.open ?? localOpen;
+ const setOpen = props.onOpenChange ?? setLocalOpen;
+ const formId = useId();
const [summary, setSummary] = useState(draft.summary);
const [embedding, setEmbedding] = useState(draft.embedding);
const [dimensions, setDimensions] = useState(draft.embeddingDimensions);
@@ -177,14 +177,6 @@ export function ConfigureTopicsDialog(props: ConfigureTopicsDialogProps) {
const [browsing, setBrowsing] = useState(facets[0]?.id ?? ADD_FACET_TAB);
const [idleSeconds, setIdleSeconds] = useState(draft.idleSeconds);
const [filters, setFilters] = useState(draft.filters);
- const [samplingStore] = useState(() =>
- createRuleSetupStore({
- name: "",
- filter: [],
- sampling: draft.sampling,
- assignments: [],
- }),
- );
const modelsReady = Boolean(summary && embedding && clustering);
const enabledFacets = facets.filter((facet) => facet.enabled);
const testsReady =
@@ -192,12 +184,22 @@ export function ConfigureTopicsDialog(props: ConfigureTopicsDialogProps) {
(["summary", "embedding", "clustering"] as const).every(
(slot) => slotChecks[slot]?.status === "ok",
);
+ const modelsPass = modelsReady && testsReady;
+ const selected = { summary, embedding, clustering };
+ // With automatic processing off the server tests only changed slots.
+ const changedSlotsPass = (["summary", "embedding", "clustering"] as const)
+ .filter(
+ (slot) =>
+ selected[slot] &&
+ (!sameModel(selected[slot], draft[slot]) ||
+ (slot === "embedding" && dimensions !== draft.embeddingDimensions)),
+ )
+ .every((slot) => !slotChecks || slotChecks[slot]?.status === "ok");
const canSave =
canWrite &&
!saving &&
- modelsReady &&
enabledFacets.length > 0 &&
- testsReady;
+ (draft.automaticProcessing ? modelsPass : changedSlotsPass);
const browsed = facets.find((facet) => facet.id === browsing) ?? null;
const atFacetCap = enabledFacets.length >= MAX_ENABLED_FACETS;
const commitSlot = (
@@ -232,18 +234,22 @@ export function ConfigureTopicsDialog(props: ConfigureTopicsDialogProps) {
size="sm"
onClick={() => setOpen(true)}
/>
- <Sheet open={open} onOpenChange={setOpen}>
- <SheetContent
- overlayClassName="bg-transparent"
- className="flex flex-col gap-0 overflow-hidden p-0 sm:max-w-4xl"
+ <DialogPrimitive.Root open={open} onOpenChange={setOpen}>
+ <Dialog
+ title="Configure Topics"
+ size="lg"
+ actions={[
+ {
+ label: "Save",
+ type: "submit",
+ form: formId,
+ loading: saving,
+ disabled: !canSave,
+ },
+ ]}
>
- <SheetHeader className="items-start space-y-1 p-6 pb-4 text-left">
- <SheetTitle>Configure Topics</SheetTitle>
- <SheetDescription>
- Models, what to look for, and which traces to run.
- </SheetDescription>
- </SheetHeader>
<form
+ id={formId}
className="flex min-h-0 flex-1 flex-col"
onSubmit={(event) => {
event.preventDefault();
@@ -255,7 +261,6 @@ export function ConfigureTopicsDialog(props: ConfigureTopicsDialogProps) {
clustering,
facets,
filters,
- sampling: samplingStore.getState().sampling,
idleSeconds,
}),
)
@@ -263,16 +268,12 @@ export function ConfigureTopicsDialog(props: ConfigureTopicsDialogProps) {
.catch(() => undefined);
}}
>
- <div className="flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-6 pb-4">
- <Alert variant="info" icon={Info}>
- <Alert.Description>
- Incoming traces are processed automatically only when
- ingestion is v4-ready. Legacy ingestion is not included.
- </Alert.Description>
- </Alert>
+ <div className="flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-4 pb-4">
+ <p className="text-muted-foreground text-sm">
+ Models, what to look for, and which traces to run.
+ </p>
{paused ? (
<PausedNotice
- canReactivate={canSave}
shortLabel={paused.shortLabel}
pausedAgo={paused.pausedAgo}
message={paused.message}
@@ -333,8 +334,13 @@ export function ConfigureTopicsDialog(props: ConfigureTopicsDialogProps) {
</Stepper>
<Stepper
number={2}
- title="Insights"
- description="Choose which questions you want answered. Five can be on."
+ title="Facets"
+ description={
+ <>
+ Choose which questions you want answered. Five can be on.
+ <DocPopup description="A facet is one question Topics answers for every trace, such as what the user asked for, how the run ended, or which issues came up. Answers to the same facet are clustered into topics." />
+ </>
+ }
compactBottomSpacing
>
<FacetPicker
@@ -374,31 +380,16 @@ export function ConfigureTopicsDialog(props: ConfigureTopicsDialogProps) {
projectId={projectId}
filters={filters}
onFiltersChange={setFilters}
- samplingStore={samplingStore}
/>
) : null}
</Stepper>
</div>
{saveError ? (
- <p className="text-destructive px-6 pb-2 text-sm">{saveError}</p>
+ <p className="text-destructive px-4 pb-2 text-sm">{saveError}</p>
) : null}
- <div className="mt-auto flex items-center justify-end gap-2 border-t p-4">
- <div className="flex gap-2">
- <LegacyButton
- type="button"
- variant="outline"
- onClick={() => setOpen(false)}
- >
- Cancel
- </LegacyButton>
- <LegacyButton type="submit" disabled={!canSave}>
- {saving ? "Saving…" : "Save"}
- </LegacyButton>
- </div>
- </div>
</form>
- </SheetContent>
- </Sheet>
+ </Dialog>
+ </DialogPrimitive.Root>
</div>
);
}
@@ -474,34 +465,44 @@ function ModelSlot({
const fields = (
<div className="flex min-w-0 flex-1 items-center gap-2">{controls}</div>
);
+
return (
<div className="flex items-start gap-2">
- <p
- className="flex h-8 w-36 shrink-0 items-center text-sm font-bold"
- title={copy.hint}
- >
+ <p className="flex h-8 w-36 shrink-0 items-center text-sm font-bold">
{copy.label}
</p>
<div className="flex min-w-0 flex-1 flex-col gap-1">
{locked ? (
<Tooltip>
<TooltipTrigger asChild>{fields}</TooltipTrigger>
- <TooltipContent side="bottom">{copy.hint}</TooltipContent>
+ <TooltipContent side="bottom">
+ {"lockedHint" in copy ? copy.lockedHint : null}
+ </TooltipContent>
</Tooltip>
) : (
fields
)}
- {check?.status === "testing" ? (
- <p className="text-muted-foreground text-sm">Testing this model…</p>
- ) : null}
- {check?.status === "error" && check.message ? (
- <p className="text-destructive text-sm">{check.message}</p>
- ) : null}
+ <SlotStatus check={check} recommendation={copy.recommendation} />
</div>
</div>
);
}
+// A test status replaces the recommendation, so the field keeps one line below it.
+function SlotStatus({
+ check,
+ recommendation,
+}: {
+ check?: TopicSlotCheck;
+ recommendation: string;
+}) {
+ if (check?.status === "testing")
+ return <p className="text-muted-foreground text-xs">Testing this model…</p>;
+ if (check?.status === "error" && check.message)
+ return <p className="text-destructive text-xs">{check.message}</p>;
+ return <p className="text-muted-foreground text-xs">{recommendation}</p>;
+}
+
function FacetPicker({
atCap,
browsed,
@@ -522,7 +523,7 @@ function FacetPicker({
const enabledCount = facets.filter((facet) => facet.enabled).length;
return (
<div className="flex flex-col gap-3">
- <div className="max-w-full overflow-x-auto">
+ <div className="-m-1 max-w-full overflow-x-auto p-1">
<Tabs value={browsing} onValueChange={onBrowse}>
<Tabs.List
aria-label="Facets"
@@ -546,7 +547,9 @@ function FacetPicker({
</div>
{browsed ? (
<div className="flex flex-col gap-2">
- <p className="text-sm">{browsed.question}</p>
+ <div className="bg-muted/50 max-h-48 overflow-y-auto rounded-md border px-3 py-2 text-sm leading-5 break-words whitespace-pre-wrap">
+ {browsed.question}
+ </div>
<label className="flex items-center gap-2 text-sm">
<Switch
checked={browsed.enabled}
@@ -572,9 +575,10 @@ function FacetPicker({
)}
</div>
) : (
- <p className="text-muted-foreground text-sm">
- Custom questions are added on their own page. This setup uses the
- facets already in the project.
+ <p className="text-muted-foreground flex flex-wrap items-center gap-2 text-sm">
+ <Badge text="Coming soon" color="blue" size="sm" />
+ Custom facets with your own questions. This setup uses the built-in
+ facets for now.
</p>
)}
</div>
@@ -655,27 +659,20 @@ function RuleScope({
projectId,
filters,
onFiltersChange,
- samplingStore,
}: {
projectId?: string;
filters: FilterState;
onFiltersChange: (filters: FilterState) => void;
- samplingStore: RuleSetupStore;
}) {
if (!projectId)
return (
- <SampleTraceScope
- filters={filters}
- onFiltersChange={onFiltersChange}
- samplingStore={samplingStore}
- />
+ <SampleTraceScope filters={filters} onFiltersChange={onFiltersChange} />
);
return (
<ProjectTraceScope
projectId={projectId}
filters={filters}
onFiltersChange={onFiltersChange}
- samplingStore={samplingStore}
/>
);
}
@@ -683,18 +680,15 @@ function RuleScope({
function SampleTraceScope({
filters,
onFiltersChange,
- samplingStore,
}: {
filters: FilterState;
onFiltersChange: (filters: FilterState) => void;
- samplingStore: RuleSetupStore;
}) {
return (
<TraceScopeFrame
projectId={undefined}
filters={filters}
onFiltersChange={onFiltersChange}
- samplingStore={samplingStore}
countLabel="Sample"
rows={SAMPLE_TRACES_IN_SCOPE}
/>
@@ -705,12 +699,10 @@ function ProjectTraceScope({
projectId,
filters,
onFiltersChange,
- samplingStore,
}: {
projectId: string;
filters: FilterState;
onFiltersChange: (filters: FilterState) => void;
- samplingStore: RuleSetupStore;
}) {
const [range] = useState(() => relativeTopicTimeRange(7));
const [mode, setMode] = useState<EvaluatorFilterExperience>("query");
@@ -842,7 +834,6 @@ function ProjectTraceScope({
searchType={searchType}
onModeChange={setMode}
onFiltersChange={onFiltersChange}
- samplingStore={samplingStore}
onSearchQueryChange={setSearchQuery}
onSearchTypeChange={setSearchType}
/>
@@ -864,7 +855,6 @@ function TraceScopeFrame({
tooltip,
rows,
status,
- samplingStore,
onModeChange,
onFiltersChange,
onSearchQueryChange,
@@ -890,7 +880,6 @@ function TraceScopeFrame({
input: string;
}>;
status?: string | null;
- samplingStore: RuleSetupStore;
onModeChange?: (mode: EvaluatorFilterExperience) => void;
onFiltersChange?: (filters: FilterState) => void;
onSearchQueryChange?: (query: string | null) => void;
@@ -1028,23 +1017,16 @@ function TraceScopeFrame({
</table>
</div>
</section>
- <RuleSamplingSection
- store={samplingStore}
- description="Set the percentage of matching traces Topics processes."
- tooltip="Topics processes this share of the traces that match the filter. A lower rate processes fewer traces."
- />
</div>
);
}
function PausedNotice({
- canReactivate,
message,
onConfigureProviders,
pausedAgo,
shortLabel,
}: {
- canReactivate: boolean;
message: string;
onConfigureProviders: () => void;
pausedAgo: string;
@@ -1065,6 +1047,10 @@ function PausedNotice({
<span>Paused {pausedAgo}</span>
</div>
<p className="text-muted-foreground mt-2 text-sm">{message}</p>
+ <p className="text-muted-foreground mt-1 text-sm">
+ Saving here keeps automatic processing paused. Turn it back on from
+ the Topics page once the models work.
+ </p>
<div className="mt-3 flex flex-wrap items-center gap-2">
<LegacyButton
type="button"
@@ -1075,19 +1061,13 @@ function PausedNotice({
<ExternalLinkIcon className="icon-base text-icon-foreground mr-1.5" />
Open LLM connections
</LegacyButton>
- {/* Saving re-runs the model tests and clears the pause. */}
- <LegacyButton
- type="submit"
- variant="outline"
- size="sm"
- disabled={!canReactivate}
- >
- <RefreshCcw className="icon-base text-icon-foreground mr-1.5" />
- Reactivate
- </LegacyButton>
</div>
</div>
</div>
</section>
);
}
+
+function sameModel(a: JudgeModel | null, b: JudgeModel | null) {
+ return a?.provider === b?.provider && a?.model === b?.model;
+}
diff --git a/web/src/features/topics/TopicModelSettings.tsx b/web/src/features/topics/TopicModelSettings.tsx
index 67d1b9043d..37bb01bb40 100644
--- a/web/src/features/topics/TopicModelSettings.tsx
+++ b/web/src/features/topics/TopicModelSettings.tsx
@@ -1,6 +1,8 @@
import { useRef, useState } from "react";
import { formatDistanceToNow } from "date-fns";
import { Alert } from "@/src/components/design-system/Alert/Alert";
+import { Button } from "@/src/components/design-system/Button/Button";
+import { SplashScreen } from "@/src/components/ui/splash-screen";
import { env } from "@/src/env.mjs";
import { type JudgeModel } from "@/src/features/evals/v2/judgeModel";
import { api, type RouterOutputs } from "@/src/utils/api";
@@ -22,12 +24,13 @@ import {
type TopicSlotCheck,
} from "./ConfigureTopicsDialog";
import { topicsSetupPayload } from "./topics-setup";
+import { useAutomaticProcessing } from "./useAutomaticProcessing";
type StoredSettings = RouterOutputs["topics"]["modelSettings"];
type Connection = RouterOutputs["llmApiKey"]["all"]["data"][number];
type SlotValue = { llmApiKeyId: string; model: string } | null;
-/** Topics setup: one sheet for models, facets, and which traces to include. */
+/** Topics setup: one dialog for models, facets, and which traces to include. */
export function useTopicModelSettings({
projectId,
canWrite,
@@ -50,7 +53,32 @@ export function useTopicModelSettings({
settings.data.embedding &&
settings.data.clustering,
);
+ const rule = rules.data?.length === 1 ? rules.data[0] : null;
+ const dataKey = `${settings.dataUpdatedAt}-${rules.dataUpdatedAt}-${readinessSettings.dataUpdatedAt}`;
+ // Pins the key while Configure is open so a refetch cannot reset unsaved edits.
+ const [openKey, setOpenKey] = useState<string | null>(null);
+ const setConfigureOpen = (open: boolean) => setOpenKey(open ? dataKey : null);
+ const automaticProcessing = useAutomaticProcessing({
+ canWrite,
+ projectId,
+ rule,
+ stored: settings.data,
+ traceIdleMs: readinessSettings.data?.traceIdleMs ?? null,
+ });
+ const unavailable = settings.data && !settings.data.processingAvailable && (
+ <Alert variant="info">
+ <Alert.Title>
+ Topics processing is not enabled for this project
+ </Alert.Title>
+ <Alert.Description>
+ <p>
+ You can configure Topics, but processing traces and automatic
+ processing stay unavailable until Topics is enabled for this project.
+ </p>
+ </Alert.Description>
+ </Alert>
+ );
let notice = null;
if (settings.data?.blockMessage)
notice = (
@@ -58,9 +86,61 @@ export function useTopicModelSettings({
<Alert.Title>Automatic Topics processing is paused</Alert.Title>
<Alert.Description>
<p className="break-words">{settings.data.blockMessage}</p>
+ <div className="mt-2 flex flex-wrap gap-2">
+ <Button
+ text="Turn back on"
+ variant="secondary"
+ size="sm"
+ disabled={!canWrite}
+ onClick={automaticProcessing.openEnable}
+ />
+ <Button
+ text="Keep off"
+ variant="secondary"
+ size="sm"
+ disabled={!canWrite}
+ onClick={automaticProcessing.clearPause}
+ />
+ </div>
</Alert.Description>
</Alert>
);
+ else if (settings.data && !configured && facetsReady && !facets.length)
+ notice = (
+ <div className="mx-auto w-full max-w-xl pt-12">
+ <SplashScreen
+ title="Find patterns across your traces"
+ description="Topics analyzes each trace along the questions you choose, called facets, and clusters similar answers, so you can see what users ask for, how runs end, and which issues come up along the way."
+ steps={[
+ {
+ title: "Set up Topics",
+ description:
+ "Pick the models Topics runs on and the facets to analyze, such as intent, outcome, and issues.",
+ },
+ {
+ title: "Analyze traces",
+ description:
+ "Topics summarizes new traces automatically, and past traces whenever you process them.",
+ },
+ {
+ title: "Gather insights",
+ description:
+ "Similar summaries are clustered into topics, on demand or continuously, so patterns across your traces show up here.",
+ },
+ ]}
+ primaryAction={{
+ label: "Configure Topics",
+ component: (
+ <Button
+ text="Configure Topics"
+ disabled={!canWrite}
+ onClick={() => setConfigureOpen(true)}
+ />
+ ),
+ }}
+ />
+ </div>
+ );
else if (settings.data && !configured)
notice = (
<Alert variant="info">
@@ -82,10 +162,9 @@ export function useTopicModelSettings({
rules.isSuccess &&
facetsReady,
);
- const rule = rules.data?.length === 1 ? rules.data[0] : null;
const action = ready ? (
<ConfigureTopicsSettings
- key={`${settings.dataUpdatedAt}-${rules.dataUpdatedAt}-${readinessSettings.dataUpdatedAt}`}
+ key={openKey ?? dataKey}
projectId={projectId}
canWrite={canWrite}
stored={settings.data!}
@@ -93,6 +172,8 @@ export function useTopicModelSettings({
connections={connections.data!.data}
facets={facets}
rule={rule}
+ open={openKey !== null}
+ onOpenChange={setConfigureOpen}
/>
) : (
<ConfigureTopicsDialog
@@ -105,9 +186,9 @@ export function useTopicModelSettings({
clustering: null,
facets: [],
filters: [],
- sampling: 1,
idleSeconds: "600",
embeddingLocked: false,
+ automaticProcessing: false,
}}
defaultOpen={false}
onConfigureProviders={() => undefined}
@@ -118,7 +199,16 @@ export function useTopicModelSettings({
/>
);
- return { action, notice };
+ return {
+ action,
+ notice: (
+ <>
+ {unavailable}
+ {notice}
+ </>
+ ),
+ automaticProcessing: automaticProcessing.control,
+ };
}
function ConfigureTopicsSettings({
@@ -129,6 +219,8 @@ function ConfigureTopicsSettings({
connections,
facets,
rule,
+ open,
+ onOpenChange,
}: {
projectId: string;
canWrite: boolean;
@@ -137,6 +229,8 @@ function ConfigureTopicsSettings({
connections: Connection[];
facets: TopicFacet[];
rule: TopicRule | null;
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
}) {
const utils = api.useUtils();
const requests = useRef({ summary: 0, embedding: 0, clustering: 0 });
@@ -178,9 +272,9 @@ function ConfigureTopicsSettings({
clustering: judgeModel(stored.clustering, connections),
facets: facetDrafts(facets, rule ? new Set(rule.facetIds) : null),
filters: [],
- sampling: rule?.sampling ?? 1,
idleSeconds: String((traceIdleMs ?? 600_000) / 1000),
embeddingLocked: false,
+ automaticProcessing: stored.enabled ?? false,
};
const paused = stored.blockMessage
? {
@@ -247,7 +341,6 @@ function ConfigureTopicsSettings({
? parsedDimensions.data
: stored.embeddingDimensions,
clustering: slot === "clustering" ? value : null,
- enabled: false,
})
.then((errors) => {
if (requests.current[slot] !== request) return;
@@ -300,7 +393,7 @@ function ConfigureTopicsSettings({
stored.clustering?.llmApiKeyId,
"chat",
);
- if (!summary || !embedding || !clustering)
+ if (stored.enabled && (!summary || !embedding || !clustering))
throw new Error("Choose a model from a connection in this project.");
try {
await save.mutateAsync({
@@ -328,6 +421,8 @@ function ConfigureTopicsSettings({
embeddingProviderGroups={embeddingGroups}
draft={draft}
defaultOpen={false}
+ open={open}
+ onOpenChange={onOpenChange}
canWrite={canWrite}
saving={save.isPending}
saveError={saveError}
diff --git a/web/src/features/topics/TopicsPage.clienttest.tsx b/web/src/features/topics/TopicsPage.clienttest.tsx
index 4f2f8c20d5..d4486cd42d 100644
--- a/web/src/features/topics/TopicsPage.clienttest.tsx
+++ b/web/src/features/topics/TopicsPage.clienttest.tsx
@@ -99,7 +99,6 @@ vi.mock("@/src/utils/api", () => ({
topics: {
facets: { useQuery: () => ({ data: [], isLoading: false }) },
executions: { useQuery: () => ({ data: [] }) },
- initialize: { useMutation: () => ({}) },
execution: {
useQuery: () => ({
data: {
diff --git a/web/src/features/topics/TopicsPage.tsx b/web/src/features/topics/TopicsPage.tsx
index 6540f27a22..7647c840e6 100644
--- a/web/src/features/topics/TopicsPage.tsx
+++ b/web/src/features/topics/TopicsPage.tsx
@@ -153,9 +153,6 @@ function TopicsWorkspaceView({
: false,
},
);
- const initialize = api.topics.initialize.useMutation({
- onSuccess: () => utils.topics.facets.invalidate({ projectId }),
- });
const executionId =
typeof router.query.executionId === "string"
? router.query.executionId
@@ -264,6 +261,7 @@ function TopicsWorkspaceView({
});
const actions = (
<div className="ph-no-capture flex items-center justify-end gap-1">
+ {modelSettings.automaticProcessing}
{modelSettings.action}
{primaryAction}
<DropdownMenu
@@ -434,23 +432,6 @@ function TopicsWorkspaceView({
)}
{facets.isLoading && <p>Loading facets…</p>}
{facets.error && <ErrorMessage message={facets.error.message} />}
- {facets.data?.length === 0 && (
- <section className="flex flex-col items-start gap-3">
- <h2 className="font-bold">Start with a question</h2>
- <p className="text-muted-foreground text-sm">
- Create built-in facets for intent, outcome, and issues, then add
- custom facets for your own questions.
- </p>
- <Button
- text="Create starter facets"
- disabled={!canWrite || initialize.isPending}
- onClick={() => initialize.mutate({ projectId })}
- />
- {initialize.error && (
- <ErrorMessage message={initialize.error.message} />
- )}
- </section>
- )}
</div>
</div>
</Page>
diff --git a/web/src/features/topics/server/topicsRouter.ts b/web/src/features/topics/server/topicsRouter.ts
index bb632c1844..072d0f9aff 100644
--- a/web/src/features/topics/server/topicsRouter.ts
+++ b/web/src/features/topics/server/topicsRouter.ts
@@ -13,6 +13,7 @@ import {
topicTraceIdSchema,
topicRuleConfigSchema,
topicTimeRangeSchema,
+ topicsAutomaticProcessingSchema,
topicsModelSettingsSchema,
topicsSetupSchema,
type TopicTimeRange,
@@ -27,7 +28,6 @@ import {
getTopicSummaryCounts,
listTopicExecutions,
listTopicFacets,
- ensureDefaultTopicFacets,
getTopicFacetVersion,
getLatestFacetSummaries,
createTopicFacet,
@@ -45,6 +45,7 @@ import {
readTopicsModelSettings,
checkTopicsModelSettings,
saveTopicsSetup,
+ setTopicsAutomaticProcessing,
enqueueTopicExecution,
getTopicExecutionQueueState,
} from "@langfuse/shared/topics/server";
@@ -326,9 +327,6 @@ export const topicsRouter = createTRPCRouter({
facets: topicsProcedure.query(({ input }) =>
listTopicFacets(input.projectId),
),
- initialize: topicsWriteProcedure.mutation(({ input }) =>
- ensureDefaultTopicFacets(input.projectId),
- ),
saveFacet: topicsWriteProcedure
.input(
projectInput.extend({
@@ -367,9 +365,10 @@ export const topicsRouter = createTRPCRouter({
});
return rule;
}),
- modelSettings: topicsProcedure.query(({ input }) =>
- readTopicsModelSettings(input.projectId),
- ),
+ modelSettings: topicsProcedure.query(async ({ input }) => ({
+ ...(await readTopicsModelSettings(input.projectId)),
+ processingAvailable: isTopicsProjectEnabled(input.projectId),
+ })),
tracingReadinessSettings: topicsProcedure.query(({ input }) =>
getTracingReadinessSettings(input.projectId),
),
@@ -393,6 +392,30 @@ export const topicsRouter = createTRPCRouter({
});
return rule;
}),
+ setAutomaticProcessing: topicsWriteProcedure
+ .input(topicsAutomaticProcessingSchema.extend({ projectId: topicIdSchema }))
+ .mutation(async ({ input: { projectId, ...input }, ctx }) => {
+ if (input.enabled && !isTopicsProjectEnabled(projectId))
+ throw new InvalidRequestError(
+ "Topics processing is not enabled for this project.",
+ );
+ const { ruleBefore, ruleAfter } = await auditedTopicConfigSave(
+ ctx,
+ projectId,
+ () =>
+ setTopicsAutomaticProcessing(projectId, input, ctx.session.user.id),
+ );
+ if (ruleBefore.sampling !== ruleAfter.sampling)
+ await auditLog({
+ session: ctx.session,
+ resourceType: JOB_CONFIGURATION_AUDIT_LOG_RESOURCE_TYPE,
+ resourceId: ruleAfter.id,
+ action: "update",
+ before: ruleBefore,
+ after: ruleAfter,
+ });
+ return { enabled: input.enabled, sampling: ruleAfter.sampling };
+ }),
summaryCounts: topicsProcedure
.input(
resultInput.extend({
diff --git a/web/src/features/topics/topics-setup.clienttest.ts b/web/src/features/topics/topics-setup.clienttest.ts
index ba655e5df8..959ed05198 100644
--- a/web/src/features/topics/topics-setup.clienttest.ts
+++ b/web/src/features/topics/topics-setup.clienttest.ts
@@ -16,7 +16,6 @@ const draft: ConfigureTopicsSaveDraft = {
embeddingDimensions: "1024",
clustering: null,
idleSeconds: "120",
- sampling: 0.25,
filters: [
{ column: "name", type: "string", operator: "=", value: "billing" },
],
@@ -39,11 +38,9 @@ const draft: ConfigureTopicsSaveDraft = {
};
describe("topicsSetupPayload", () => {
- it("keeps the filter, sampling, and built-in enabled state", () => {
+ it("keeps the filter and built-in enabled state", () => {
expect(topicsSetupPayload(draft, slots)).toMatchObject({
- enabled: true,
embeddingDimensions: 1024,
- sampling: 0.25,
traceIdleMs: 120_000,
filter: draft.filters,
facets: DEFAULT_TOPIC_FACETS.map((facet, index) => ({
@@ -53,6 +50,21 @@ describe("topicsSetupPayload", () => {
});
});
+ it("saves without models", () => {
+ expect(
+ topicsSetupPayload(draft, {
+ ...slots,
+ summary: null,
+ embedding: null,
+ clustering: null,
+ }),
+ ).toMatchObject({
+ summary: null,
+ embedding: null,
+ clustering: null,
+ });
+ });
+
it("rejects a setup with every built-in facet turned off", () => {
expect(() =>
topicsSetupPayload(
diff --git a/web/src/features/topics/topics-setup.ts b/web/src/features/topics/topics-setup.ts
index a564743be7..52fb6fb310 100644
--- a/web/src/features/topics/topics-setup.ts
+++ b/web/src/features/topics/topics-setup.ts
@@ -12,7 +12,6 @@ export function topicsSetupPayload(
): TopicsSetup {
const parsed = topicsSetupSchema.safeParse({
...slots,
- enabled: true,
facets: value.facets
.filter((facet) => facet.builtIn)
.map((facet) => ({ name: facet.name, enabled: facet.enabled })),
@@ -20,7 +19,6 @@ export function topicsSetupPayload(
.filter((facet) => !facet.builtIn && facet.enabled)
.map((facet) => facet.id),
filter: value.filters,
- sampling: value.sampling,
traceIdleMs: Number(value.idleSeconds) * 1000,
});
if (!parsed.success)
diff --git a/web/src/features/topics/useAutomaticProcessing.tsx b/web/src/features/topics/useAutomaticProcessing.tsx
new file mode 100644
index 0000000000..f7c21548e6
--- /dev/null
+++ b/web/src/features/topics/useAutomaticProcessing.tsx
@@ -0,0 +1,122 @@
+import { useState } from "react";
+import * as DialogPrimitive from "@radix-ui/react-dialog";
+import { getEvaluatorBlockMetadata } from "@langfuse/shared";
+import { type TopicRule } from "@langfuse/shared/topics";
+import { api, type RouterOutputs } from "@/src/utils/api";
+import {
+ AutomaticProcessingControl,
+ type AutomaticProcessingState,
+} from "./AutomaticProcessingControl";
+import { AutomaticProcessingDialog } from "./AutomaticProcessingDialog";
+
+type StoredSettings = RouterOutputs["topics"]["modelSettings"];
+
+/**
+ * The header control and dialog for automatic processing. `openEnable` lets
+ * the paused notice open the same dialog.
+ */
+export function useAutomaticProcessing({
+ canWrite,
+ projectId,
+ rule,
+ stored,
+ traceIdleMs,
+}: {
+ canWrite: boolean;
+ projectId: string;
+ rule: TopicRule | null;
+ stored: StoredSettings | undefined;
+ traceIdleMs: number | null;
+}) {
+ const utils = api.useUtils();
+ // The switch's starting position while the dialog is open.
+ const [dialog, setDialog] = useState<{ enabled: boolean } | null>(null);
+ const [error, setError] = useState<string | null>(null);
+ const mutation = api.topics.setAutomaticProcessing.useMutation({
+ onSuccess: () =>
+ Promise.all([
+ utils.topics.modelSettings.invalidate({ projectId }),
+ utils.topics.rules.invalidate({ projectId }),
+ ]),
+ });
+ const state = automaticProcessingState(stored, rule);
+ const paused =
+ stored?.blockMessage && state.status === "paused"
+ ? { shortLabel: state.shortLabel, message: stored.blockMessage }
+ : null;
+ const open = (enabled: boolean) => {
+ setError(null);
+ setDialog({ enabled });
+ };
+ const save = (input: { enabled: boolean; sampling: number }) => {
+ setError(null);
+ mutation
+ .mutateAsync({ projectId, ...input })
+ .then(() => setDialog(null))
+ .catch((cause: unknown) =>
+ setError(
+ cause instanceof Error
+ ? cause.message
+ : "Could not save automatic processing.",
+ ),
+ );
+ };
+
+ const control = (
+ <>
+ <AutomaticProcessingControl
+ state={state}
+ canWrite={canWrite && !mutation.isPending}
+ onOpen={() => open(state.status === "on")}
+ />
+ <DialogPrimitive.Root
+ open={dialog !== null}
+ onOpenChange={(next) => {
+ if (!next) setDialog(null);
+ }}
+ >
+ {dialog ? (
+ <AutomaticProcessingDialog
+ initialEnabled={dialog.enabled}
+ initialSampling={rule?.sampling ?? 1}
+ traceIdleMs={traceIdleMs ?? 600_000}
+ models={{
+ summary: stored?.summary?.model ?? null,
+ embedding: stored?.embedding?.model ?? null,
+ clustering: stored?.clustering?.model ?? null,
+ }}
+ paused={paused}
+ saving={mutation.isPending}
+ error={error}
+ onSave={save}
+ />
+ ) : null}
+ </DialogPrimitive.Root>
+ </>
+ );
+
+ return {
+ control,
+ openEnable: () => open(true),
+ clearPause: () => mutation.mutate({ projectId, enabled: false }),
+ };
+}
+
+function automaticProcessingState(
+ stored: StoredSettings | undefined,
+ rule: TopicRule | null,
+): AutomaticProcessingState {
+ if (!stored || stored.enabled === null || !rule)
+ return { status: "unconfigured" };
+ if (stored.blockMessage)
+ return {
+ status: "paused",
+ shortLabel: stored.blockReason
+ ? getEvaluatorBlockMetadata(stored.blockReason).shortLabel
+ : "Paused",
+ };
+ if (stored.enabled) return { status: "on" };
+ // Only turning on needs the allowlist, so a running setup can still be turned off.
+ if (!stored.processingAvailable) return { status: "unavailable" };
+ return { status: "off" };
+}
diff --git a/worker/src/features/topics/provider-error.ts b/worker/src/features/topics/provider-error.ts
index 9ea7e98989..17516d3f0e 100644
--- a/worker/src/features/topics/provider-error.ts
+++ b/worker/src/features/topics/provider-error.ts
@@ -88,7 +88,7 @@ export function isRejectedConnection(
function rejectedConnectionBlock(error: TopicsProviderUnavailable) {
return {
blockReason: EvaluatorBlockReason.LLM_CONNECTION_AUTH_INVALID,
- blockMessage: `${error.message} Topics was turned off; fix the connection and turn it on again.`,
+ blockMessage: `${error.message} Automatic processing was paused. Fix the connection, then turn automatic processing back on.`,
};
}
diff --git a/worker/src/features/topics/storage.integration.test.ts b/worker/src/features/topics/storage.integration.test.ts
index 6008c45a5e..d8f8df089e 100644
--- a/worker/src/features/topics/storage.integration.test.ts
+++ b/worker/src/features/topics/storage.integration.test.ts
@@ -137,10 +137,6 @@ describe("Topics eval-backed configuration", () => {
facetIds: [facets[0].id],
},
{
- enabled: true,
- blockedAt: null,
- blockReason: null,
- blockMessage: null,
// No such connection: the foreign key rejects the model write.
summaryLlmApiKeyId: "missing-connection",
summaryModel: "gpt-6-luna",
@@ -165,10 +161,6 @@ describe("Topics eval-backed configuration", () => {
it("records who created and last updated the Topics configuration", async () => {
const facets = await ensureDefaultTopicFacets(auditProjectId);
const models = {
- enabled: false,
- blockedAt: null,
- blockReason: null,
- blockMessage: null,
summaryLlmApiKeyId: null,
summaryModel: null,
embeddingLlmApiKeyId: null,