Extraction jobs
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:
| Item | Description |
| Request URL | The service endpoint concatenated with the API path. |
| Authentication | The request header includes Authorization: Bearer sk-.... |
| Project scope | Determined by the SK. Do not pass project_id separately. |
| User scope | Jobs are scoped to the project. The application is responsible for verifying user identity. |
| Request format | The JSON request body uses Content-Type: application/json. |
| Response format | A 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.
status | progress | Can be cancelled | Can be retried |
queued | 0 | Yes | No |
processing | 0.5 | No | No |
completed | 1.0 | No | No |
failed | 1.0 | No | Yes |
cancelled | 1.0 | No | Yes |
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.
| Parameter | Required | Description |
status | No | The job status used to filter results. Valid values: queued, processing, completed, failed, and cancelled. |
limit | No | The number of entries to return. Valid values: 1 to 100. Default value: 20. |
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:
| Field | Description |
result | A summary of successful extraction results. |
result.memory_count | The number of memories in the extraction results. |
result.profile_updated | Indicates whether the profile update was accepted. |
error | The 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.