Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("chunk_index", schema=None) as batch_op:
batch_op.alter_column(
"id", existing_type=sa.NUMERIC(), type_=sa.UUID(), existing_nullable=False
)
batch_op.alter_column("id", existing_type=sa.NUMERIC(), type_=sa.UUID(), existing_nullable=False)
batch_op.alter_column(
"content_source_id",
existing_type=sa.NUMERIC(),
Expand All @@ -48,9 +46,7 @@ def upgrade() -> None:
with op.batch_alter_table("content_sources", schema=None) as batch_op:
batch_op.add_column(sa.Column("status_message", sa.Text(), nullable=True))
batch_op.add_column(sa.Column("error_message", sa.Text(), nullable=True))
batch_op.alter_column(
"id", existing_type=sa.NUMERIC(), type_=sa.UUID(), existing_nullable=False
)
batch_op.alter_column("id", existing_type=sa.NUMERIC(), type_=sa.UUID(), existing_nullable=False)
batch_op.alter_column(
"subject_id",
existing_type=sa.NUMERIC(),
Expand All @@ -66,14 +62,10 @@ def upgrade() -> None:
existing_nullable=True,
)
batch_op.drop_index(batch_op.f("ix_diarizations_title"))
batch_op.create_index(
batch_op.f("ix_diarizations_name"), ["name"], unique=False
)
batch_op.create_index(batch_op.f("ix_diarizations_name"), ["name"], unique=False)

with op.batch_alter_table("ingestion_jobs", schema=None) as batch_op:
batch_op.alter_column(
"id", existing_type=sa.NUMERIC(), type_=sa.UUID(), existing_nullable=False
)
batch_op.alter_column("id", existing_type=sa.NUMERIC(), type_=sa.UUID(), existing_nullable=False)
batch_op.alter_column(
"content_source_id",
existing_type=sa.NUMERIC(),
Expand All @@ -88,9 +80,7 @@ def upgrade() -> None:
)

with op.batch_alter_table("knowledge_subjects", schema=None) as batch_op:
batch_op.alter_column(
"id", existing_type=sa.NUMERIC(), type_=sa.UUID(), existing_nullable=False
)
batch_op.alter_column("id", existing_type=sa.NUMERIC(), type_=sa.UUID(), existing_nullable=False)

# ### end Alembic commands ###

Expand All @@ -99,9 +89,7 @@ def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("knowledge_subjects", schema=None) as batch_op:
batch_op.alter_column(
"id", existing_type=sa.UUID(), type_=sa.NUMERIC(), existing_nullable=False
)
batch_op.alter_column("id", existing_type=sa.UUID(), type_=sa.NUMERIC(), existing_nullable=False)

with op.batch_alter_table("ingestion_jobs", schema=None) as batch_op:
batch_op.alter_column(
Expand All @@ -116,15 +104,11 @@ def downgrade() -> None:
type_=sa.NUMERIC(),
existing_nullable=True,
)
batch_op.alter_column(
"id", existing_type=sa.UUID(), type_=sa.NUMERIC(), existing_nullable=False
)
batch_op.alter_column("id", existing_type=sa.UUID(), type_=sa.NUMERIC(), existing_nullable=False)

with op.batch_alter_table("diarizations", schema=None) as batch_op:
batch_op.drop_index(batch_op.f("ix_diarizations_name"))
batch_op.create_index(
batch_op.f("ix_diarizations_title"), ["name"], unique=False
)
batch_op.create_index(batch_op.f("ix_diarizations_title"), ["name"], unique=False)
batch_op.alter_column(
"subject_id",
existing_type=sa.UUID(),
Expand All @@ -139,9 +123,7 @@ def downgrade() -> None:
type_=sa.NUMERIC(),
existing_nullable=True,
)
batch_op.alter_column(
"id", existing_type=sa.UUID(), type_=sa.NUMERIC(), existing_nullable=False
)
batch_op.alter_column("id", existing_type=sa.UUID(), type_=sa.NUMERIC(), existing_nullable=False)
batch_op.drop_column("error_message")
batch_op.drop_column("status_message")

Expand All @@ -164,8 +146,6 @@ def downgrade() -> None:
type_=sa.NUMERIC(),
existing_nullable=False,
)
batch_op.alter_column(
"id", existing_type=sa.UUID(), type_=sa.NUMERIC(), existing_nullable=False
)
batch_op.alter_column("id", existing_type=sa.UUID(), type_=sa.NUMERIC(), existing_nullable=False)

# ### end Alembic commands ###
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ def upgrade() -> None:
"""Upgrade schema."""
# Using batch mode for SQLite compatibility
with op.batch_alter_table("content_sources", schema=None) as batch_op:
batch_op.drop_constraint(
op.f("uq_content_source_external_source"), type_="unique"
)
batch_op.drop_constraint(op.f("uq_content_source_external_source"), type_="unique")
batch_op.create_unique_constraint(
"uq_content_source_external_source_per_subject",
["external_source", "subject_id"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@

def upgrade() -> None:
"""Upgrade schema."""
op.add_column(
"ingestion_jobs", sa.Column("external_source", sa.Text(), nullable=True)
)
op.add_column("ingestion_jobs", sa.Column("external_source", sa.Text(), nullable=True))


def downgrade() -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"content_sources", sa.Column("total_tokens", sa.Integer(), nullable=True)
)
op.add_column("content_sources", sa.Column("total_tokens", sa.Integer(), nullable=True))
op.add_column(
"content_sources",
sa.Column("max_tokens_per_chunk", sa.Integer(), nullable=True),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,13 @@ def upgrade() -> None:
columns_chunk = [c["name"] for c in insp.get_columns("chunk_index")]
if "vector_store_type" not in columns_chunk:
with op.batch_alter_table("chunk_index", schema=None) as batch_op:
batch_op.add_column(
sa.Column("vector_store_type", sa.Text(), nullable=True)
)
batch_op.add_column(sa.Column("vector_store_type", sa.Text(), nullable=True))

# ingestion_jobs
columns_jobs = [c["name"] for c in insp.get_columns("ingestion_jobs")]
if "vector_store_type" not in columns_jobs:
with op.batch_alter_table("ingestion_jobs", schema=None) as batch_op:
batch_op.add_column(
sa.Column("vector_store_type", sa.Text(), nullable=True)
)
batch_op.add_column(sa.Column("vector_store_type", sa.Text(), nullable=True))


def downgrade() -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,8 @@ def upgrade() -> None:
)
)
batch_op.create_index("ix_chunk_index_chunk_id", ["chunk_id"], unique=False)
batch_op.create_index(
"ix_chunk_index_content_source_id", ["content_source_id"], unique=False
)
batch_op.create_index(
op.f("ix_chunk_index_created_at"), ["created_at"], unique=False
)
batch_op.create_index("ix_chunk_index_content_source_id", ["content_source_id"], unique=False)
batch_op.create_index(op.f("ix_chunk_index_created_at"), ["created_at"], unique=False)
batch_op.create_index("ix_chunk_index_job_id", ["job_id"], unique=False)

with op.batch_alter_table("content_sources", schema=None) as batch_op:
Expand All @@ -50,24 +46,16 @@ def upgrade() -> None:
nullable=False,
)
)
batch_op.create_index(
op.f("ix_content_sources_created_at"), ["created_at"], unique=False
)
batch_op.create_index(op.f("ix_content_sources_created_at"), ["created_at"], unique=False)
batch_op.create_index(
op.f("ix_content_sources_processing_status"),
["processing_status"],
unique=False,
)
batch_op.create_index(
"ix_content_sources_source_type", ["source_type"], unique=False
)
batch_op.create_index("ix_content_sources_source_type", ["source_type"], unique=False)
batch_op.create_index("ix_content_sources_status", ["status"], unique=False)
batch_op.create_index(
"ix_content_sources_subject_id", ["subject_id"], unique=False
)
batch_op.create_unique_constraint(
"uq_content_source_external_source", ["external_source"]
)
batch_op.create_index("ix_content_sources_subject_id", ["subject_id"], unique=False)
batch_op.create_unique_constraint("uq_content_source_external_source", ["external_source"])

