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.
Debug
You can run this API directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After the API is successfully run, OpenAPI Explorer can automatically generate SDK code examples.
Debug
Authorization information
The following table describes the authorization information of this API. You can use it in the Action element of a RAM policy statement to grant a RAM user or RAM role the permission to call this API. Details:
- Operation: refers to a specific permission point.
- Access level: refers to the access level of each operation. Valid values: Write, Read, or List.
-
Resource type: refers to the resource types that support authorization for the operation. Details:
- Required resource types are marked with a leading asterisk (*).
- For operations that do not support resource-level authorization,
全部资源is used.
- Condition key: refers to the condition keys defined by the cloud product itself.
- Dependent operation: refers to other permissions required to successfully perform the operation. The caller must also have the permissions of the dependent operations for the operation to succeed.
| Operation | Access level | Resource type | Condition key | Dependent operation |
|---|---|---|---|---|
| dianjin:RunLibraryChatGeneration | none | *All resources * |
| None |
Request syntax
Request parameters
| Name | Type | Required | Description | Example |
|---|---|---|---|---|
| workspaceId | string | Yes | The workspace ID. | llm-xxxx |
| body | object | No | The request body. | |
| docIdList | array | No | A list of document IDs. | |
| docIdList | 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 LLM used for multi-turn query enhancement. | qwen-max |
| libraryId | string | Yes | The document library ID. | 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/document chunks. | |
| and | object | No | The content of the and expression. | |
| boost | float | No | The weight of the tag. When the value is less than 1, the weight of the corresponding keyword is reduced; conversely, when the value is greater than 1, the weight is increased. | 0.5 |
| key | string | No | The key of the tag. | city |
| operator | string | No | The operator of the tag: 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 tag. | Beijing |
| or | array<object> | No | The or expression, used to filter documents/document chunks. | |
| or | object | No | The content of the or expression. | |
| boost | float | No | The weight of the tag. When the value is less than 1, the weight of the corresponding keyword is reduced; conversely, when the value is greater than 1, the weight is increased. | 0.5 |
| key | string | No | The key of the tag. | city |
| operator | string | No | The operator of the tag: 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 tag. | Beijing |
| rerankType | string | No | The sort policy type: linear/model (linear: rule-based sorting, model: model-based sorting, llm) | linear |
| sessionId | string | No | sessionId | null |
| stream | boolean | No | Streaming/non-streaming | false |
| subQueryList | array | No | A list of subqueries. | |
| subQueryList | 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 (Standard, IkMaxWord, IkSmart). Configure it flexibly based on business needs. If left empty, the search tokenizer bound 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 parameters
| Name | Type | Description | Example |
|---|---|---|---|
| object | ResultCode | ||
| cost | long | 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 is 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