Skip to content
Merged
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 backend/app/api/docs/documents/info.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Retrieve all information about a given document.
Retrieve all information about a given document. If you set the ``include_url`` parameter to true, a signed URL will be included in the response, which is a clickable link to access the retrieved document. If you don't set it to true, the URL will not be included in the response.
1 change: 1 addition & 0 deletions backend/app/api/docs/documents/job_info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Get the status and details of a document transformation job. If you set the ``include_url`` parameter to true, a signed URL will be included in the response, which is a clickable link to access the transformed document if the job has been successful. If you don't set it to true, the URL will not be included in the response.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion:
Instead of placing the information about include_url in the top-level documentation, it would be clearer to include it within the description of that specific field.
The top-level section should focus on explaining the overall API behavior, note any exceptional or abnormal behaviors, and include general guidance or notes where appropriate.

1 change: 1 addition & 0 deletions backend/app/api/docs/documents/job_list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Get the status and details of multiple document transformation jobs by IDs. If you set the ``include_url`` parameter to true, a signed URL will be included in the response, which is a clickable link to access the transformed document for successful jobs. If you don't set it to true, the URL will not be included in the response.
2 changes: 1 addition & 1 deletion backend/app/api/docs/documents/list.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
List documents uploaded to the AI platform.
List documents uploaded to the AI platform. If you set the ``include_url`` parameter to true, a signed URL will be included in the response, which is a clickable link to access the retrieved documents. If you don't set it to true, the URL will not be included in the response.
1 change: 1 addition & 0 deletions backend/app/api/docs/documents/upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Upload a document to the AI platform.

- If only a file is provided, the document will be uploaded and stored, and its ID will be returned.
- 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 Transformations

Expand Down
9 changes: 4 additions & 5 deletions backend/app/api/routes/doc_transformation_job.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
from uuid import UUID
import logging

from fastapi import APIRouter, HTTPException, Query, Path
from fastapi import APIRouter, Query, Path

from app.api.deps import CurrentUserOrgProject, SessionDep
from app.crud import DocTransformationJobCrud, DocumentCrud
from app.models import (
DocTransformationJobPublic,
DocTransformationJobsPublic,
TransformedDocumentPublic,
)
from app.utils import APIResponse
from app.utils import APIResponse, load_description
from app.services.documents.helpers import build_job_schema, build_job_schemas
from app.core.cloud import get_cloud_storage

Expand All @@ -21,7 +20,7 @@

@router.get(
"/{job_id}",
description="Get the status and details of a document transformation job.",
description=load_description("documents/job_info.md"),
response_model=APIResponse[DocTransformationJobPublic],
)
def get_transformation_job(
Expand Down Expand Up @@ -53,7 +52,7 @@ def get_transformation_job(

@router.get(
"/",
description="Get the status and details of multiple document transformation jobs by IDs.",
description=load_description("documents/job_list.md"),
response_model=APIResponse[DocTransformationJobsPublic],
)
def get_multiple_transformation_jobs(
Expand Down
21 changes: 21 additions & 0 deletions backend/app/api/routes/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
DocumentUploadResponse,
Message,
TransformationJobInfo,
DocTransformationJobPublic,
)
from app.services.collections.helpers import pick_service_for_documennt
from app.services.documents.helpers import (
Expand All @@ -36,6 +37,25 @@

logger = logging.getLogger(__name__)
router = APIRouter(prefix="/documents", tags=["documents"])
doctransformation_callback_router = APIRouter()


@doctransformation_callback_router.post(
"{$callback_url}",
name="doctransformation_callback",
)
def doctransformation_callback_notification(
body: APIResponse[DocTransformationJobPublic],
):
"""
Callback endpoint specification for document transformation.

The callback will receive:
- On success: APIResponse with success=True and data containing DocTransformationJobPublic
- On failure: APIResponse with success=False and error message
- metadata field will always be included if provided in the request
"""
...


@router.get(
Expand Down Expand Up @@ -73,6 +93,7 @@ def list_docs(
"/",
description=load_description("documents/upload.md"),
response_model=APIResponse[DocumentUploadResponse],
callbacks=doctransformation_callback_router.routes,
)
async def upload_doc(
session: SessionDep,
Expand Down