AutoRAG¶
You do not construct these classes yourself. Every
AiProjectHandle owns one
AutoRagManager and exposes it as
autorag. deploy, list and get hand back an
AutoRag bound to one retriever.
deploy returns an
AutoRagDeployResult, whose
service_info is a ServiceInfo documented
in Models and whose autorag is the bound object. undeploy
returns the ServiceInfo directly. ask returns a
GraphRagQueryResponse.
- class arango_ai_sdk.projects.services.autorag.AutoRagManager(service_api, api, project, refresh)¶
Deploy, list and look up the retrievers of one project.
- Parameters:
service_api (
ServiceApi) – Sends install and delete requests to ACP.api (
AutoRagApi) – Sends health and query requests to the retrievers themselves.project (
callable returning AiProject) – Returns the current project snapshot.refresh (
callable returning AiProject) – Reloads the project from the platform and returns the new snapshot.
- deploy(*, chat_api_provider, embedding_api_provider, chat_secret_profile_id, embedding_secret_profile_id, chat_model=None, embedding_model=None, chat_api_url=None, embedding_api_url=None, labels=None, wait=False)¶
Install a new retriever in this project and return the deploy result.
Steps: build the install request, send it through
ServiceApi.deploy_servicetoAcpPath.GRAPHRAG_RETRIEVER, refresh the project, bind anAutoRagto the new service id. ACP answers once Helm accepts the install, before the pod is up. Withwait=Truethe call then runsAutoRag.wait_until_ready()with its defaults and reports the outcome inready; a slow start never fails the deploy.- Parameters:
chat_api_provider (
str) – Provider of the chat model, for example"openai".embedding_api_provider (
str) – Provider of the embedding model, for example"openai".chat_secret_profile_id (
str) – ID of the secret profile holding the chat provider’s API key.embedding_secret_profile_id (
str) – ID of the secret profile holding the embedding provider’s API key.chat_model (
str, optional) – Chat model name, for example"gpt-4o".embedding_model (
str, optional) – Embedding model name, for example"text-embedding-3-small".chat_api_url (
str, optional) – Override for the chat provider’s endpoint.embedding_api_url (
str, optional) – Override for the embedding provider’s endpoint.labels (
Mapping[str,str], optional) – Labels attached to the deployed service on the platform.wait (
bool) – Also wait for the service health check before returning.not (Optional parameters are left out of the install request when)
value (given. The SDK does not validate the required strings; an empty)
is. (is sent as)
- Returns:
service_infofrom ACP,readyas described above, andautoragbound to the new service.- Return type:
- Raises:
ProjectNotFoundError – The project no longer exists on the platform.
InvalidServiceParametersError – ACP rejected an install parameter.
ServiceError – Any other error answer from the service.
- list()¶
Refresh the project and return an
AutoRagper deployed retriever.- Return type:
list[AutoRag]
- get(service_id)¶
Refresh the project and return the
AutoRagbound toservice_id.- Raises:
AutoRagNotDeployedError – No retriever with that id is in the project.
- Parameters:
service_id (str)
- Return type:
- class arango_ai_sdk.projects.services.autorag.AutoRagDeployResult(service_info, ready, autorag)¶
What
AutoRagManager.deployreturns: the service record, readiness and the object.- Parameters:
service_info (ServiceInfo)
ready (bool | None)
autorag (AutoRag)
- service_info¶
The service as ACP described it right after accepting the install.
- Type:
ServiceInfo
- ready¶
Truewhendeploy(wait=True)saw the health check answerOKwithin the bound,Falsewhen the bound passed first,Nonewhen nobody waited (wait=False).- Type:
boolorNone
- class arango_ai_sdk.projects.services.autorag.AutoRag(service_api, api, project, refresh, service_id)¶
One deployed retriever of a project, bound to its service id.
Obtained from
AutoRagManager, never constructed by users. The id is fixed for the object’s lifetime, every other state property is read from the project snapshot and reflects a refresh.- Parameters:
service_api (
ServiceApi) – Sends the delete request to ACP.api (
AutoRagApi) – Sends health and query requests to the retriever itself.project (
callable returning AiProject) – Returns the current project snapshot.refresh (
callable returning AiProject) – Reloads the project from the platform and returns the new snapshot.service_id (
str) – Id of the retriever this object is bound to.
- property service_id: str¶
Return the id of the retriever this object is bound to.
- property is_deployed: bool¶
Return whether the last project snapshot still lists this retriever.
- property service_url: str | None¶
Return the retriever’s URL, or
Nonewhen it is no longer deployed.
- property service_path: str | None¶
Return the gateway path of the retriever, or
None.service_urlminus scheme and host, without a trailing slash, so endpoints can be appended to it.
- ask(query, *, query_type=QueryType.UNIFIED, response_instructions=None, include_metadata=False, partition_ids=None, show_citations=None, model=None)¶
Ask the retriever a question and return its answer.
- Parameters:
query (
str) – The question, in natural language. Required, an empty string is rejected.query_type (
QueryType) – How the retriever searches. DefaultUNIFIED, which works on both VectorRAG and Full GraphRAG partitions.response_instructions (
str, optional) – Style instructions for the answer, such as"Short answer".include_metadata (
bool) – Whether to include retrieval metadata in the response.partition_ids (
Sequence[str], optional) – Restrict retrieval to these partitions. When omitted the service selects the relevant partitions itself.show_citations (
bool, optional) – Whether to keep inline citations in the answer. Omitted means the service default.model (
str, optional) – Chat model to use for this query only, instead of the deploy-time default.
- Returns:
resultholds the answer,run_idthe persisted query run.- Return type:
GraphRagQueryResponse- Raises:
ValueError –
queryis empty; nothing is sent.AutoRagNotDeployedError – The retriever is no longer in the project.
QueryFailedError – The service answered with a failure code instead of a result.
ServiceError – Any other error answer from the service.
- wait_until_ready(*, timeout=300.0, poll_interval=5.0)¶
Block until the retriever answers its health check with
OK.A failed request while the route or the pod is still coming up counts as not ready, not as an error. For the sake of convenience, this method is dedicated to AutoRag retrievers, and not shared with other types of services.
- Parameters:
timeout (
float) – Seconds to wait before giving up.poll_interval (
float) – Seconds between two health checks.
- Returns:
Trueonce the service isOK,Falsewhentimeoutpassed first.- Return type:
bool- Raises:
AutoRagNotDeployedError – The retriever is no longer in the project.
- undeploy()¶
Stop and remove this retriever.
Steps: refresh the project, raise if the retriever is gone, send
ServiceApi.deletewith the bound id, refresh again.- Raises:
AutoRagNotDeployedError – The retriever is no longer in the project.
ServiceNotFoundError – ACP no longer knows the service id the project metadata holds.
ServiceError – Any other error answer from the service.
- Return type:
ServiceInfo