Skip to content

Latest commit

 

History

History
270 lines (191 loc) · 25.7 KB

File metadata and controls

270 lines (191 loc) · 25.7 KB

Documents

Overview

Available Operations

list

Retrieve a paginated list of documents for the authenticated organization.

Example Usage

from agentset import Agentset


with Agentset(
    namespace_id="ns_123",
    x_tenant_id="<id>",
    token="AGENTSET_API_KEY",
) as a_client:

    res = a_client.documents.list(order_by="createdAt", order="desc", cursor_direction="forward", per_page=30)

    while res is not None:
        # Handle items

        res = res.next()

Parameters

Parameter Type Required Description
statuses List[models.DocumentStatus] N/A
order_by Optional[models.ListDocumentsOrderBy] The field to order by. Default is createdAt.
order Optional[models.ListDocumentsOrder] The order to sort by. Default is desc.
ingest_job_id Optional[str] N/A
cursor Optional[str] N/A
cursor_direction Optional[models.PaginationCursorDirection] The direction to paginate by.
per_page Optional[float] N/A
x_tenant_id Optional[str] Optional tenant id to use for the request. If not provided, the namespace will be used directly. Must be alphanumeric and up to 64 characters.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ListDocumentsResponse

Errors

Error Type Status Code Content Type
errors.BadRequestError 400 application/json
errors.UnauthorizedError 401 application/json
errors.ForbiddenError 403 application/json
errors.NotFoundError 404 application/json
errors.ConflictError 409 application/json
errors.InviteExpiredError 410 application/json
errors.UnprocessableEntityError 422 application/json
errors.RateLimitExceededError 429 application/json
errors.InternalServerError 500 application/json
errors.AgentsetDefaultError 4XX, 5XX */*

get

Retrieve the info for a document.

Example Usage

from agentset import Agentset


with Agentset(
    namespace_id="ns_123",
    x_tenant_id="<id>",
    token="AGENTSET_API_KEY",
) as a_client:

    res = a_client.documents.get(document_id="doc_123")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
document_id str ✔️ The id of the document (prefixed with doc_) doc_123
x_tenant_id Optional[str] Optional tenant id to use for the request. If not provided, the namespace will be used directly. Must be alphanumeric and up to 64 characters.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.GetDocumentResponse

Errors

Error Type Status Code Content Type
errors.BadRequestError 400 application/json
errors.UnauthorizedError 401 application/json
errors.ForbiddenError 403 application/json
errors.NotFoundError 404 application/json
errors.ConflictError 409 application/json
errors.InviteExpiredError 410 application/json
errors.UnprocessableEntityError 422 application/json
errors.RateLimitExceededError 429 application/json
errors.InternalServerError 500 application/json
errors.AgentsetDefaultError 4XX, 5XX */*

delete

Delete a document for the authenticated organization.

Example Usage

from agentset import Agentset


with Agentset(
    namespace_id="ns_123",
    x_tenant_id="<id>",
    token="AGENTSET_API_KEY",
) as a_client:

    res = a_client.documents.delete(document_id="doc_123")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
document_id str ✔️ The id of the document (prefixed with doc_) doc_123
x_tenant_id Optional[str] Optional tenant id to use for the request. If not provided, the namespace will be used directly. Must be alphanumeric and up to 64 characters.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.DeleteDocumentResponse

Errors

Error Type Status Code Content Type
errors.BadRequestError 400 application/json
errors.UnauthorizedError 401 application/json
errors.ForbiddenError 403 application/json
errors.NotFoundError 404 application/json
errors.ConflictError 409 application/json
errors.InviteExpiredError 410 application/json
errors.UnprocessableEntityError 422 application/json
errors.RateLimitExceededError 429 application/json
errors.InternalServerError 500 application/json
errors.AgentsetDefaultError 4XX, 5XX */*

get_chunks_download_url

Get a presigned download URL for a document's chunks. Only available for completed documents.

Example Usage

from agentset import Agentset


with Agentset(
    namespace_id="ns_123",
    token="AGENTSET_API_KEY",
) as a_client:

    res = a_client.documents.get_chunks_download_url(document_id="doc_123")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
document_id str ✔️ The id of the document (prefixed with doc_) doc_123
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.GetChunksDownloadURLResponse

Errors

Error Type Status Code Content Type
errors.BadRequestError 400 application/json
errors.UnauthorizedError 401 application/json
errors.ForbiddenError 403 application/json
errors.NotFoundError 404 application/json
errors.ConflictError 409 application/json
errors.InviteExpiredError 410 application/json
errors.UnprocessableEntityError 422 application/json
errors.RateLimitExceededError 429 application/json
errors.InternalServerError 500 application/json
errors.AgentsetDefaultError 4XX, 5XX */*

get_file_download_url

Get a presigned download URL for a document's source file. Only available for documents with source type MANAGED_FILE.

Example Usage

from agentset import Agentset


with Agentset(
    namespace_id="ns_123",
    token="AGENTSET_API_KEY",
) as a_client:

    res = a_client.documents.get_file_download_url(document_id="doc_123")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
document_id str ✔️ The id of the document (prefixed with doc_) doc_123
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.GetFileDownloadURLResponse

Errors

Error Type Status Code Content Type
errors.BadRequestError 400 application/json
errors.UnauthorizedError 401 application/json
errors.ForbiddenError 403 application/json
errors.NotFoundError 404 application/json
errors.ConflictError 409 application/json
errors.InviteExpiredError 410 application/json
errors.UnprocessableEntityError 422 application/json
errors.RateLimitExceededError 429 application/json
errors.InternalServerError 500 application/json
errors.AgentsetDefaultError 4XX, 5XX */*