Skip to content

Commit 1e62db0

Browse files
authored
Document : documentation fixes and callback router (#456)
* function doc fixes and callback router * small fix
1 parent ec347af commit 1e62db0

File tree

7 files changed

+30
-7
lines changed

7 files changed

+30
-7
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Retrieve all information about a given document.
1+
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.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
List documents uploaded to the AI platform.
1+
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.

backend/app/api/docs/documents/upload.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Upload a document to the AI platform.
22

33
- If only a file is provided, the document will be uploaded and stored, and its ID will be returned.
44
- 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.
5+
- If a callback URL is provided, you will receive a notification at that URL once the document transformation job is completed.
56

67
### Supported Transformations
78

backend/app/api/routes/doc_transformation_job.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
from uuid import UUID
22
import logging
33

4-
from fastapi import APIRouter, HTTPException, Query, Path
4+
from fastapi import APIRouter, Query, Path
55

66
from app.api.deps import CurrentUserOrgProject, SessionDep
77
from app.crud import DocTransformationJobCrud, DocumentCrud
88
from app.models import (
99
DocTransformationJobPublic,
1010
DocTransformationJobsPublic,
11-
TransformedDocumentPublic,
1211
)
13-
from app.utils import APIResponse
12+
from app.utils import APIResponse, load_description
1413
from app.services.documents.helpers import build_job_schema, build_job_schemas
1514
from app.core.cloud import get_cloud_storage
1615

@@ -21,7 +20,7 @@
2120

2221
@router.get(
2322
"/{job_id}",
24-
description="Get the status and details of a document transformation job.",
23+
description=load_description("documents/job_info.md"),
2524
response_model=APIResponse[DocTransformationJobPublic],
2625
)
2726
def get_transformation_job(
@@ -53,7 +52,7 @@ def get_transformation_job(
5352

5453
@router.get(
5554
"/",
56-
description="Get the status and details of multiple document transformation jobs by IDs.",
55+
description=load_description("documents/job_list.md"),
5756
response_model=APIResponse[DocTransformationJobsPublic],
5857
)
5958
def get_multiple_transformation_jobs(

backend/app/api/routes/documents.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
DocumentUploadResponse,
2424
Message,
2525
TransformationJobInfo,
26+
DocTransformationJobPublic,
2627
)
2728
from app.services.collections.helpers import pick_service_for_documennt
2829
from app.services.documents.helpers import (
@@ -36,6 +37,25 @@
3637

3738
logger = logging.getLogger(__name__)
3839
router = APIRouter(prefix="/documents", tags=["documents"])
40+
doctransformation_callback_router = APIRouter()
41+
42+
43+
@doctransformation_callback_router.post(
44+
"{$callback_url}",
45+
name="doctransformation_callback",
46+
)
47+
def doctransformation_callback_notification(
48+
body: APIResponse[DocTransformationJobPublic],
49+
):
50+
"""
51+
Callback endpoint specification for document transformation.
52+
53+
The callback will receive:
54+
- On success: APIResponse with success=True and data containing DocTransformationJobPublic
55+
- On failure: APIResponse with success=False and error message
56+
- metadata field will always be included if provided in the request
57+
"""
58+
...
3959

4060

4161
@router.get(
@@ -73,6 +93,7 @@ def list_docs(
7393
"/",
7494
description=load_description("documents/upload.md"),
7595
response_model=APIResponse[DocumentUploadResponse],
96+
callbacks=doctransformation_callback_router.routes,
7697
)
7798
async def upload_doc(
7899
session: SessionDep,

0 commit comments

Comments
 (0)