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
Actionelement 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
Resourceelement of the policy. - For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the
Resourceelement of the policy.
- For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the
- 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
| None | None |
Request syntax
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.
| 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 |
| 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.
| 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. | |
| chunkText | string | Document chunk text. | Test document chunk |
| chunkType | string | Document chunk type. | text |
| docId | string | Document ID. | 839468263472 |
| fileType | string | Document type. | |
| 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. | |
| chunkText | string | Document chunk text. | Test document chunk |
| chunkType | string | Document chunk type. | text |
| docId | string | Document ID. | 92837482364 |
| fileType | string | Document type. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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