Choosing a strategy per cluster¶
run = sales.autograph.strategize(categories=["legal", "finance"])
One call starts the strategizer for the given categories, waits until it
finishes and returns the final job status. The strategizer looks at each
cluster the corpus build produced and decides how it is imported: as a full
knowledge graph with entities and relations (FullGraphRAG), or as vectors
only (VectorRAG). The choice is stored on the platform; the import step
reads it from there. This is the second step of ingestion, after
Building the corpus and before Importing the graph.
The status this call returns carries progress counts only. Which cluster got which strategy is read separately with Reading the stored strategies.
Before sending anything, strategize reloads the project and refuses if it
has no AutoGraph service.
Parameters¶
Parameter |
Type |
Meaning |
|---|---|---|
|
sequence of |
The categories to analyse, as passed to the corpus build. At least one is required. |
|
|
What share of the clusters, ranked by complexity, gets |
|
|
Turn image extraction on for the |
|
|
How many clusters are analysed at once. Unset uses the service default. |
|
|
Deadline in seconds for the whole run. Unset waits without bound. |
|
|
Seconds between two status polls. Default 30. |
|
callable, optional |
Called with every polled
|
Return value¶
The final GetRagStrategizerJobStatusResponse.
Its status is "completed" and progress is the percentage done,
0 to 100. Nothing on it says which strategy a cluster got; call
strategies() for that.
Errors¶
ValueErrorcategoriesis empty. Nothing was sent.AutoGraphNotDeployedErrorThe project has no AutoGraph service. Nothing was sent.
ModelConfigNotReadyErrorAutoGraph cannot use its chat or embedding settings. Check the secret profiles and models passed to
deploy, or retry shortly.AutoGraphBusyErrorA conflicting job is already running on the project. Wait for it and retry.
IngestionFailedErrorThe run ended as failed.
job_statuson the exception is the final status. Cancellation only happens on an import.JobStatusLostErrorAutoGraph no longer has a status for the run, usually after a restart. The run itself may still be going.
JobTimeoutErrortimeoutpassed before the run finished. The run keeps going on the platform.
Any other failure, including extract_images_default with a complexity
below high, surfaces as one of the general SDK exceptions described in
Errors, usually a ServiceError
carrying the status code and message the service returned.
Example¶
from arango_ai_sdk.models import RagStrategizerComplexity
sales = client.project.get(project_name="sales")
def show(status):
print(f"strategize {status.status} {status.clusters_done}/{status.clusters_total}")
run = sales.autograph.strategize(
categories=["legal", "finance"],
complexity=RagStrategizerComplexity.moderate,
on_progress=show,
)
stored = sales.autograph.strategies()
print(f"{run.clusters_done} clusters analysed: {dict(stored.strategy_type_counts)}")