Enable a knowledge base as a context for code completion so Lingma can use internal company documents and files, to generates code suggestions that better fit the company's needs.
Who can use this feature?
Editions: Lingma Enterprise Dedicated
Roles: Lingma admins and global admins in an organization
You can add or remove code repository archives in a knowledge base. You can also enable or disable knowledge base as context for code completion on the Knowledge Base page of the Lingma console.
Manage a knowledge base
You can manage a knowledge base and its access controls. For example, you can:
Create, edit, or remove a knowledge base.
Add or remove enterprise members.
Add or remove code repository archives.
Create, edit, and delete a knowledge base
Create a knowledge base
Click Knowledge Base in the left-side navigation pane to go to the Knowledge Base page.
Click Create Knowledge Base.
In the dialog box that appears, do the following:
Set the Scenarios parameter to Code Completion.
Enter a name for the knowledge base. Pick a name that is easy to recognize.
(Optional) Write a description that tells what the knowledge base is about.
Choose who can access the knowledge base under Access Control. By default, it's set to Private - Any member in this knowledge base.
Click OK to save the information.
After the knowledge base is created, it appears in the list.
Edit a knowledge base
You can change the basic information of a knowledge base, such as the name, description, and access control by using the following methods:
On the list page: Find the knowledge base that you want to edit from the list and click Edit in the Actions column to enter the edit mode.
On the detail page: Select a knowledge base that you want to edit on the Knowledge Base page and click Edit in the upper-right corner of the page.
Delete a knowledge base
On the Knowledge Base page, click the knowledge base that you want to edit. click Delete Knowledge Base in the upper-right corner of the page. In the dialog box that appears, enter the name of the knowledge base to confirm its deletion.
Once deleted, a knowledge base cannot be restored. Proceed with caution. Re-create a knowledge base and populate data if needed.
Add a code repository
Here's how Lingma to add data to the knowledge base:
Select a knowledge base from the list to enter the details page.
Click Add Data.
If the data type is
code
, click or drag a file into the Add File area (gray area) to upload a code repository archive.Take note of the following tips:
Upload one code repository archive at a time.
Supported file formats: zip, gz, and tar.gz.
The file size cannot exceed 100 MB.
The file name cannot exceed 200 characters in length, and only UTF-8 and GBK file encodings are supported.
To avoid missing information during information retrieval, we recommend using a hierarchical and structured code repository.
After the code repository archive is uploaded, click Add to enter the data processing mode.
To improve the quality of code completion, use common second-party source code and libraries instead of your own business code package.
Enable or disable knowledge base as context for code completion
After the data is processed, you can enable the knowledge base as context for code completion using the following methods:
Enable on the Knowledge Base list page: Find the knowledge base that you want to configure and click Toggle.
Enable on the details page: On the details page of the knowledge base that you want to configure, in the upper-right corner of the console, click Toggle.
After you enable the feature, when authorized developers code in the IDE, Lingma will generate code suggestions based on the uploaded code repository archive.
Sample scenario
In most cases, the front-end team follows a unified coding standard. For example, the following code snippet explains what is bad and what is good in ReactJS development. It helps developers write Props clearly and avoid mistakes.
import React from 'react'
type Props = {
children:React.ReactNode;
}
// bad
const Index = (props: Props)=> {
return <>{props.children}</>
}
// bad
const Index<Props>=({ children }) => {
return <>{children}</>
}
// good
const Index: React.FC<Props> = (props) => {
return <>{props.children}</>
}
Here are the steps to use the team's coding standards for code completion::
The Lingma admin uploads a code repository archive that follows the coding standard, like Ant Design. Ant Design is a model of UI design that follows strict React component design standards.
Enable knowledge base as context for code completion.
Front-end developers in the team install and activate the Lingma plugin.
When front-end developers code in an IDE, Lingma generates code suggestions based on the coding standards in the uploaded code archive, as shown in the following figure:
Access control
Lingma admins and global admins in an organization can change the access control for a knowledge base using either of the following methods:
Go to the edit mode of the knowledge base and change the access control settings.
Go to the knowledge base page, click Access Control, and add or remove the members.
When you enable the knowledge base as context for code completion feature, developers can start code completion using #teamDocs
in an IDE environment. Lingma will generate code suggestions based on the knowledge base data for authorized developers.
Check the processing progress of the code repository archive
After the code repository archive is uploaded, the system stores the data in a vector format. This makes sure the data works with is the knowledge base as context for code completion feature. You can see the progress in the code repository list.
Here are the data processing statuses:
Awaiting Processing: The uploaded files are processed based on a specific order, and files that are pending processing enter a queued state.
Processing: The files are being analyzed and vectorized.
Completed: The file is parsed and stored as a vector.
Error: An error occurs during file processing. You can hover over the status icon to view the reason for the error. You can choose to reprocess or delete the files with errors based on different conditions.
Duplicated Files: The file content is duplicated and won't be reprocessed. You can delete the duplicate files.
Update a code repository
To update a code repository, click Add Data to upload a new version. After you upload the new code repository archive, the system will reprocesses the data.
Delete a code repository
To handle exceptions, duplicates, or unneeded code repositories, click Delete in the Actions column to remove a single code repository. For batch deletion, select the checkboxes next to the code repository archive in the list, and click Batch Remove in the upper-left corner of the console.