Skip to main content

knowledge base

What is a knowledge base

A knowledge base refers to a database or knowledge graph that stores and organizes large amounts of structured or unstructured information. These knowledge bases contain various types of information, such as facts, concepts, relationships, rules, etc., used to help AI systems understand the world, answer questions, make decisions, and perform other tasks.

Knowledge bases play an important role in AI. They can be specifically built for a particular domain or task, or they can be general knowledge bases. Some examples of knowledge bases include:

  • Linguistic knowledge base: Contains information such as vocabulary, grammatical rules, and semantic relationships to help AI systems understand and generate natural language.
  • Domain-specific knowledge bases: Contain professional knowledge in specific fields, such as medical knowledge bases, financial knowledge bases, etc., used to support intelligent applications in related domains.
  • Common Sense Knowledge Base: Contains common sense information from daily life to help AI systems make logical reasoning and decisions.

The establishment and maintenance of knowledge bases typically require substantial manual effort and professional expertise, but once completed, they can serve as a vital resource for AI systems, providing Agents with rich background knowledge and information support, thereby enhancing the system's intelligence level and application capabilities.

How to build a knowledge base

Go to AI+

  1. Go to TCB AI+
  2. Agent Creation: Create an Agent Instance

Create a knowledge base

By creating a knowledge base and uploading collected relevant information, you can build a private knowledge base and connect it to the Agent, enabling the provision of usable information to the Agent and assisting it in performing more effective reasoning.

Go to the corresponding Agent configuration page and click Knowledge Base

Go to the Knowledge Base Management page and click the Add button

Click New, fill in the Knowledge Base name and description

After saving, you can see the newly created knowledge base.

Upload Content

After creating a knowledge base, you can add knowledge to it by uploading files.

The currently supported file formats for upload are as follows:

  • Text content written in markdown format with the file extension .md
  • pdf files with the file extension .pdf
  • docx files with the file extension .docx

After files are uploaded, you can view the file information added in the knowledge base. After files are added, they undergo a parsing and processing phase. The content within the files can be searched by the Agent only after parsing and processing are completed.

Usage in Agent

const msg = "User question"
const knowledgeBase = ["Knowledge Base ID-1", "Knowledge Base ID-2"]
const result = await this.botContext.bot.tools.searchKnowledgeBase(
this.botContext.info.botId,
msg,
knowledgeBase
);

if (result?.code && result?.code?.length !== 0) {
throw new Error(`Failed to query knowledge base content: ${result?.message}`);
}

Test knowledge base query effectiveness

Ask questions via conversation:

You can enable the DeepSeek R1 model to verify that the returned content in the reasoning chain includes knowledge base information, confirming the test results are correct. Then proceed to create the Application Release by following the configuration-based AgentUI application solution.

API Call

Uploading Knowledge Base

Knowledge base document automation management can be enabled via APIs, supporting features such as creation, deletion, and batch operations.

View Documentation

Querying Knowledge Base

Here is an example of invoking the Knowledge Base HTTP API using cURL:

curl 'https://<your-envId>.api.tcloudbasegateway.com/v1/knowlege/send-message' \
-H 'Authorization: Bearer <your API Key>' \
-H 'Accept: text/event-stream' \
-H 'Content-Type: application/json' \
-d '{
"collectionView": "ykfty_6fWO",
"search": {
"content": "What are the latest new features of TCB AI?",
"limit": "5"
}
}'

Frequently Asked Questions

What file formats are supported by the knowledge base?

Currently supports file formats such as .md, .pdf, .docx, or .pptx.

What is the file size limitation for the knowledge base?

The maximum size for a single file is 100M, Markdown files are supported up to 10M, and a knowledge base supports multiple files.

Does the knowledge base support integration with articles from WeChat official accounts?

Temporarily not supported

Does the knowledge base support databases?

It has been supported, and you can integrate with data models through the Agent.

Structured data such as tables can serve as a knowledge base source through databases, while supporting data queries based on end-user permissions to prevent unauthorized data access.

Does the knowledge base support uploading Excel files?

Currently not supported, but it is under planning. You can convert Excel files to pdf or docx format for uploading. You may need to test whether the result meets expectations.

You can also create a data model to import data from Excel. Configure the data model in the Agent to query data through it, while supporting data queries based on end-user permissions to prevent unauthorized data access.