Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .claude/conventions/celery.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ the bands already in use (see the `job_execution.py` module docstring):
|---|---|---|
| `9` | `default` | User-blocking, interactive — LLM call / chain / response jobs |
| `9` | `evaluations` | Fast evaluation chunk/aggregate (top band of this queue; new eval tasks pick a lower band) |
| `2` | `default` | Default — doctransform, collections, assessment |
| `2` | `default` | Default — collections, assessment |
| `2` | `evaluations` | STT evaluation (batch submission, metric computation) and TTS evaluation (batch submission, sync generation, result processing) — below fast eval |
| `1` | `default` | Notifications and other fire-and-forget background work |

Expand Down
2 changes: 1 addition & 1 deletion .claude/conventions/service.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Service conventions (`app/services/`)

Authoritative conventions for business-logic services in kaapi-backend. Services live in
`app/services/<domain>/` (auth, collections, doctransform, llm, evaluations, ...).
`app/services/<domain>/` (auth, collections, documents, llm, evaluations, ...).
Services are where orchestration happens — they call CRUD for DB work and call external HTTP
libraries for third-party APIs.

Expand Down
4 changes: 0 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ PENDING_JOB_MONITOR_INTERVAL_MINUTES=5
PENDING_RECENT_GRACE_MINUTES=3
LLM_PENDING_THRESHOLD_MINUTES=30
COLLECTION_PENDING_THRESHOLD_MINUTES=30
DOC_TRANSFORMATION_PENDING_THRESHOLD_MINUTES=30
PENDING_JOB_QUERY_TIMEOUT_MS=1000

# Rate limits (requests per minute per organization; over-limit calls get 429)
Expand Down Expand Up @@ -110,9 +109,6 @@ TTS_QUEUED_STALE_SECONDS=86400
CALLBACK_CONNECT_TIMEOUT = 3
CALLBACK_READ_TIMEOUT = 10

# require as a env if you want to use doc transformation
OPENAI_API_KEY=""

# Platform-owned Anthropic key for AI-assisted prompt improvement.
# Shared across all orgs/projects so the feature works without per-project credentials.
ANTHROPIC_API_KEY=""
Expand Down
2 changes: 0 additions & 2 deletions .env.test.example
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,5 @@ AWS_S3_BUCKET_PREFIX="bucket-prefix-name"
CALLBACK_CONNECT_TIMEOUT = 3
CALLBACK_READ_TIMEOUT = 10

OPENAI_API_KEY=""

KAAPI_GUARDRAILS_AUTH=""
KAAPI_GUARDRAILS_URL=""
1 change: 0 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ The backend follows a layered architecture located in `backend/app/`:
- Database connection and session management
- Security (JWT, password hashing, API keys)
- Cloud storage (`cloud/storage.py`)
- Document transformation (`doctransform/`)
- Fine-tuning utilities (`finetune/`)
- Langfuse observability integration (`langfuse/`)
- Exception handlers and middleware
Expand Down
113 changes: 113 additions & 0 deletions backend/app/alembic/versions/096_drop_doc_transformation_job_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
"""drop doc_transformation_job

Revision ID: 096
Revises: 095
Create Date: 2026-12-04 00:00:00.000000

The Document transformation module was removed, so nothing reads or writes this
table any more. Rows are lost on upgrade; downgrade restores the schema as it stood
at 095 (an empty table) so older code can boot, not the data.

document.source_document_id is kept: transformed documents that already exist are
still ordinary documents and remain listable.
"""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

revision = "096"
down_revision = "095"
branch_labels = None
depends_on = None


def upgrade():
op.drop_table("doc_transformation_job")
op.execute("DROP TYPE IF EXISTS transformationstatus")


def downgrade():
transformation_status = postgresql.ENUM(
"PENDING", "PROCESSING", "COMPLETED", "FAILED", name="transformationstatus"
)

op.create_table(
"doc_transformation_job",
sa.Column(
"id",
sa.Uuid(),
nullable=False,
comment="Unique identifier for the transformation job",
),
sa.Column(
"source_document_id",
sa.Uuid(),
nullable=False,
comment="Reference to the source document being transformed",
),
sa.Column(
"transformed_document_id",
sa.Uuid(),
nullable=True,
comment="Reference to the resulting transformed document",
),
sa.Column(
"status",
transformation_status,
nullable=False,
comment="Current status (PENDING, PROCESSING, COMPLETED, FAILED)",
),
sa.Column(
"error_message",
sa.String(),
nullable=True,
comment="Error message if transformation failed",
),
sa.Column(
"inserted_at",
sa.DateTime(),
nullable=False,
comment="Timestamp when the job was created",
),
sa.Column(
"updated_at",
sa.DateTime(),
nullable=False,
comment="Timestamp when the job was last updated",
),
sa.Column(
"task_id",
sa.String(),
nullable=True,
comment="Celery task ID for async processing",
),
sa.Column(
"trace_id",
sa.String(),
nullable=True,
comment="Tracing ID for correlating logs and traces",
),
sa.ForeignKeyConstraint(
["source_document_id"], ["document.id"], ondelete="CASCADE"
),
sa.ForeignKeyConstraint(
["transformed_document_id"], ["document.id"], ondelete="CASCADE"
),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(
"ix_doc_transformation_job_source_document_id",
"doc_transformation_job",
["source_document_id"],
)
op.create_index(
"ix_doc_transformation_job_transformed_document_id",
"doc_transformation_job",
["transformed_document_id"],
)
op.create_index(
"ix_doc_transformation_job_status_inserted_at",
"doc_transformation_job",
["status", "inserted_at"],
)
3 changes: 0 additions & 3 deletions backend/app/api/docs/documents/job_info.md

This file was deleted.

3 changes: 0 additions & 3 deletions backend/app/api/docs/documents/job_list.md

This file was deleted.

2 changes: 1 addition & 1 deletion backend/app/api/docs/documents/permanent_delete.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Permanently delete a document.

The file is removed from cloud storage (e.g., S3) and the database record is deleted. This cannot be undone. Records
that depend on the document, such as its transformed documents, transformation jobs, fine-tuning jobs and model
that depend on the document, such as its transformed documents, fine-tuning jobs and model
evaluations, are deleted along with it.

Works on both active and soft-deleted documents. Collections and knowledge bases that contain this document are not
Expand Down
19 changes: 2 additions & 17 deletions backend/app/api/docs/documents/upload.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
Upload a document to Kaapi and optionally transform it as well.
Upload a document to Kaapi.

- If only a file is provided, the document will be uploaded and stored, and its ID will be returned. The maximum file size allowed for upload is 25 MB.
- If a target format is specified, a transformation job will also be created to transform document into target format in the background. The response will include both the uploaded document details and information about the transformation job.
- If a callback URL is provided, you will receive a notification at that URL once the document transformation job is completed.

### Supported Conversions:

The following (source_format → target_format) transformations are supported for now:

- pdf → markdown
- zerox

### Transformers:

Available transformer names and their implementations, default transformer is zerox for now:

- `zerox`
The document is uploaded and stored, and its ID is returned along with a signed URL to access it. The maximum file size allowed for upload is 25 MB.
2 changes: 1 addition & 1 deletion backend/app/api/docs/documents/v2/register.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Final step of the v2 upload flow, and it takes no request body. The uploaded obj

Errors: `400` if nothing was uploaded for that `document_id` (the upload never happened or the URL lapsed); `409` if the `document_id` was already registered — open a new upload session in that case.

The 25 MB cap is enforced by storage while the file uploads, so an oversized file never reaches this step. Document transformation is not available on v2. Use `POST /api/v1/documents` if you need a `target_format` conversion.
The 25 MB cap is enforced by storage while the file uploads, so an oversized file never reaches this step.
2 changes: 0 additions & 2 deletions backend/app/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
credentials,
cron,
decision,
doc_transformation_job,
documents,
evaluations,
features,
Expand Down Expand Up @@ -55,7 +54,6 @@
api_router.include_router(credentials.router)
api_router.include_router(cron.router)
api_router.include_router(decision.router)
api_router.include_router(doc_transformation_job.router)
api_router.include_router(documents.router)
api_router.include_router(duplicate_detection.router)
api_router.include_router(evaluations.router)
Expand Down
115 changes: 0 additions & 115 deletions backend/app/api/routes/doc_transformation_job.py

This file was deleted.

Loading
Loading