Definitions
Offline Documentation: Offline documentation mainly refers to the Documents and Q&A under Knowledge Management in the Intelligent Agent development platform.
Real-time Documents: Real-time documents mainly refer to the upload of documents in the conversation interface.
Operations
Offline file upload requires three steps [the first two are also applicable to real-time documentation]:
2. Obtain temporary key and upload to COS via the COS SDK. 3. Call the SaveDoc API to store the basic information of the file in the Intelligent Agent development platform, as shown below: 1. Obtain Temporary Key
1.1 Add the FileType request parameter. FileType is the file name suffix as normal, such as xlsx, pdf, docx, png.
Fill in the FileType field, the obtained key has only upload permission, and the return parameters use UploadPath.
If the FileType field is not filled in, the obtained key only has download permission.
TypeKey distinguishes between offline files and real-time files.
BotBizID is a required field.
Each file upload needs to obtain a different temporary key, and the temporary key has a validity period.
Note:
Note that TypeKey values should not be mixed: "offline" applies to offline document uploads, while "realtime" applies to real-time document uploads; defaults to "offline" when empty.
1.2 Request parameters add IsPublic (case-sensitive for public or private scenarios)
Example:
Public scenario: /public/12332323/21321321321/image/1.png
Private scenario: /corp/12332323/12332323/doc/1.pdf
Note:
IsPublic is used to select the scenario when files or images are uploaded. For offline document uploads, IsPublic is false. For real-time document uploads, if the file is an image, IsPublic is true; for other file types, IsPublic is false.
The following parameters returned by the API are used in subsequent steps.
|
Bucket | Bucket location [Offline Documentation and real-time documents differ here] |
TmpSecretId | Temporary secretID |
TmpSecretKey | Temporary secretKey |
Token | token for uploading |
UploadPath | Used in next steps, in conjunction with upload to cos |
API response example:
{
"code": 0,
"data": {
"Response": {
"Bucket": "qidian-qbot-test-1251316161",
"CorpUin": "0",
"Credentials": {
"TmpSecretId": "*******************************",
"TmpSecretKey": "*******************************",
"Token": "*******************************"
},
"ExpiredTime": 1722234043,
"FilePath": "",
"ImagePath": "",
"Region": "ap-jakarta",
"RequestId": "771ca2ee-03a7-487f-b77e-ccbb240f3cb8",
"StartTime": 1722233443,
"Type": "cos",
"UploadPath": "/corp/17468272416xxxxxxxxxx6.txt"
}
},
"message": "OK",
"reqId": "749c46ae-8070-457f-84be-5d0daa5cce05"
}
2. Call the cos storage interface provided by Tencent Cloud to store files in the Intelligent Agent development platform cos
Note:
1. The TmpSecretId, TmpSecretKey, Token, and UploadPath from Step 1 are required.
2. File upload to cos[putObject] cannot directly copy code from API-Explorer. The following two have code differences when files are uploaded via code. For details, refer to the following code example (demo): API-Explorer uses fixed secret keys.
Upload via code uses temporary secret keys.
3. Note that the corresponding key for COS API upload is the UploadPath returned by obtaining temporary secret keys.
3. Call SaveDoc to Save Metadata
Important field description. For other fields, see API document.
|
IsRefer | When true, during the dialogue on the client-side, matching knowledge will provide related URLs, effect as follows: |
CosUrl | uploadPath obtained in step 1 |
CosHash | Step 2 back in "X-Cos-Hash-Crc64ecma" |
Etag | "Etag" in the header returned in step 2 |
Opt | Document operation type: 1: Batch import (Batch import of Q&A pairs) 2: file import (standard import of a single document) When the value is 1 and an Excel file is imported, it will verify whether the Excel header meets expectations. |
Open external link hit knowledge effect: