Skip to main content

RecallDocument

You can retrieve document chunks from a document library using text. You can specify the number of chunks to retrieve, filter them by metadata conditions, and choose whether to complete the document chunks.

Operation description

Prerequisites
  • Activate the Alibaba Cloud Model Studio service and the Tongyi Dianjin service.
  • Obtain the workspace ID. Obtain the workspace identity.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:
  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.
  • API: The API that you can call to perform the action.
  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.
  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.
    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.
    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.
  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.
  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

dianjin:RecallDocument

none

*All Resource

*

NoneNone

Request syntax

POST /{workspaceId}/api/library/recallDocument HTTP/1.1

Path Parameters

Parameter

Type

Required

Description

Example

workspaceId

string

Yes

Path parameter, workspace ID.

llm-xxxxx

Request parameters

Parameter

Type

Required

Description

Example

body

object

No

Request body parameters.

filters

array<object>

No

Metadata filter conditions.

array<object>

No

Filter.

and

array<object>

No

AND expression, used to filter documents/document chunks.

object

No

AND expression.

boost

number

No

Keyword weight.

20

key

string

No

The key of the metadata in the document library.

docType

operator

string

No

The relationship between the value stored in the document library metadata key and the value you enter.

  • eq: The value stored in the document library metadata key equals the value you enter.

  • lte: The value stored in the document library metadata key is less than or equal to the value you enter.

  • gte: The value stored in the document library metadata key is greater than or equal to the value you enter.

  • lt: The value stored in the document library metadata key is less than the value you enter.

  • gt: The value stored in the document library metadata key is greater than the value you enter.

  • contains: The list of values stored in the document library metadata key contains the value you enter.

contains

value

string

No

The value of the metadata you enter.

Strategy report

chunkType

string

No

Document chunk type, used to filter document chunks, such as: Text, Graph, Table, FAQ.

Text

docIdList

array

No

Document ID list, used to filter documents/document chunks.

string

No

Document ID.

8372458573692819933

libraryId

string

Yes

Document library ID, used to filter documents/document chunks.

sdbjhvs

or

array<object>

No

OR expression, used to filter documents/document chunks.

object

No

OR expression.

boost

number

No

Keyword weight.

30

key

string

No

The key of the metadata in the document library.

researcher

operator

string

No

The relationship between the value stored in the document library metadata key and the value you enter.

  • eq: The value stored in the document library metadata key equals the value you enter.

  • lte: The value stored in the document library metadata key is less than or equal to the value you enter.

  • gte: The value stored in the document library metadata key is greater than or equal to the value you enter.

  • lt: The value stored in the document library metadata key is less than the value you enter.

  • gt: The value stored in the document library metadata key is greater than the value you enter.

  • contains: The list of values stored in the document library metadata key contains the value you enter.

eq

value

string

No

The value of the metadata you enter.

alice

status

array

No

Document status list, used to filter documents.

string

No

Document status.

WaitRefresh

query

string

Yes

Text.

Which teams in European Championship history have benefited from players adapting to new cultures

rearrangement

boolean

No

Enable parent-child document chunk retrieval.

  • Parent-child document chunks: During document parsing, a complete semantic block, such as a paragraph or a section, might split into multiple document chunks. This depends on your chunking strategy. When you enable parent-child document retrieval, the system attempts to complete the semantic block of the retrieved document chunk. This makes the corpus more semantically complete when constructing prompts, improving answer completeness and accuracy.

false

topK

integer

No

The number of document chunks to retrieve.

10

Response elements

Element

Type

Description

Example

object

Returned data.

cost

integer

Time elapsed.

0

data

object

Response data.

chunkList

array<object>

Chunk list.

array<object>

Chunk.

chunkId

string

Document chunk ID.

823746762354

chunkMeta

object

Document chunk metadata.

{"a":"1"}

chunkOssUrl

string

Document chunk OSS address.

http://oss-xxx-hangzhou.com/xxx

chunkText

string

Document chunk text.

Test document chunk

chunkType

string

Document chunk type.

text

docId

string

Document ID.

839468263472

fileType

string

Document type.

pdf

libraryId

string

Document library ID.

dscsbdsk

libraryName

string

Document library name.

Test document library

nextChunkId

string

Next document chunk ID.

982374872364

pos

array<object>

Document chunk position.

object

Document chunk position coordinates.