with op.batch_alter_table("ingestion_jobs", schema=None) as batch_op:
batch_op.add_column(
Expand All @@ -78,12 +66,8 @@ def upgrade() -> None:
nullable=False,
)
)
batch_op.create_index(
"ix_ingestion_jobs_content_source_id", ["content_source_id"], unique=False
)
batch_op.create_index(
op.f("ix_ingestion_jobs_started_at"), ["started_at"], unique=False
)
batch_op.create_index("ix_ingestion_jobs_content_source_id", ["content_source_id"], unique=False)
batch_op.create_index(op.f("ix_ingestion_jobs_started_at"), ["started_at"], unique=False)
batch_op.create_index("ix_ingestion_jobs_status", ["status"], unique=False)

with op.batch_alter_table("knowledge_subjects", schema=None) as batch_op:
Expand All @@ -105,9 +89,7 @@ def downgrade() -> None:
with op.batch_alter_table("ingestion_jobs", schema=None) as batch_op:
batch_op.drop_index("ix_ingestion_jobs_status")
batch_op.drop_index(op.f("ix_ingestion_jobs_started_at"))
batch_op.create_index(
"ix_ingestion_jobs_content_source_id", ["content_source_id"], unique=False
)
batch_op.create_index("ix_ingestion_jobs_content_source_id", ["content_source_id"], unique=False)
batch_op.drop_column("updated_at")

with op.batch_alter_table("content_sources", schema=None) as batch_op:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@ def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("diarizations", schema=None) as batch_op:
batch_op.add_column(sa.Column("subject_id", sa.UUID(), nullable=True))
batch_op.create_index(
batch_op.f("ix_diarizations_subject_id"), ["subject_id"], unique=False
)
batch_op.create_foreign_key(
"fk_diarization_subject", "knowledge_subjects", ["subject_id"], ["id"]
)
batch_op.create_index(batch_op.f("ix_diarizations_subject_id"), ["subject_id"], unique=False)
batch_op.create_foreign_key("fk_diarization_subject", "knowledge_subjects", ["subject_id"], ["id"])

# ### end Alembic commands ###

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
def upgrade() -> None:
"""Upgrade schema."""
with op.batch_alter_table("diarizations", schema=None) as batch_op:
batch_op.alter_column(
"title", new_column_name="name", existing_type=sa.String()
)
batch_op.alter_column("title", new_column_name="name", existing_type=sa.String())


def downgrade() -> None:
Expand Down
4 changes: 1 addition & 3 deletions alembic/versions/73f13c5ff10a_add_metadata_to_chunk_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ def upgrade() -> None:
# Check for FK
fks = insp.get_foreign_keys("chunk_index")
has_fk = any(
fk["referred_table"] == "knowledge_subjects"
and "subject_id" in fk["constrained_columns"]
for fk in fks
fk["referred_table"] == "knowledge_subjects" and "subject_id" in fk["constrained_columns"] for fk in fks
)
if not has_fk:
batch_op.create_foreign_key(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"content_sources", sa.Column("source_metadata", sa.JSON(), nullable=True)
)
op.add_column("content_sources", sa.Column("source_metadata", sa.JSON(), nullable=True))
# ### end Alembic commands ###


Expand Down
12 changes: 3 additions & 9 deletions alembic/versions/bd01964d9b26_created_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ def upgrade() -> None:
sa.Column("language", sa.Text(), nullable=True),
sa.Column("embedding_model", sa.Text(), nullable=True),
sa.Column("dimensions", sa.Integer(), nullable=True),
sa.Column(
"status", sa.Text(), server_default=sa.text("'active'"), nullable=False
),
sa.Column("status", sa.Text(), server_default=sa.text("'active'"), nullable=False),
sa.Column(
"created_at",
sa.DateTime(timezone=True),
Expand Down Expand Up @@ -103,9 +101,7 @@ def upgrade() -> None:
sa.Column("chunk_id", sa.Text(), nullable=False),
sa.Column("chars", sa.Integer(), server_default=sa.text("0"), nullable=False),
sa.Column("language", sa.Text(), nullable=True),
sa.Column(
"version_number", sa.Integer(), server_default=sa.text("1"), nullable=False
),
sa.Column("version_number", sa.Integer(), server_default=sa.text("1"), nullable=False),
sa.Column(
"created_at",
sa.DateTime(timezone=True),
Expand All @@ -118,9 +114,7 @@ def upgrade() -> None:
initially="IMMEDIATE",
deferrable=True,
),
sa.ForeignKeyConstraint(
["job_id"], ["ingestion_jobs.id"], initially="IMMEDIATE", deferrable=True
),
sa.ForeignKeyConstraint(["job_id"], ["ingestion_jobs.id"], initially="IMMEDIATE", deferrable=True),
sa.PrimaryKeyConstraint("id"),
if_not_exists=True,
)
Expand Down
4 changes: 1 addition & 3 deletions alembic/versions/c16fab000f02_add_user_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ def upgrade() -> None:
if_not_exists=True,
)
with op.batch_alter_table("users", schema=None) as batch_op:
batch_op.create_index(
batch_op.f("ix_users_email"), ["email"], unique=True, if_not_exists=True
)
batch_op.create_index(batch_op.f("ix_users_email"), ["email"], unique=True, if_not_exists=True)

# ### end Alembic commands ###

Expand Down
4 changes: 1 addition & 3 deletions alembic/versions/c48798b08031_add_voice_samples_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,4 @@ def downgrade() -> None:
sa.PrimaryKeyConstraint("id"),
)
with op.batch_alter_table("voice_samples", schema=None) as batch_op:
batch_op.create_index(
batch_op.f("ix_voice_samples_voice_id"), ["voice_id"], unique=False
)
batch_op.create_index(batch_op.f("ix_voice_samples_voice_id"), ["voice_id"], unique=False)
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ def upgrade() -> None:
if_not_exists=True,
)
with op.batch_alter_table("voices", schema=None) as batch_op:
batch_op.create_index(
batch_op.f("ix_voices_name"), ["name"], unique=True, if_not_exists=True
)
batch_op.create_index(batch_op.f("ix_voices_name"), ["name"], unique=True, if_not_exists=True)


def downgrade() -> None:
Expand Down
37 changes: 32 additions & 5 deletions frontend/src/components/DiarizationView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@ export function DiarizationView() {
loadJobs(true).then(updatedJobs => {
const updated = updatedJobs.find(j => j.id === activeJob.id);
if (updated && updated.status !== activeJob.status) {
if (updated.status === 'awaiting_verification' || updated.status === 'completed' || updated.status === 'failed') {
// If user is already in identification/result, don't reset the
// local speakers state on transient status changes (e.g. voice
// training flipping the job to TRAINING → COMPLETED). Only
// open/reset the job when we were still waiting on the initial
// diarization run.
const inIdentification = step === 'identification' || step === 'result';
if (!inIdentification && (updated.status === 'awaiting_verification' || updated.status === 'completed' || updated.status === 'failed')) {
handleOpenJob(updated);
} else {
setActiveJob(updated);
Expand All @@ -111,7 +117,18 @@ export function DiarizationView() {
}
}
}
}, [lastEvent, loadJobs, activeJob, addToast, t]);

// Voice training finished in background → clear per-speaker processing flag
if (lastEvent.type === 'voice' && lastEvent.action === 'train' && lastEvent.name) {
const finishedName = lastEvent.name as string;
setSpeakers(prev => prev.map(s =>
s.trainingStatus === 'processing' && s.assigned === finishedName
? { ...s, trainingStatus: undefined, confidence: Math.max(s.confidence, 95) }
: s
));
refreshVoices();
}
}, [lastEvent, loadJobs, activeJob, addToast, t, step, refreshVoices]);


// -- HANDLERS --
Expand Down Expand Up @@ -497,9 +514,19 @@ export function DiarizationView() {
speaker={trainingSpeaker}
diarizationId={activeJob?.id || ''}
onClose={() => setTrainingSpeaker(null)}
onTrained={() => {
refreshVoices();
handleRecognizeSpeakers();
onTrained={(name) => {
// Mark this speaker as "processing" and optimistically assign the
// new name so the UI reflects the in-flight training job. The
// button will switch to "Reinforce" once the backend publishes
// the voice/train completion event.
const targetId = trainingSpeaker?.id;
if (targetId) {
setSpeakers(prev => prev.map(s =>
s.id === targetId
? { ...s, assigned: name, trainingStatus: 'processing' }
: s
));
}
}}
/>
</div>
Expand Down
Loading
Loading