CodeArts Agent improves chat features using knowledge bases. Developers can add internal documents and technical resources to these bases for smarter responses. With company-specific information, AI provides precise answers tailored to real-world needs, boosting both development speed and decision quality.
Getting Started with Knowledge Bases
CodeArts Agent leverages knowledge bases primarily for unit test generation, code generation, and R&D Q&A, dramatically enhancing both accuracy and speed across these critical scenarios.
The following figure shows the process of how the tool processes user queries into answers visually. It includes important stages like retrieving data and making logical conclusions, making it easy for you to grasp how knowledge bases work.
Figure 1 How knowledge bases work
- To fulfill service needs, knowledge is organized into distinct types, such as general, domain-specific, or individual expertise.
- You can create a knowledge space to manage knowledge bases.
- To create a knowledge base, upload desired files. Then, choose a chunking method to break data source into manageable pieces. Each chunk is then transformed into a vector by an embedding model.
- CodeArts Agent may reference knowledge bases for more accurate retrieval and generation.
Learn these key concepts before using knowledge bases for quick setup.
Table 1 Basic concepts | Basic Concept | Description |
| Knowledge space | A knowledge space is a collection of knowledge formed after chunking, vectorizing, indexing user-uploaded data, and storing it in a database. It is categorized based on actual usage dimensions. A knowledge space itself does not store content; it is used solely for the centralized management of knowledge bases. |
| Knowledge base | A knowledge base organizes and stores different types of documents. These documents are categorized by their type and source for clear classification, making them easier to find and understand. |
| File | Files serve as the primary carrier of knowledge. To ingest them into a knowledge base for retrieval, configure a proper chunking strategy, select an embedding model, apply index filters, and define retrieval policies. |
| Chunk | Chunks refer to portions of a file. They are created when loading and splitting a file, serving as fundamental units for vectorization, storage, and recall. |
Constraints
File storage capacity limits vary across different versions of CodeArts Agent, as detailed below:
- Basic edition: up to 5 GB
- Professional edition: up to 20 GB
Prerequisites
- You have been assigned a seat. If not, you cannot create or manage a knowledge space.
- An enterprise administrator has joined a team, if they want to create a team knowledge base.
Accessing Knowledge Bases
Creating a Knowledge Base
- Create a knowledge space.
A knowledge space is used to manage multiple knowledge bases in one place. Before creating a knowledge base, you need to create a knowledge space.
- On the Knowledge page, click Create Space and set parameters by referring to Table 2.
Figure 2 Creating a knowledge space
Table 2 Parameters for creating a knowledge space | Parameter | Description |
| Name | Indicates the name of the knowledge space to be created. Naming rules: The name cannot start with an underscore (_) and can contain a maximum of 18 characters, including letters, digits, underscores (_), and hyphens (-). |
| Visible To | Controls the access permissions of members. - Private: available only to members themselves.
- Team: available only to team members and created by the enterprise administrator or team administrator.
- Enterprise: available to all enterprise members and created by the enterprise administrator.
|
| Teams | This parameter is displayed only when Visible To is set to Team. Select a team from the drop-down list; only the teams which the current account belongs to are displayed. |
| Tag | (Optional) Indicates the tags to be added to the knowledge space for content classification and management. A maximum of 10 tags can be selected. - If you have not created any tags yet, follow the operations below to create them. Otherwise, proceed to the next step.
Select Add from the drop-down list. In the displayed dialog box, enter a tag name containing a maximum of 32 characters and click OK. - Select the target tag.
|
| Description | (Optional) Indicates the description of the knowledge space. A maximum of 300 characters are allowed. A detailed description helps CodeArts Agent accurately understand the knowledge scope, improving retrieval and matching precision. |
- Click OK.
In the knowledge space list, you can view the created one.
- Create a knowledge base.
Create a knowledge base within a knowledge space and specify its type and source. This ensures a clear information structure and easy retrieval.
- Select your desired knowledge space from the list to view its detailed information.
- Click Create Knowledge Base in the upper right corner.
- Configure basic information by referring to Table 3.
Figure 3 Creating a knowledge base
Table 3 Basic parameters of a knowledge base | Parameter | Description |
| Name | Indicates the name of the knowledge base to be created. Naming rules: The name cannot start with an underscore (_) and can contain a maximum of 32 characters, including letters, digits, underscores (_), and hyphens (-). |
| Knowledge Type | Indicates the knowledge base type. You can select Unstructured or Structured. - Unstructured: Data does not have a fixed format.
- Structured: Data has fixed formats, fields, and structures.
|
| Data Source | Indicates the data source of the knowledge base. You can select Local file or Code. - When Knowledge Type is set to Unstructured, the following data sources are supported:
- Local file: The code base mainly contains textual content, such as articles, reports, and books. Supported formats include TXT, DOCX, PDF, MD, CSV, XLS, and XLSX.
- Code: Only ZIP packages containing Java, Python, C, C++, or Vue code files are supported.
- When Knowledge Type is set to Structured, only local JSON files are supported.
|
| Knowledge Description | (Optional) Indicates the description of the knowledge base content. A maximum of 300 characters are allowed. A detailed description helps guide the agent to call and utilize the knowledge base more accurately. |
- Click Next and complete the content import configuration by referring to Table 4.
Table 4 Content import configuration parameters | Parameter | Description |
| Embedding Model | Select an embedding model to vectorize the uploaded files/code. The following models are available. - bge-m3: a multilingual 1024-dimensional text embedding model that supports hybrid retrieval (dense, sparse, and multi-vector representation). It supports a maximum text length of 8,192 tokens, making it ideal for complex, multilingual scenarios.
- m3e-base: a general-purpose 768-dimensional embedding model for Chinese and English text, suitable for most basic semantic understanding and retrieval tasks.
- bge-large-zh-v1.5: a Chinese-specific model optimized for tasks such as retrieval, classification, clustering, and semantic matching.
- paraphrase-multilingual-MiniLM-L12-v2: a 364-dimensional multilingual embedding model that excels in text similarity calculations, ideal for speed-sensitive scenarios.
- VESO-v1.3: a specific model deeply optimized for code, delivering outstanding performance in code vectorization and search tasks.
|
| Splitter | This parameter is displayed when Knowledge Type is set to Unstructured and Data Source is set to Local file. The way your content is split depends on the splitter you choose. Different languages can use different splitters for optimal results. - By paragraph: Splits text by double line breaks (\n\n) or paragraph structure.
- By line: Splits text by single line breaks (\n).
- By sentence (for English): Splits text by sentence boundaries.
- By character: Splits text into individual characters (including whitespace characters).
|
| Chunk Length | This parameter is displayed when Knowledge Type is set to Unstructured and Data Source is set to Local file. Range: 50 to 1,200 characters. Default value: 1,000 characters. |
| Chunk Overlap | This parameter is displayed when Knowledge Type is set to Unstructured and Data Source is set to Local file. Overlap between sequential chunks: 0 to chunk length (default value: 0). |
| Child Splitter | This parameter is displayed when Knowledge Type is set to Unstructured and Data Source is set to Local file. Applied when a chunk exceeds the maximum allowed length. Currently, the following child splitters are supported: - By character: Splits text into individual characters (including whitespace characters).
- By sentence (for English): Splits text by sentence boundaries.
- By word (for English): Splits text by whitespace characters.
|
| Index Fields | This parameter is displayed when Knowledge Type is set to Structured. Enter the JSON keys to be used as index fields during retrieval. Up to 20 fields are supported, separated by English commas (,). |
| Filter Fields | This parameter is displayed when Knowledge Type is set to Structured. Enter the JSON keys to be used as filter criteria during retrieval. Up to 2 fields are supported, separated by English commas (,). |
| Indexed Field | This parameter is displayed when Data Source is set to Code. Select indexed fields to specify which data fields the system needs to build indexes for in advance. During retrieval, the agent will perform keyword matching only against these indexed fields. For example, if function body is selected as an indexed field, the agent will prioritize matching keywords within the function body section of the code when a user enters a search query. |
| Use Sliding Window | This parameter is displayed when Data Source is set to Code. Once enabled, complex functions are segmented into chunks to improve search accuracy. |
- Click OK.
In the knowledge base list, you can view the created one.
- Import files.
After creating a knowledge base, you can upload various local documents to it. Once uploaded, the system automatically cleans the data and builds indexes, ensuring that your imported content can be quickly retrieved and called for instant knowledge accumulation.
- Click the name of your desired knowledge base in the list to view its detailed information.
- Click Import File in the upper right corner.
- Select target code files or other files from the local and click OK to return to the knowledge base page.
Figure 4 Uploading code files or other files
You can upload code files or other files based on your required knowledge type. The maximum size for a single file or ZIP package is 20 MB, and the maximum capacity for a single knowledge base is 50 MB.
Table 5 Description for file importing | Knowledge Type | Data Source | Description |
| Unstructured | Local files | TXT, DOCX, PDF, MD, CSV, XLS, and XLSX files are supported. |
| Code | Only ZIP packages containing Java, Python, C, C++, or Vue code files are supported. |
| Structured | Local files | Only JSON files are supported. |
- View the import result.
When Ingestion Status changes from Uploading to Ingested, the file import is successful.
Referencing a Knowledge Base in the Context
- Log in to CodeArts Agent IDE as instructed in Quick Start.
- In the input box on the chat panel, enter #, or choose
> Add Context. Then choose Knowledge Bases. - In the knowledge base list, select the knowledge space (for example, the individual knowledge space) created in 1.
Figure 5 Selecting a knowledge space
- In the target knowledge space, select the knowledge base (for example, service introduction document) created in 3 and add it to the context.
- After the knowledge base is added, you can initiate a chat based on the knowledge base.
Managing Knowledge Bases
Table 6 shows the operation permissions of different roles on managing knowledge bases.
Table 6 Operation permissions of different roles on knowledge bases | Role | Enterprise Knowledge Base | Team Knowledge Base | User Knowledge Base |
| Enterprise administrators | All operations on all knowledge bases. | All operations on the knowledge bases of the team which the enterprise administrator belongs to. | All operations on the knowledge bases created by themselves. |
| Team administrators | The following operations can be performed: - Test hit rates of knowledge bases.
- View operation history on knowledge bases.
| All operations on knowledge bases created by members of their own team (including the team administrator). | All operations on the knowledge bases created by themselves. |
| Team members | The following operations can be performed: - Test hit rates of knowledge bases.
- View operation history on knowledge bases.
| The following operations can be performed on knowledge bases created by members of their own team (including the team administrator): - Test hit rates of knowledge bases.
- View operation history on knowledge bases.
| All operations on the knowledge bases created by themselves. |
| Enterprise members | The following operations can be performed: - Test hit rates of knowledge bases.
- View operation history on knowledge bases.
| No operation permissions. | All operations on the knowledge bases created by themselves. |
Table 7 Managing knowledge bases | Operation | Procedure |
| Editing a knowledge space | On the knowledge space page, click on the target knowledge space and choose Edit. |
| Deleting a knowledge space | Before deleting a knowledge space, you must clear all knowledge bases in the space. - On the knowledge space page, click
on the target knowledge space and choose Delete. The Delete Knowledge Space dialog box is displayed. - Click Autofill. The system automatically enters DELETE. Click OK to delete the knowledge space.
The target knowledge space has been removed from the knowledge space page, indicating that the deletion was successful. CAUTION: Deleting a knowledge space will delete all resources within it. Once confirmed, data cannot be recovered; make a backup before this operation. |
| Testing the hit rate of a knowledge base | The hit rate test is designed to run search queries against the knowledge base to verify the accuracy and relevance of retrieval results. - On the knowledge space page, click Hit Test in the upper right corner.
- Select up to 10 knowledge bases to be tested.
- Select the field to be retrieved from the drop-down list.
- Select a retrieval mode.
- Text: Based on keyword matching; best suited for exact-word matches and short queries.
- Vector: Based on semantic similarity; understanding context and synonyms, making it ideal for natural language queries.
- Hybrid: Combining text and vector retrieval, using weighted fusion of both results. This generally yields better performance, especially for complex semantic queries.
- Enter the content you want to search (maximum 1,000 characters).
- Set the number of returned results.
- Click Debug. You can view the final results under Chunks.
|
| Deleting a knowledge base | When content is severely outdated and holds no retention value, or contains critical errors where correction is too costly or impossible, follow the steps below to delete the knowledge base. - On the knowledge space page, click the knowledge space where the target knowledge base is located to view its details.
- Locate the row that contains the target knowledge base, and click Delete. The Delete Knowledge Base dialog box is displayed.
- Click Autofill. The system automatically enters DELETE. Click OK to delete the knowledge base.
The target knowledge base has been removed from the knowledge space details page, indicating that the deletion was successful. CAUTION: Deleting a knowledge base will delete all data within it. The deleted data cannot be recovered. Ensure that you have backed up important data before this operation. |
| Batch deleting knowledge bases | Deleting knowledge bases one by one manually is inefficient; you can batch delete knowledge bases through the following steps: - On the knowledge space page, click the knowledge space where the target knowledge base is located to view its details.
- Click Batch Delete in the upper right corner and select the target knowledge bases.
- Click Delete. The Batch Delete Knowledge Bases dialog box is displayed.
- Click Autofill. The system automatically enters DELETE. Click OK to delete the knowledge bases.
The target knowledge bases have been removed from the knowledge space details page, indicating that the deletion was successful. CAUTION: Deleting a knowledge base will delete all data within it. The deleted data cannot be recovered. Ensure that you have backed up important data before this operation. |
| Viewing operation history on knowledge bases | - On the knowledge space page, click the knowledge space where the target knowledge base is located to view its details.
- Click History in the upper right corner to view the operation logs of all knowledge bases in the knowledge space.
|
| Re-importing a file | If file upload fails, check your network connection or file format, and click Reimport to try again. - On the knowledge space page, click the knowledge space where the target knowledge base is located to view its details.
- Click the name of the target knowledge base to view its details.
- Click Reimport in the upper right corner and view the import result.
|
| Deleting a file | When dealing with a small number of files, deleting them one by one is more intuitive and flexible, making it easier to locate and clear specific content. - On the knowledge space page, click the knowledge space where the target knowledge base is located to view its details.
- Click the name of the target knowledge base to view its details.
- Click Delete next to the target file. The Delete File dialog box is displayed.
- Click Autofill. The system automatically enters DELETE. Click OK to delete the file.
The target file has been removed from the knowledge base details page, indicating that the deletion was successful. CAUTION: Deleted files will be permanently cleared and cannot be recovered. Ensure that you have backed up important data before this operation. |
| Batch deleting files | Deleting many files one by one manually is inefficient; you can also batch delete files using the following steps: This is ideal for scenarios such as knowledge base restructuring, version iterations, and deduplication, helping you keep your knowledge base organized. - On the knowledge space page, click the knowledge space where the target knowledge base is located to view its details.
- Click the name of the target knowledge base to view its details.
- Click Batch Delete in the upper right corner and select the target files.
- Click Delete. The Batch Delete Files dialog box is displayed.
- Click Autofill. The system automatically enters DELETE. Click OK to delete the files.
The target files have been removed from the knowledge base details page, indicating that the deletion was successful. CAUTION: Deleted files will be permanently cleared and cannot be recovered. Ensure that you have backed up important data before this operation. |