axisArray

array

Coordinates.

number

Coordinate value.

20.8

page

integer

Page number.

1

textHighlightArea

array

Text highlight area, used for text-type file highlighting.

integer

Text highlight area data.

1

preChunkId

string

Previous document chunk ID.

827364827364832

score

number

Document chunk score.

0.5

title

string

Document title.

test

chunkPartList

array<object>

Chunk part (layout recognition result) list.

array<object>

Chunk part (layout recognition result).

chunkId

string

Document chunk ID.

98327482364

chunkMeta

object

Document chunk metadata.

{"a":"1"}

chunkOssUrl

string

Document chunk OSS address.

http://oss-xxx-hangzhou.com/xxx

chunkText

string

Document chunk text.

Test document chunk

chunkType

string

Document chunk type.

text

docId

string

Document ID.

92837482364

fileType

string

Document type.

pdf

libraryId

string

Document library ID.

sjdhgjsd

libraryName

string

Document library name.

Test document library

nextChunkId

string

Next document chunk ID.

2387648263542

pos

array<object>

Document chunk position.

object

Document chunk position data.

axisArray

array

Coordinates.

number

Coordinate value.

1

page

integer

Page number.

1

textHighlightArea

array

Text highlight area, used for text-type file highlighting.

integer

Text highlight area position data.

1

preChunkId

string

Previous document chunk ID.

32874682764

score

number

Document chunk score.

0.5

title

string

Document title.

Test document title

chunkTextList

array

Chunk text list.

string

Document chunk

This is a test document chunk

documents

array<object>

Document list.

array<object>

Document information.

docId

string

Document ID.

92837482364

documentMeta

object

Document metadata.

{"a":"1"}

fileType

string

Document type.

pdf

gmtCreate

string

Creation time.

2024-01-01 00:00:00

libraryId

string

Document library ID.

sjdhgjsd

title

string

Document title.

test

url

string

Document link.

http://oss-xxx-hangzhou.com/test.pdf

embeddingElapsedMs

integer

Vector computation time elapsed.

100

textChunkList

array<object>

List of chunks retrieved from the text index.

array<object>

Chunk retrieved from the text index.

chunkId

string

Document chunk ID.

32874682364

chunkMeta

object

Document chunk metadata.

{"a":"1"}

chunkOssUrl

string

Document chunk OSS address.

http://oss-xxx-hangzhou.com/xxx

chunkText

string

Document chunk text.

This is a test document chunk

chunkType

string

Document chunk type.

text

docId

string

Document ID.

8372467263542

fileType

string

Document type.

pdf

libraryId

string

Document library ID.

djsgfsjd

libraryName

string

Document library name.

Test document library

nextChunkId

string

Next document chunk ID.

23874682432

pos

array<object>

Document chunk position.

object

Document chunk position.

axisArray

array

Coordinates.

number

Coordinate value.

10

page

integer

Page number.

1

textHighlightArea

array

Text highlight area, used for text-type file highlighting.

integer

Text highlight area data.

1

preChunkId

string

Previous document chunk ID.

89473868346

score

number

Document chunk score.

0.5

title

string

Document title.

Test document title

textSearchElapsedMs

integer

Text search time elapsed.

100

totalElapsedMs

integer

Total time elapsed, including vector computation time, vector search time, and text search time (depending on retrieval parameters).

400

vectorChunkList

array<object>

List of chunks retrieved from the vector index.

array<object>

Chunk retrieved from the vector index.

chunkId

string

Document chunk ID.

8723642345276

chunkMeta

object

Document chunk metadata.

{"a":"1"}

chunkOssUrl

string

Document chunk OSS address.

https://oss-xxxx-hangzhou.com/test.pdf

chunkText

string

Document chunk text.

This is a test text

chunkType

string

Document chunk type.

text

docId

string

Document ID.

78326476235675372

fileType

string

Document type.

pdf

libraryId

string

Document library ID.

djsgfsjd

libraryName

string

Document library name.

Test document library

nextChunkId

string

Next document chunk ID.

293846872343

pos

array<object>

Document chunk position.

object

Document chunk position coordinates.

axisArray

array

Coordinates.

number

Coordinate value.

48.8

page

integer

Page number.

1

textHighlightArea

array

Text highlight area, used for text-type file highlighting.

integer

Text highlight area.

10

preChunkId

string

Previous document chunk ID.

