Skip to main content

CreateLibrary

Creates a document library. A document library isolates document and index data. If your use case requires frequent natural language search by category, create multiple libraries to isolate different data types. You can customize vector and text indexes by format.

Operation description

Prerequisites
  • You have activated Alibaba Cloud Model Studio and Tongyi Dianjin.
  • Obtain the workspaceId: Obtain the workspace identifier.

Debug

You can run this API directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After a successful run, OpenAPI Explorer can automatically generate SDK code examples. Debug

Authorization information

The following table describes the authorization information for this API. You can use it in the Action element of a RAM policy statement to grant RAM users or RAM roles the permission to call this API. Details are as follows:
  • Action: the specific permission point.
  • Access level: the access level of each action. Valid values: Write, Read, or List.
  • Resource type: the resource types that support authorization for the action. Details are as follows:
    • For required resource types, an asterisk (*) is added as a prefix.
    • For actions that do not support resource-level authorization, All resources is used.
  • Condition key: the condition keys defined by the cloud service itself.
  • Related action: other permissions required to successfully perform the action. The caller must also have the permissions of the related actions for the operation to succeed.
ActionAccess levelResource typeCondition keyRelated action
dianjin:CreateLibrarycreate
*All resources
*
    None
None

Request syntax

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

Request parameters

NameTypeRequiredDescriptionExample value
workspaceIdstringYes

Business space ID

llm-ik******RVYCKzt
bodyobjectNo

Request body.

descriptionstringYes

Description of the document library

Describe the specific purpose of the document library
indexSettingobjectNo

Index settings of the document library

chunkStrategyobjectNo

Chunking strategy

docTreeSplitbooleanNo

Layout-based splitting

true
docTreeSplitSizeintegerNo

Layout-based split size

300
enhanceGraphbooleanNo

Whether to parse image content in documents

true
enhanceTablebooleanNo

Whether to parse table content in documents

true
overlapintegerNo

Chunk overlap length

20
sentenceSplitbooleanNo

Split by sentence

true
sentenceSplitSizeintegerNo

Sentence-based split size

300
sizeintegerNo

Chunk size

300
splitbooleanNo

Whether to split into chunks

true
modelConfigobjectNo

Model configuration

temperaturedoubleNo

Controls the randomness and diversity of model responses. Specifically, the temperature value controls the degree of smoothing applied to the probability distribution over candidate tokens during text generation. A higher temperature value lowers the peak of the probability distribution, allowing more low-probability tokens to be selected and producing more diverse results. A lower temperature value sharpens the peak, making high-probability tokens more likely to be selected and producing more deterministic results.

Valid range: [0, 2). A value of 0 is not recommended because it is meaningless.

0.8
topPdoubleNo

Probability threshold for nucleus sampling during generation. For example, with a value of 0.8, only the smallest set of the most likely tokens whose cumulative probability is greater than or equal to 0.8 is retained as the candidate set. Valid range: (0, 1.0). A higher value produces more random results, and a lower value produces more deterministic results.

0.8
promptRoleStylestringNo

Prompt role style. By specifying a role and describing the tone and style, you can control the quality of the final responses. Examples: document analysis expert, gentle customer service agent, professional financial industry analyst.

You are an information processing expert: patient, friendly, and logically clear.
queryEnhancerobjectNo

Query enhancement configuration

enableFollowUpbooleanNo

Whether to rewrite questions based on the history

true
enableMultiQuerybooleanNo

Whether to use LLM knowledge to decompose questions

true
enableOpenQabooleanNo

Whether to use LLM knowledge to answer questions

true
enableQueryRewritebooleanNo

Whether to use question rewriting

true
enableSessionbooleanNo

Whether to enable multi-turn conversations

true
localKnowledgeIdstringNo

Document library ID used for knowledge rewriting

xxxx
withDocumentReferencebooleanNo

Whether to include document references

true
recallStrategyobjectNo

Recall strategy

documentRankTypestringNo

Merge & sort strategy

Valid values:
  • linear: linear.
  • model: model.
model
limitintegerNo

Number of results from two-way merge and summarization

20
textIndexSettingobjectNo

Text index configuration

categorystringNo

Text index type. Currently, only ElasticSearch is supported.

ElasticSearch
enablebooleanNo

Whether to enable the text index.

Valid values:
  • true: true.
  • false: false.
true
indexAnalyzerstringNo

Index analyzer of the text index: (Standard, IkMaxWord, IkSmart)

Standard
rankThresholddoubleNo

Text index ranking threshold

0.5
searchAnalyzerstringNo

Search analyzer of the text index: (Standard, IkMaxWord, IkSmart)

Standard
topKintegerNo

Number of final text index summary results

50
vectorIndexSettingobjectNo

Vector index settings

categorystringNo

Vector index source: only ADB is currently supported

ADB
embeddingTypestringNo

Text Embedding type of the vector index

Valid values:
  • DashScope: DashScope.
DashScope
enablebooleanNo

Whether to enable

Valid values:
  • true: true.
  • false: false.
true
rankThresholddoubleNo

Vector index ranking threshold

0.5
topKintegerNo

Number of final vector index summary results

50
libraryNamestringYes

Name of the document library

Financial knowledge document library

Response parameters

NameTypeDescriptionExample value
object

ResultCode

costlong

Processing time

300
datastring

Response data

a1b2c3
dataTypestring

Data type

null
errCodestring

Error code

0
messagestring

Error message

Success
requestIdstring

Request ID

xxxx-xxxx-xxxx-xxxx
successboolean

Whether the operation is successful

true
timestring

Timestamp

null

Examples

Success response JSON format
{
  "cost": 300,
  "data": "a1b2c3",
  "dataType": null,
  "errCode": 0,
  "message": "成功",
  "requestId": "xxxx-xxxx-xxxx-xxxx",
  "success": true,
  "time": null
}

Error codes

Visit the Error Center to view more error codes.