Knowledge
List Knowledge
Returns a list of your knowledge bases. The knowledge bases are returned sorted by creation date, with the most recent knowledge bases appearing firstfrom orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.list(limit=10)
# Handle response
print(res)
Show Parameters
Show Parameters
A limit on the number of objects to be returned. Limit can range between 1 and 50, and the default is 10
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.Show Response
Show Response
Create a Knowledge
Create a knowledgefrom orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.create(request={
"type": "internal",
"key": "<key>",
"embedding_model": "<value>",
"path": "Default",
})
# Handle response
print(res)
Show Parameters
Show Parameters
The request object to use for the request.
Retrieve a Knowledge
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>")
# Handle response
print(res)
Show Parameters
Show Parameters
The request object to use for the request.
Update a Knowledge
Updates a knowledgefrom 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>", request_body={
"path": "Default",
"type": "external",
})
# Handle response
print(res)
Show Parameters
Show Parameters
The unique identifier of the knowledge base
Delete a Knowledge
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 ...
Show Parameters
Show Parameters
The request object to use for the request.
Search Knowledge
Search a Knowledge Base and return the most similar chunks, along with their search and rerank scores. Note that all configuration changes made in the API will override the settings in the UI.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.search(knowledge_id="<id>", query="<value>", search_type="hybrid_search", rerank_config={
"model": "cohere/rerank-multilingual-v3.0",
})
# Handle response
print(res)
Show Parameters
Show Parameters
The unique identifier or key of the knowledge base
List Datasources
List all datasourcesfrom 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>", limit=50, status=[
"completed",
"failed",
])
# Handle response
print(res)
Show Parameters
Show Parameters
Unique identifier of the knowledge base
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.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.Search query to find datasources by name.
A limit on the number of objects to be returned. Limit can range between 1 and 50, and the default is 10
Show Response
Show Response
Show Properties of data
Show Properties of data
The unique identifier of the data source
The display name of the datasource. Normally the name of the uploaded file
The description of the knowledge base
The unique identifier of the file used to create the datasource.
The date and time the datasource was created
The date and time the datasource was updated
The user ID of the creator of the knowledge base
The user ID of the last user who updated the knowledge base
The unique identifier of the knowledge base
Create Datasource
Create a new datasourcefrom 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>")
# Handle response
print(res)
Show Parameters
Show Parameters
The unique identifier of the knowledge base
Show Response
Show Response
The unique identifier of the data source
The display name of the datasource. Normally the name of the uploaded file
The description of the knowledge base
The unique identifier of the file used to create the datasource.
The date and time the datasource was created
The date and time the datasource was updated
The user ID of the creator of the knowledge base
The user ID of the last user who updated the knowledge base
The unique identifier of the knowledge base
Retrieve Datasource
Retrieve a datasourcefrom 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>")
# Handle response
print(res)
Show Parameters
Show Parameters
The unique identifier of the knowledge base
Show Response
Show Response
The unique identifier of the data source
The display name of the datasource. Normally the name of the uploaded file
The description of the knowledge base
The unique identifier of the file used to create the datasource.
The date and time the datasource was created
The date and time the datasource was updated
The user ID of the creator of the knowledge base
The user ID of the last user who updated the knowledge base
The unique identifier of the knowledge base
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.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 ...
Show Parameters
Show Parameters
The unique identifier of the knowledge base
Update Datasource
Update a datasourcefrom 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="Tony_Roberts")
# Handle response
print(res)
Show Parameters
Show Parameters
Show Response
Show Response
The unique identifier of the data source
The display name of the datasource. Normally the name of the uploaded file
The description of the knowledge base
The unique identifier of the file used to create the datasource.
The date and time the datasource was created
The date and time the datasource was updated
The user ID of the creator of the knowledge base
The user ID of the last user who updated the knowledge base
The unique identifier of the knowledge base
Create Chunks
Create chunks for a datasourcefrom 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>")
# Handle response
print(res)
Show Parameters
Show Parameters
List Chunks
List all chunks for a datasourcefrom 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>", limit=10, status=[
"completed",
"failed",
])
# Handle response
print(res)
Show Parameters
Show Parameters
The unique identifier of the knowledge base
The unique identifier of the datasource.
A limit on the number of objects to be returned. Limit can range between 1 and 50, and the default is 10
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.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.Search query to find datasources by name.
Show Response
Show Response
Show Properties of data
Show Properties of data
The unique identifier of the chunk
The text content of the chunk
Metadata of the chunk. Can include
page_number or any other key-value pairsWhether the chunk is enabled
The status of the chunk
The date and time the chunk was created
The date and time the chunk was updated
The unique identifier of the user who created the chunk
Delete Chunks
Delete multiple chunksfrom orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.delete_chunks(knowledge_id="<id>", datasource_id="<id>", chunk_ids=[
"<value 1>",
"<value 2>",
])
# Handle response
print(res)
Show Parameters
Show Parameters
Show Response
Show Response
Number of chunks successfully deleted
List Chunks Paginated
List chunks with offset-based paginationfrom orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.list_chunks_paginated(knowledge_id="<id>", datasource_id="<id>", q="", limit=100, page=1)
# Handle response
print(res)
Show Parameters
Show Parameters
Show Response
Show Response
Show Properties of data
Show Properties of data
The unique identifier of the chunk
The text content of the chunk
Metadata of the chunk. Can include
page_number or any other key-value pairsWhether the chunk is enabled
The status of the chunk
The date and time the chunk was created
The date and time the chunk was updated
The unique identifier of the user who created the chunk
Get Chunks Count
Get chunks total countfrom orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.get_chunks_count(knowledge_id="<id>", datasource_id="<id>", q="")
# Handle response
print(res)
Show Parameters
Show Parameters
Update Chunk
Update a chunkfrom 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>")
# Handle response
print(res)
Show Parameters
Show Parameters
Show Response
Show Response
The unique identifier of the chunk
The text content of the chunk
Metadata of the chunk. Can include
page_number or any other key-value pairsWhether the chunk is enabled
The status of the chunk
The date and time the chunk was created
The date and time the chunk was updated
The unique identifier of the user who created the chunk
Delete Chunk
Delete a chunkfrom 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 ...
Show Parameters
Show Parameters
Retrieve Chunk
Retrieve a chunkfrom 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>")
# Handle response
print(res)
Show Parameters
Show Parameters
Show Response
Show Response
The unique identifier of the chunk
The text content of the chunk
Metadata of the chunk. Can include
page_number or any other key-value pairsWhether the chunk is enabled
The status of the chunk
The date and time the chunk was created
The date and time the chunk was updated
The unique identifier of the user who created the chunk