873647326542

score

number

Document chunk score.

0.5

title

string

Document title.

test

vectorSearchElapsedMs

integer

Vector search time elapsed.

100

dataType

string

Data type.

null

errCode

string

Error code.

0

message

string

Error message.

ok

requestId

string

Request ID.

0bc13a9517168617617186457e401f

success

boolean

Success.

true

time

string

Timestamp.

2024-04-24 11:54:34

Examples

Success response JSON format
{
  "cost": 0,
  "data": {
    "chunkList": [
      {
        "chunkId": "823746762354",
        "chunkMeta": {
          "a": "1"
        },
        "chunkOssUrl": "http://oss-xxx-hangzhou.com/xxx",
        "chunkText": "测试文档块",
        "chunkType": "text",
        "docId": "839468263472",
        "fileType": "pdf",
        "libraryId": "dscsbdsk",
        "libraryName": "测试文档库",
        "nextChunkId": "982374872364",
        "pos": [
          {
            "axisArray": [
              20.8
            ],
            "page": 1,
            "textHighlightArea": [
              1
            ]
          }
        ],
        "preChunkId": "827364827364832",
        "score": 0.5,
        "title": "test"
      }
    ],
    "chunkPartList": [
      {
        "chunkId": "98327482364",
        "chunkMeta": {
          "a": "1"
        },
        "chunkOssUrl": "http://oss-xxx-hangzhou.com/xxx\n",
        "chunkText": "测试文档块\n",
        "chunkType": "text",
        "docId": "92837482364",
        "fileType": "pdf",
        "libraryId": "sjdhgjsd",
        "libraryName": "测试文档库",
        "nextChunkId": "2387648263542",
        "pos": [
          {
            "axisArray": [
              1
            ],
            "page": 1,
            "textHighlightArea": [
              1
            ]
          }
        ],
        "preChunkId": "32874682764",
        "score": 0.5,
        "title": "测试文档标题"
      }
    ],
    "chunkTextList": [
      "这是一段测试文档块"
    ],
    "documents": [
      {
        "docId": "92837482364",
        "documentMeta": {
          "a": "1"
        },
        "fileType": "pdf",
        "gmtCreate": "2024-01-01 00:00:00",
        "libraryId": "sjdhgjsd\n",
        "title": "test",
        "url": "http://oss-xxx-hangzhou.com/test.pdf"
      }
    ],
    "embeddingElapsedMs": 100,
    "textChunkList": [
      {
        "chunkId": "32874682364",
        "chunkMeta": {
          "a": "1"
        },
        "chunkOssUrl": "http://oss-xxx-hangzhou.com/xxx\n",
        "chunkText": "这是一段测试文档块\n",
        "chunkType": "text",
        "docId": "8372467263542",
        "fileType": "pdf",
        "libraryId": "djsgfsjd",
        "libraryName": "测试文档库",
        "nextChunkId": "23874682432",
        "pos": [
          {
            "axisArray": [
              10
            ],
            "page": 1,
            "textHighlightArea": [
              1
            ]
          }
        ],
        "preChunkId": "89473868346",
        "score": 0.5,
        "title": "测试文档标题"
      }
    ],
    "textSearchElapsedMs": 100,
    "totalElapsedMs": 400,
    "vectorChunkList": [
      {
        "chunkId": "8723642345276",
        "chunkMeta": {
          "a": "1"
        },
        "chunkOssUrl": "https://oss-xxxx-hangzhou.com/test.pdf",
        "chunkText": "这是一段测试文本",
        "chunkType": "text",
        "docId": "78326476235675372",
        "fileType": "pdf",
        "libraryId": "djsgfsjd",
        "libraryName": "测试文档库",
        "nextChunkId": "293846872343",
        "pos": [
          {
            "axisArray": [
              48.8
            ],
            "page": 1,
            "textHighlightArea": [
              10
            ]
          }
        ],
        "preChunkId": "873647326542",
        "score": 0.5,
        "title": "test"
      }
    ],
    "vectorSearchElapsedMs": 100
  },
  "dataType": "null",
  "errCode": "0",
  "message": "ok",
  "requestId": "0bc13a9517168617617186457e401f",
  "success": true,
  "time": "2024-04-24 11:54:34"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.
Token Plan
Model Playground
Fine-tuning
Model Compression
Statistics and Monitoring
Support