feat: filter meaningful conversations with local model

This commit is contained in:
Codex Local
2026-08-30 15:20:08 +08:00
parent 89f6641331
commit 522785eda8
18 changed files with 451 additions and 45 deletions
@@ -0,0 +1,28 @@
BEGIN;
CREATE TABLE conversation_content_assessment (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
public_id uuid NOT NULL UNIQUE DEFAULT gen_random_uuid(),
tenant_id uuid NOT NULL REFERENCES tenant(id),
subject_id uuid NOT NULL,
conversation_id uuid NOT NULL,
generation_version bigint NOT NULL CHECK (generation_version > 0),
meaningful boolean NOT NULL,
story_worthy boolean NOT NULL,
decision_reason varchar(500) NOT NULL CHECK (length(decision_reason) > 0),
model_ref varchar(160) NOT NULL,
prompt_version varchar(80) NOT NULL,
confidence numeric(5,4) NOT NULL CHECK (confidence BETWEEN 0 AND 1),
created_at timestamptz NOT NULL DEFAULT now(),
CONSTRAINT conversation_content_assessment_decision_check CHECK (meaningful OR NOT story_worthy),
CONSTRAINT conversation_content_assessment_conversation_tenant_fk FOREIGN KEY (conversation_id, tenant_id)
REFERENCES conversation (id, tenant_id),
CONSTRAINT conversation_content_assessment_subject_tenant_fk FOREIGN KEY (subject_id, tenant_id)
REFERENCES subject_profile (id, tenant_id),
CONSTRAINT conversation_content_assessment_generation_key UNIQUE (conversation_id, generation_version)
);
CREATE INDEX conversation_content_assessment_conversation_idx
ON conversation_content_assessment (conversation_id, generation_version DESC);
COMMIT;