Skip to content

Latest commit

 

History

History
355 lines (244 loc) · 19.6 KB

File metadata and controls

355 lines (244 loc) · 19.6 KB

Entities

Overview

Available Operations

list_instructions

List all instructions.

Example Usage

from ragie import Ragie


with Ragie(
    auth="<YOUR_BEARER_TOKEN_HERE>",
) as r_client:

    res = r_client.entities.list_instructions()

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

List[models.Instruction]

Errors

Error Type Status Code Content Type
models.ErrorMessage 401, 402, 429 application/json
models.ErrorMessage 500 application/json
models.SDKError 4XX, 5XX */*

create_instruction

Create a new instruction. Instructions are applied to documents as they are created or updated. The results of the instruction are stored as structured data in the schema defined by the entity_schema parameter. The prompt parameter is a natural language instruction which will be applied to documents. This feature is in beta and may change in the future.

Example Usage

import ragie
from ragie import Ragie


with Ragie(
    auth="<YOUR_BEARER_TOKEN_HERE>",
) as r_client:

    res = r_client.entities.create_instruction(request={
        "name": "Find all pizzas",
        "scope": ragie.CreateInstructionParamsScope.DOCUMENT,
        "prompt": "Find all pizzas described in the text.",
        "context_template": "Document: {{document.name}} {{document.metadata.key_foo}}",
        "entity_schema": {
            "key": "<value>",
            "key1": "<value>",
        },
        "filter_": {
            "toppings": {
                "$in": [
                    "pizza",
                    "mushrooms",
                ],
            },
        },
        "partition": "<value>",
    })

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
request models.CreateInstructionParams ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.Instruction

Errors

Error Type Status Code Content Type
models.HTTPValidationError 422 application/json
models.ErrorMessage 401, 402, 429 application/json
models.ErrorMessage 500 application/json
models.SDKError 4XX, 5XX */*

delete_instruction

Delete an instruction. This will delete the instruction and all entities generated by it. This operation is irreversible.

Example Usage

from ragie import Ragie


with Ragie(
    auth="<YOUR_BEARER_TOKEN_HERE>",
) as r_client:

    res = r_client.entities.delete_instruction(instruction_id="00000000-0000-0000-0000-000000000000")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
instruction_id str ✔️ The ID of the instruction. 00000000-0000-0000-0000-000000000000
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

Dict[str, str]

Errors

Error Type Status Code Content Type
models.HTTPValidationError 422 application/json
models.ErrorMessage 401, 402, 429 application/json
models.ErrorMessage 500 application/json
models.SDKError 4XX, 5XX */*

update_instruction

Patch Instruction

Example Usage

import ragie
from ragie import Ragie


with Ragie(
    auth="<YOUR_BEARER_TOKEN_HERE>",
) as r_client:

    res = r_client.entities.update_instruction(instruction_id="00000000-0000-0000-0000-000000000000", patch_instruction_params={
        "name": "Find all pizzas",
        "active": True,
        "scope": ragie.PatchInstructionParamsScope.DOCUMENT,
        "prompt": "Find all pizzas described in the text.",
        "context_template": "Document: {{document.name}} {{document.metadata.key_foo}}",
        "filter_": {
            "toppings": {
                "$in": [
                    "pizza",
                    "mushrooms",
                ],
            },
        },
    })

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
instruction_id str ✔️ The ID of the instruction. 00000000-0000-0000-0000-000000000000
patch_instruction_params models.PatchInstructionParams ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.Instruction

Errors

Error Type Status Code Content Type
models.HTTPValidationError 422 application/json
models.ErrorMessage 401, 402, 429 application/json
models.ErrorMessage 500 application/json
models.SDKError 4XX, 5XX */*

list_by_instruction

Get Instruction Extracted Entities

Example Usage

from ragie import Ragie


with Ragie(
    auth="<YOUR_BEARER_TOKEN_HERE>",
) as r_client:

    res = r_client.entities.list_by_instruction(request={
        "instruction_id": "00000000-0000-0000-0000-000000000000",
        "partition": "acme_customer_id",
    })

    while res is not None:
        # Handle items

        res = res.next()

Parameters

Parameter Type Required Description
request models.ListEntitiesByInstructionRequest ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ListEntitiesByInstructionResponse

Errors

Error Type Status Code Content Type
models.HTTPValidationError 422 application/json
models.ErrorMessage 401, 402, 429 application/json
models.ErrorMessage 500 application/json
models.SDKError 4XX, 5XX */*

list_extraction_logs

List entity extraction logs for an instruction. Results are attempt-level and include both successful and unsuccessful extraction outcomes. Results are sorted by created_at in descending order and paginated. Historical extraction attempts before 2026-03-06 are unavailable in this endpoint.

Example Usage

from ragie import Ragie


with Ragie(
    auth="<YOUR_BEARER_TOKEN_HERE>",
) as r_client:

    res = r_client.entities.list_extraction_logs(request={
        "instruction_id": "00000000-0000-0000-0000-000000000000",
        "partition": "acme_customer_id",
    })

    while res is not None:
        # Handle items

        res = res.next()

Parameters

Parameter Type Required Description
request models.ListInstructionEntityExtractionLogsRequest ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ListInstructionEntityExtractionLogsResponse

Errors

Error Type Status Code Content Type
models.HTTPValidationError 422 application/json
models.ErrorMessage 401, 402, 429 application/json
models.ErrorMessage 500 application/json
models.SDKError 4XX, 5XX */*

list_by_document

Get Document Extracted Entities

Example Usage

from ragie import Ragie


with Ragie(
    auth="<YOUR_BEARER_TOKEN_HERE>",
) as r_client:

    res = r_client.entities.list_by_document(request={
        "document_id": "00000000-0000-0000-0000-000000000000",
        "partition": "acme_customer_id",
    })

    while res is not None:
        # Handle items

        res = res.next()

Parameters

Parameter Type Required Description
request models.ListEntitiesByDocumentRequest ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ListEntitiesByDocumentResponse

Errors

Error Type Status Code Content Type
models.HTTPValidationError 422 application/json
models.ErrorMessage 401, 402, 429 application/json
models.ErrorMessage 500 application/json
models.SDKError 4XX, 5XX */*