(knowledge)
Returns a list of your knowledge bases. The knowledge bases are returned sorted by creation date, with the most recent knowledge bases appearing first
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)
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. |
models.ListKnowledgeBasesResponseBody
Error Type |
Status Code |
Content Type |
models.APIError |
4XX, 5XX |
*/* |
Create a knowledge
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)
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. |
|
models.CreateKnowledgeResponseBody
Error Type |
Status Code |
Content Type |
models.APIError |
4XX, 5XX |
*/* |
Retrieve a knowledge base with the settings.
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)
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. |
models.GetOneKnowledgeResponseBody
Error Type |
Status Code |
Content Type |
models.APIError |
4XX, 5XX |
*/* |
Updates a knowledge
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)
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. |
|
models.UpdateKnowledgeResponseBody
Error Type |
Status Code |
Content Type |
models.APIError |
4XX, 5XX |
*/* |
Deletes a knowledge base. Deleting a knowledge base will delete all the datasources and chunks associated with it.
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 ...
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. |
Error Type |
Status Code |
Content Type |
models.APIError |
4XX, 5XX |
*/* |
List all datasources
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)
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. |
models.ListDatasourcesResponseBody
Error Type |
Status Code |
Content Type |
models.APIError |
4XX, 5XX |
*/* |
Create a new datasource
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)
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. |
models.CreateDatasourceResponseBody
Error Type |
Status Code |
Content Type |
models.APIError |
4XX, 5XX |
*/* |
Retrieve a datasource
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)
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. |
models.RetrieveDatasourceResponseBody
Error Type |
Status Code |
Content Type |
models.APIError |
4XX, 5XX |
*/* |
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.
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 ...
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. |
Error Type |
Status Code |
Content Type |
models.APIError |
4XX, 5XX |
*/* |
Update a datasource
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)
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. |
models.UpdateDatasourceResponseBody
Error Type |
Status Code |
Content Type |
models.APIError |
4XX, 5XX |
*/* |
Create chunks for a datasource
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)
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. |
List[models.CreateChunkResponseBody]
Error Type |
Status Code |
Content Type |
models.APIError |
4XX, 5XX |
*/* |
List all chunks for a datasource
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)
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. |
models.ListChunksResponseBody
Error Type |
Status Code |
Content Type |
models.APIError |
4XX, 5XX |
*/* |
Update a chunk
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)
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. |
models.UpdateChunkResponseBody
Error Type |
Status Code |
Content Type |
models.APIError |
4XX, 5XX |
*/* |
Delete a chunk
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 ...
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. |
Error Type |
Status Code |
Content Type |
models.APIError |
4XX, 5XX |
*/* |
Retrieve a chunk
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)
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. |
models.GetOneChunkResponseBody
Error Type |
Status Code |
Content Type |
models.APIError |
4XX, 5XX |
*/* |