Generates a chat response from a document library. You can ask questions in natural language, and the system retrieves relevant information to provide a summarized answer.
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:RunLibraryChatGeneration | none | *All Resource
| None | None |
Request syntax
Path Parameters
Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| workspaceId | string | Yes | The ID of the workspace. | llm-xxxx |
Request parameters
Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| body | object | No | The request body. | |
| docIdList | array | No | A list of document IDs. | |
string | No | A document ID. | 1273827636xxx | |
| enableFollowUp | boolean | No | Specifies whether to enable multi-turn enhancement. | false |
| enableMultiQuery | boolean | No | Specifies whether to enable query splitting. | false |
| enableOpenQa | boolean | No | Specifies whether to enable openQA. | false |
| followUpLlm | string | No | The Large Language Model (LLM) used for multi-turn query enhancement. | qwen-max |
| libraryId | string | Yes | The ID of the document library. | 3akzl28vap |
| llmType | string | Yes | The type of the LLM. | qwen-max |
| multiQueryLlm | string | No | The LLM used for query splitting. | qwen-max |
| query | string | Yes | The query entered by the user. | How is the weather in Beijing these two days |
| queryCriteria | object | No | The property filter. | |
| and | array<object> | No | The `and` expression, used to filter documents or document chunks. | |
object | No | The content of the `and` expression. | ||
| boost | number | No | The weight of the tag. A value less than 1 decreases the weight of the corresponding keyword. A value greater than 1 increases the weight. | 0.5 |
| key | string | No | The key of the tag. | city |
| operator | string | No | The operator for the tag. It specifies the relationship between the metadata key's stored value and your input value.
| eq |
| value | string | No | The value of the tag. | Beijing |
| or | array<object> | No | The `or` expression, used to filter documents or document chunks. | |
object | No | The content of the `or` expression. | ||
| boost | number | No | The weight of the tag. A value less than 1 decreases the weight of the corresponding keyword. A value greater than 1 increases the weight. | 0.5 |
| key | string | No | The key of the tag. | city |
| operator | string | No | The operator for the tag. It specifies the relationship between the metadata key's stored value and your input value.
| eq |
| value | string | No | The value of the tag. | Beijing |
| rerankType | string | No | The type of the sort policy. Valid values: `linear` and `model`. `linear`: rule-based sorting. `model`: model-based sorting (LLM). | linear |
| sessionId | string | No | The session ID. | null |
| stream | boolean | No | Specifies whether to use streaming or non-streaming mode. | false |
| subQueryList | array | No | A list of subqueries. | |
string | No | A subquery. | How is the recent temperature in Beijing? | |
| textSearchParameter | object | No | Search engine parameters: text search parameters. | |
| limit | integer | No | The number of rows to return. | 10 |
| searchAnalyzerType | string | No | The search tokenizer. Valid values: `Standard`, `IkMaxWord`, and `IkSmart`. Configure this parameter as needed. If left empty, the tokenizer attached to the document library is used. | IkMaxWord |
| topK | integer | No | The final number of retrieved corpus entries. | 1 |
| vectorSearchParameter | object | No | Search engine parameters: vector search parameters. | |
| limit | integer | No | The number of rows to return. | 10 |
| withDocumentReference | boolean | No | Specifies whether to return document references. | false |
Response elements
Element | Type | Description | Example |
|---|---|---|---|
object | ResultCode | ||
| cost | integer | The time consumed. | null |
| data | any | The response data (non-streaming). | { "finish":true, "text":"Yes, the validity period of a registered prepaid card must be no less than 3 years.", "message": "Yes, the validity period of a registered prepaid card must be no less than 3 years.", "queryResult":{ "errCode": "0", //Error code at the API protocol level. Normally 0. Changes when unauthorized, parameter error, or server exception occurs. Can be ignored. "message": "ok", //Message at the API protocol level "data":{ "success": true, //true if there is an answer, false if not "answer": null, //Answer generated by the LLM "embeddingElapsedMs": 127, "vectorSearchElapsedMs": 2745, "llmElapsedMs": 7911, "totalElapsedMs": 10820, "chunks": [ //Retrieved chunk information, generally top5 or top10. Contact us to tune the effect. { "chunkId": "470182177892469799", //Chunk information number "docId": "22666332", //Document number associated with the chunk "chunkText": "Profits plummeted in the first quarter, can't you bear it? In fact, previous rounds of price cuts have indeed had a certain impact on Tesla's financial data. Tesla has just released its financial report for the first quarter of this year. The data shows that in Q1 2023, Tesla achieved revenue of 23.33 billion US dollars, an increase of 24% over the previous year; Tesla delivered more than 422,000 electric vehicles worldwide in the first quarter, an increase of 36% over the previous year", //Original news content "chunkMeta": { // Other metadata in the demo data "language": "en", "unique_id": "news_22666332_13", "content_type": "news", "stock_id_list": [] } }], "documents": [{ "docId": "1686637056086872065", //Document number "gmtCreate": "2023-08-02 15:16:25", //Document creation time "libraryId": "a1b2c3", //Knowledge base number associated with the document "title": "2023 ICBC Credit Card WeChat and JD Card-Binding Consumption Accumulated Points Activity", //Document title "url": null //Document link, if any }] //Document associated with the chunk text }, "success": true //Success/failure status at the API protocol level. true means errCode is 0 } } |
| dataType | string | The data type. | null |
| errCode | string | The error code. | 0 |
| message | string | The error message. | ok |
| requestId | string | The request ID. | 5E3FBAF1-17AF-53B7-AF0A-CDCEEB6DE658 |
| success | boolean | Indicates whether the request was successful. | true |
| time | string | The timestamp. | 2024-04-24 11:54:34 |
Streaming response description
Result rewritten based on conversation history
Query decomposition
Retrieval results
Model summary result
Examples
Success response
JSON format