Extraction jobs

Updated at:

The Long-term Memory Service performs memory extraction asynchronously in batches. Each extraction job reports its execution status and results. This topic describes how to query, cancel, and retry extraction jobs.

Prerequisites

  • LindormTable, the search engine, the vector engine, and the AI engine are activated, and the Long-term Memory Service is activated and configured.

  • A project is created, and a valid project access key (SK) is obtained.

Request description

The APIs in this topic share the following request conventions:

ItemDescription
Request URLThe service endpoint concatenated with the API path.
AuthenticationThe request header includes Authorization: Bearer sk-....
Project scopeDetermined by the SK. Do not pass project_id separately.
User scopeJobs are scoped to the project. The application is responsible for verifying user identity.
Request formatThe JSON request body uses Content-Type: application/json.
Response formatA successful response contains request_id and data. For the error format, see Response description in Service overview.

Job status

The status field of an extraction job can have the following values. The progress field indicates the job stage, not an exact execution percentage.

statusprogressCan be cancelledCan be retried
queued0YesNo
processing0.5NoNo
completed1.0NoNo
failed1.0NoYes
cancelled1.0NoYes

Prepare connection information

The sample commands in this topic use the following variables:

ENDPOINT="<service endpoint>"
SK="<project access key (SK)>"

Replace ENDPOINT with the service endpoint, including the protocol, hostname, and port. Replace SK with the project access key (SK). The job IDs in the sample commands are example values. Replace them with your actual data.

List jobs

Queries the extraction jobs in the current project. You can filter jobs by job status.

Sample request

Send the following request:

curl --request GET "${ENDPOINT}/lmemo/v1/jobs?status=failed&limit=20" \
  --header "Authorization: Bearer ${SK}"

The following table describes the query parameters.

ParameterRequiredDescription
statusNoThe job status used to filter results. Valid values: queued, processing, completed, failed, and cancelled.
limitNoThe number of entries to return. Valid values: 1 to 100. Default value: 20.
Note

The job list returns only the first batch of results, and limit specifies the number of results. Paging by page or page_size is not supported. The returned pagination.page is always 1. To continuously track a job, query the job by job ID as described in Query a single job.

Sample response

The following example shows a successful response:

{
  "request_id": "req-example",
  "data": {
    "items": [],
    "pagination": {
      "page": 1,
      "page_size": 20,
      "total": 0,
      "has_more": false
    }
  }
}

Query a single job

Queries the execution status and extraction results of a job by job ID.

Send the following request:

curl --request GET "${ENDPOINT}/lmemo/v1/jobs/batch-001" \
  --header "Authorization: Bearer ${SK}"

The response fields are the same as those for a job item in the job list. When present, the response also includes the following fields:

FieldDescription
resultA summary of successful extraction results.
result.memory_countThe number of memories in the extraction results.
result.profile_updatedIndicates whether the profile update was accepted.
errorThe failure reason.

Cancel a job

Cancels a job that is in the queued state. For a job in any other state, the request returns HTTP status code 409 (Conflict).

Send the following request:

curl --request POST "${ENDPOINT}/lmemo/v1/jobs/batch-001/cancel" \
  --header "Authorization: Bearer ${SK}"

On success, data is the updated job object.

Retry a job

Retries a job that is in the failed or cancelled state. After a retry, the job re-enters the queue. For a job in any other state, the request returns HTTP status code 409 (Conflict).

Send the following request:

curl --request POST "${ENDPOINT}/lmemo/v1/jobs/batch-001/retry" \
  --header "Authorization: Bearer ${SK}"

On success, data is the updated job object.