Knowledge Base - External API
Knowledge Base - External API
Version history
Document version | Description | SDK version | Time |
v2.11.0 | Added APIs for listing knowledge bases, uploading documents, and querying documents. |
1. Interface definitions
1. Query a list of knowledge bases
ListKnowledgeBase
Request parameters
Field name | Description | Default value | |
pageNumber | The page number for paging. | 1 | |
pageSize | The number of entries per page. | 10 | |
knowledgeBaseId | The ID of the knowledge base to filter by. This parameter is optional. |
Response parameters
Field name | Description | |
requestId | The request ID. | |
total | The total number of knowledge bases. | |
knowledgeBases[] | The knowledge base information. | |
name | Student coach: The customer simulated by the agent. | |
description | The message content. | |
industry | The industry of the knowledge base. Car: car CulturalTour: Culture and tourism Garment: Sports and outdoors Internet: Internet tools Education: Education Medical: Medicine Retail: Retail Restaurant: Dining Common: General | |
id | The knowledge base ID. | |
knowledgeBaseType | The type of knowledge base. Panxi: Panxi Intelligent Creation Bailian: Alibaba Cloud Model Studio |
2. Batch add documents
2.1. BatchAddDocument
Request parameters
Field name | Description | |
knowledgeBaseId | The knowledge base ID. | |
addDocumentInfos[] | The information of the documents to be added. | |
name | The document name. The maximum length is 64 characters. | |
documentType | The document type. Enumeration values: pdf, txt, md, doc, docx, ppt, pptx, xls, xlsx. | |
url | The download URL of the document, which must be accessible over the public network. |
Response parameters
Field name | Description | |
requestId | The request ID. | |
addDocumentResults[] | A list of results for the added documents. | |
docName | The document name. | |
success | Indicates whether the document was uploaded successfully. | |
errorMessage | The reason why the document upload failed. | |
documentInfo | The document information. | |
docName | The document name. | |
id | The document ID. | |
processStatus | The document parsing status. Processing: Parsing Success: Parsing complete Failed: Parsing failed | |
documentType | The document type. txt/md/pdf/doc/docx/ppt/pptx/xls/xlsx |
3. Query document status
3.1. DescribeDocument
Request parameters
Field name | Description | |
knowledgeBaseId | The knowledge base ID. | |
documentId | The document ID. |
Response parameters
Field name | Description | |
requestId | The request ID. | |
documentInfo | The document information. | |
docName | The document name. | |
id | The document ID. | |
processStatus | The document parsing status. Processing: Parsing Success: Parsing complete Failed: Parsing failed | |
documentType | The document type. txt/md/pdf/doc/docx/ppt/pptx/xls/xlsx |
2. SDK
Java
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>intelligentcreation20240313</artifactId>
<version>SDK version</version>
</dependency>3. Development reference
Java SDK API calls
package org.example;
import com.alibaba.fastjson.JSON;
import com.aliyun.intelligentcreation20240313.Client;
import com.aliyun.intelligentcreation20240313.models.ListAICoachTaskPageRequest;
import com.aliyun.intelligentcreation20240313.models.ListAICoachTaskPageResponse;
import com.aliyun.intelligentcreation20240313.models.ListAICoachTaskPageResponseBody;
import com.aliyun.tea.TeaException;
import com.aliyun.teaopenapi.models.Config;
import java.util.List;
public class Test {
static String endpoint = "intelligentcreation.cn-zhangjiakou.aliyuncs.com";
/**
* Create a client.
*/
static Client client;
static {
// Initialize the configuration.
try {
Config config = new Config()
// Replace with your AccessKey ID and AccessKey secret.
.setAccessKeyId("Your Alibaba Cloud AccessKey ID")
.setAccessKeySecret("Your Alibaba Cloud AccessKey secret")
.setEndpoint(endpoint);
client = new Client(config);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
String studentId = "student_id";
// The request object. The class name is <APIName>Request.
ListAICoachTaskPageRequest request = new ListAICoachTaskPageRequest();
request.setStudentId(studentId);
try {
// The response object. The class name is <APIName>Response.
// The client method. The method name is <APIName>.
ListAICoachTaskPageResponse response = client.listAICoachTaskPage(request);
List<ListAICoachTaskPageResponseBody.ListAICoachTaskPageResponseBodyTaskList> taskList
= response.getBody().getTaskList();
System.out.println("taskList:" + JSON.toJSONString(taskList));
} catch (TeaException teaException) {
// If the API call fails, get the error message from message and data.
System.out.println("TeaException," + teaException.getMessage() + ",data:" + JSON.toJSONString(teaException.getData()));
teaException.printStackTrace();
} catch (Exception e) {
// An exception occurred when calling the API.
e.printStackTrace();
}
}
}