Skip to content

Latest commit

 

History

History
655 lines (421 loc) · 83 KB

README.md

File metadata and controls

655 lines (421 loc) · 83 KB

Knowledge

(knowledge)

Overview

Available Operations

list

Returns a list of your knowledge bases. The knowledge bases are returned sorted by creation date, with the most recent knowledge bases appearing first

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.knowledge.list()

    assert res is not None

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
limit Optional[float] A limit on the number of objects to be returned. Limit can range between 1 and 50, and the default is 10
starting_after Optional[str] A cursor for use in pagination. starting_after is an object ID that defines your place in the list. For instance, if you make a list request and receive 20 objects, ending with 01JJ1HDHN79XAS7A01WB3HYSDB, your subsequent call can include after=01JJ1HDHN79XAS7A01WB3HYSDB in order to fetch the next page of the list.
ending_before Optional[str] A cursor for use in pagination. ending_before is an object ID that defines your place in the list. For instance, if you make a list request and receive 20 objects, starting with 01JJ1HDHN79XAS7A01WB3HYSDB, your subsequent call can include before=01JJ1HDHN79XAS7A01WB3HYSDB in order to fetch the previous page of the list.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ListKnowledgeBasesResponseBody

Errors

Error Type Status Code Content Type
models.APIError 4XX, 5XX */*

create

Create a knowledge

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.knowledge.create(key="<key>", embedding_model="<value>", path="Customer Service/Billing/Refund")

    assert res is not None

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
key str ✔️ N/A
embedding_model str ✔️ The embeddings model to use for the knowledge base. This model will be used to embed the chunks when they are added to the knowledge base.
path str ✔️ The path where the entity is stored in the project structure. The first element of the path always represents the project name. Any subsequent path element after the project will be created as a folder in the project if it does not exists. Customer Service/Billing/Refund
description Optional[str] N/A
retrieval_settings Optional[models.RetrievalSettings] The retrieval settings for the knowledge base. If not provider, Hybrid Search will be used as a default query strategy.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.CreateKnowledgeResponseBody

Errors

Error Type Status Code Content Type
models.APIError 4XX, 5XX */*

retrieve

Retrieve a knowledge base with the settings.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.knowledge.retrieve(knowledge_id="<id>")

    assert res is not None

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
knowledge_id str ✔️ Unique identifier of the knowledge base
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.GetOneKnowledgeResponseBody

Errors

Error Type Status Code Content Type
models.APIError 4XX, 5XX */*

update

Updates a knowledge

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.knowledge.update(knowledge_id="<id>", path="Customer Service/Billing/Refund")

    assert res is not None

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
knowledge_id str ✔️ The unique identifier of the knowledge base
description OptionalNullable[str] The description of the knowledge base.
embedding_model Optional[str] The embeddings model used for the knowledge base. If the models is provided and is different than the previous set model, all the datasources in the knowledge base will be re-embedded.
path Optional[str] The path where the entity is stored in the project structure. The first element of the path always represents the project name. Any subsequent path element after the project will be created as a folder in the project if it does not exists. Customer Service/Billing/Refund
retrieval_settings Optional[models.UpdateKnowledgeRetrievalSettings] The retrieval settings for the knowledge base. If not provider, Hybrid Search will be used as a default query strategy.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.UpdateKnowledgeResponseBody

Errors

Error Type Status Code Content Type
models.APIError 4XX, 5XX */*

delete

Deletes a knowledge base. Deleting a knowledge base will delete all the datasources and chunks associated with it.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    orq.knowledge.delete(knowledge_id="<id>")

    # Use the SDK ...

Parameters

Parameter Type Required Description
knowledge_id str ✔️ The unique identifier of the knowledge base
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Errors

Error Type Status Code Content Type
models.APIError 4XX, 5XX */*

list_datasources

List all datasources

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.knowledge.list_datasources(knowledge_id="<id>", status="completed")

    assert res is not None

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
knowledge_id str ✔️ Unique identifier of the knowledge base
limit Optional[float] A limit on the number of objects to be returned. Limit can range between 1 and 50, and the default is 10
starting_after Optional[str] A cursor for use in pagination. starting_after is an object ID that defines your place in the list. For instance, if you make a list request and receive 20 objects, ending with 01JJ1HDHN79XAS7A01WB3HYSDB, your subsequent call can include after=01JJ1HDHN79XAS7A01WB3HYSDB in order to fetch the next page of the list.
ending_before Optional[str] A cursor for use in pagination. ending_before is an object ID that defines your place in the list. For instance, if you make a list request and receive 20 objects, starting with 01JJ1HDHN79XAS7A01WB3HYSDB, your subsequent call can include before=01JJ1HDHN79XAS7A01WB3HYSDB in order to fetch the previous page of the list.
q Optional[str] Search query to find datasources by name.
status Optional[models.Status] Filter datasources by status.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ListDatasourcesResponseBody

Errors

Error Type Status Code Content Type
models.APIError 4XX, 5XX */*

create_datasource

Create a new datasource

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.knowledge.create_datasource(knowledge_id="<id>")

    assert res is not None

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
knowledge_id str ✔️ The unique identifier of the knowledge base
display_name Optional[str] The display name for the datasource visible in the UI. If omitted, the display name is derived from the uploaded file. When both display_name and file_id are provided, the provided display_name is prioritized.
file_id Optional[str] The unique identifier of the file used for datasource creation. If provided, the file is immediately queued for chunking.
chunking_options Optional[models.ChunkingOptions] Configuration options specifying how the datasource file is chunked. Required if file_id is specified. Defaults to standard chunking options if omitted.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.CreateDatasourceResponseBody

Errors

Error Type Status Code Content Type
models.APIError 4XX, 5XX */*

retrieve_datasource

Retrieve a datasource

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.knowledge.retrieve_datasource(knowledge_id="<id>", datasource_id="<id>")

    assert res is not None

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
knowledge_id str ✔️ The unique identifier of the knowledge base
datasource_id str ✔️ The unique identifier of the datasource.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.RetrieveDatasourceResponseBody

Errors

Error Type Status Code Content Type
models.APIError 4XX, 5XX */*

delete_datasource

Deletes a datasource from a knowledge base. Deleting a datasource will remove it from the knowledge base and all associated chunks. This action is irreversible and cannot be undone.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    orq.knowledge.delete_datasource(knowledge_id="<id>", datasource_id="<id>")

    # Use the SDK ...

Parameters

Parameter Type Required Description
knowledge_id str ✔️ The unique identifier of the knowledge base
datasource_id str ✔️ The unique identifier of the datasource.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Errors

Error Type Status Code Content Type
models.APIError 4XX, 5XX */*

update_datasource

Update a datasource

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.knowledge.update_datasource(knowledge_id="<id>", datasource_id="<id>", display_name="Haylee_Braun")

    assert res is not None

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
knowledge_id str ✔️ The unique identifier of the knowledge base
datasource_id str ✔️ The unique identifier of the datasource.
display_name str ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.UpdateDatasourceResponseBody

Errors

Error Type Status Code Content Type
models.APIError 4XX, 5XX */*

create_chunks

Create chunks for a datasource

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.knowledge.create_chunks(knowledge_id="<id>", datasource_id="<id>")

    assert res is not None

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
knowledge_id str ✔️ Unique identifier of the knowledge
datasource_id str ✔️ Unique identifier of the datasource
request_body List[models.RequestBody] N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

List[models.CreateChunkResponseBody]

Errors

Error Type Status Code Content Type
models.APIError 4XX, 5XX */*

list_chunks

List all chunks for a datasource

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.knowledge.list_chunks(knowledge_id="<id>", datasource_id="<id>", status="completed")

    assert res is not None

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
knowledge_id str ✔️ The unique identifier of the knowledge base
datasource_id str ✔️ The unique identifier of the datasource.
limit Optional[float] A limit on the number of objects to be returned. Limit can range between 1 and 50, and the default is 10
starting_after Optional[str] A cursor for use in pagination. starting_after is an object ID that defines your place in the list. For instance, if you make a list request and receive 20 objects, ending with 01JJ1HDHN79XAS7A01WB3HYSDB, your subsequent call can include after=01JJ1HDHN79XAS7A01WB3HYSDB in order to fetch the next page of the list.
ending_before Optional[str] A cursor for use in pagination. ending_before is an object ID that defines your place in the list. For instance, if you make a list request and receive 20 objects, starting with 01JJ1HDHN79XAS7A01WB3HYSDB, your subsequent call can include before=01JJ1HDHN79XAS7A01WB3HYSDB in order to fetch the previous page of the list.
q Optional[str] Search query to find datasources by name.
status Optional[models.QueryParamStatus] Filter datasources by status.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ListChunksResponseBody

Errors

Error Type Status Code Content Type
models.APIError 4XX, 5XX */*

update_chunk

Update a chunk

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.knowledge.update_chunk(chunk_id="<id>", datasource_id="<id>", knowledge_id="<id>")

    assert res is not None

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
chunk_id str ✔️ The unique identifier of the chunk
datasource_id str ✔️ The unique identifier of the data source
knowledge_id str ✔️ The unique identifier of the knowledge base
text Optional[str] The text content of the chunk
embedding List[float] The embedding vector of the chunk. If not provided the chunk will be embedded with the knowledge base embeddings model.
metadata Optional[models.UpdateChunkMetadata] Metadata of the chunk
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.UpdateChunkResponseBody

Errors

Error Type Status Code Content Type
models.APIError 4XX, 5XX */*

delete_chunk

Delete a chunk

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    orq.knowledge.delete_chunk(chunk_id="<id>", datasource_id="<id>", knowledge_id="<id>")

    # Use the SDK ...

Parameters

Parameter Type Required Description
chunk_id str ✔️ The unique identifier of the chunk
datasource_id str ✔️ The unique identifier of the data source
knowledge_id str ✔️ The unique identifier of the knowledge base
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Errors

Error Type Status Code Content Type
models.APIError 4XX, 5XX */*

retrieve_chunk

Retrieve a chunk

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.knowledge.retrieve_chunk(chunk_id="<id>", datasource_id="<id>", knowledge_id="<id>")

    assert res is not None

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
chunk_id str ✔️ The unique identifier of the chunk
datasource_id str ✔️ The unique identifier of the data source
knowledge_id str ✔️ The unique identifier of the knowledge base
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.GetOneChunkResponseBody

Errors

Error Type Status Code Content Type
models.APIError 4XX, 5XX */*