Skip to content

Create a helper function to poll for knowledge base indexing completion #41

@bbatha

Description

@bbatha

When a Gradient AI Platform Knowledge Base is indexed can run for several minutes. Currently users must write loops to poll for the job state, roughly.

from gradient import Gradient

client = Gradient()
while True:
  indexing_job = client.knowledge_bases.indexing_jobs.retrieve(
      "uuid",
  )
 if indexing_job.job.phase in ["BATCH_JOB_PHASE_UNKNOWN", "BATCH_JOB_PHASE_PENDING", "BATCH_JOB_PHASE_RUNNING"]:
    continue

This should of course handle failed states for errors and such

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions