User contribution: This AI coding tool CodeFuse is amazing

This article is a user contribution and the content represents only the author's views.

Author : Cang He, former senior Java engineer at Dachang, expert blogger at Alibaba Cloud, CSDN 2023 Rising Star, civil engineering transcoding, current department technology leader, focusing on sharing Internet technology and workplace experience.

 

Hello everyone, I am Cang He. In the AI ​​era, many amazing product tools will appear rapidly. These efficiency tools have promoted the progress of science and technology to a large extent. Especially in the field of programming, various tools are emerging in endlessly. From GitHub Copilot to CodeGeeX to Tongyi Lingma, many tools are constantly emerging. Today, I want to share with you an excellent programming aid that I recently discovered - CodeFuse. 

 

1. What is CodeFuse

CodeFuse is a coding assistant similar to GitHub Copilot. It is a large code model that Ant Group has fine-tuned based on its self-developed basic large model.

CodeFuse has code completion, adding comments, interpreting code, generating unit tests, and code optimization functions to help developers write code faster and easier.

We know that installing GitHub Copilot in IntelliJ IDEA cannot summon the chat function. This function is still in the testing stage, but CodeFuse can directly summon the chat function and explain the code well.

 

2. CodeFuse download and installation

Currently, CodeFuse is still in the internal testing stage, and Cang He has also obtained the qualification for internal testing. Those who have not yet applied can apply directly: apply directly on the CodeFuse official website, fill in the relevant information and wait for review. The general review cycle is 1-3 days.

Apply for closed beta

After applying, you can download the plug-in directly after receiving the qualification for internal testing.

Because it is still in the internal testing stage, it has not yet been launched in the plug-in market, and it cannot be directly searched in the plug-in application market.

Download plugin

Let’s take IntelliJ IDEA as an example. Click Download Plug-in to download it.

Download idea plug-in

local storage

Then open idea and select the plug-in you just downloaded to install:

idea plug-in installation

After the installation is complete, restart idea:

The installation is complete

You can see that my idea has installed GitHub Copilot, CodeGeeX, and Tongyi Lingma. In order to compare with other plug-ins, in the code completion part, only one plug-in is enabled at a time to ensure that the experiment is objective and true.

 

After installation, you can set whether to perform code completion by default:

Set up code completion

You need to log in later. After you click on the sidebar to log in, you can set shortcut keys, etc.

Login completed

 

3. CodeFuse functions and comparative evaluation

1. Code completion

Like all other coding assistants, code completion is the most basic core capability. In order to ensure the objectivity and authenticity of the experiment, we adopt the single completion method. We first turn off the code completion of other plug-ins.

Turn off GitHub Copilot code completion:

Turn off GitHub copilot code completion

Turn off Tongyi Lingma code completion:

Turn off Tongyi Lingma code completion

Turn off CodeGeeX code completion:

Turn off CodeGeeX code completion

At this time, code completion is only enabled by CodeFuse. We first create an empty class, write nothing, and just press newline to see:

Default completion for blank classes

We can see that there are Chinese shortcut key friendly prompts after the prompt code:

Friendly tips for shortcut keys

Press the Tab key to use the prompt encoding. CodeFuse does not directly complete the main method, but only completes the core line, missing the other parenthesis of the method. Compared with GitHub copilot, I think this is more in line with programmers' coding habits and the default line break completion method that is in line with the idea. In the idea, after writing the left bracket of a method, press Newline to directly complete the right bracket, and we really only need it to generate a single line.

CodeFuse single line completion

CodeFuse single-line completion prompts

At this time, we turn on GitHub Copilot code completion and turn off all other plug-in code completion. You can see that GitHub Copilot directly prompts a complete main method and outputs a default statement. I personally think it is a burden in some scenarios. CodeFuse prompts for the next sentence when breaking a line, which I think is more friendly.

GitHub Copilot starting completion

The single-line code completion model is faster than GitHub Copilot. This may be because the large model that GitHub Copilot's remote model relies on is openai.

Single line code completion

For multi-line code , you can also complete it. You can directly write a comment and directly generate a method. In CodeFuse, there is a complete distinction between single-line code completion and multi-line code completion.

Generate random numbers from 0 to 10, which must not be prime numbers.

 

2. Explain the code

explain code

Right-click on the selected code or click /explain directly in the sidebar. Because the chat function is currently unavailable in GitHub Copilot, this sidebar showing the explanation code is still very useful.

Click /explain to explain the code

 

3. Generate comments

Generating comments is also generated by right-clicking on the code that needs comments. But sometimes it is not very sensitive. After reading the official instructions, it seems that the generation of method functions is more perfect.

Note : Currently, the model's annotation generation function has relatively complete support for the entire function level, so it is recommended that you give priority to generating annotations at the function level.

Generate code comments

Here I suggest that the product can learn the interaction of Tongyi Lingma and operate it directly in the method. The cost of right-clicking is still a bit high.

Tongyiling code generation comment method

 

4. Generate one side

Similarly, for code that needs to be generated on one side, right-click "Generate One Side" to see the one side generated by CodeFuse in the right column. It is very convenient to directly insert the one side code into the test class.

CodeFuse generates one-sided

 

5. Code optimization

Right-click the code that needs to be optimized, and you can see the optimization suggestions generated by CodeFuse for us.
Let him optimize this code:

@Before
public void before() {
    //可以为null
    Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 7890));
    HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor(new OpenAILogger());
    httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    v2 = OpenAiClient.builder()
    .apiKey("xxxxx")
    .connectTimeout(50)
    .writeTimeout(50)
    .readTimeout(50)
    .interceptor(Arrays.asList(httpLoggingInterceptor))
    .proxy(proxy)
    .apiHost("https://api.openai.com/")
    .build();
}

 

CodeFuse generates optimization suggestions

You can choose to directly generate code according to the optimization suggestions:

Optimization suggestions directly generate code

You can directly replace the original code, or copy the code. The best thing is to compare the before and after code to see what CodeFuse has changed for us. It is very intuitive.

Let’s see what CodeFuse has changed for us.

Generated optimized code:

@Before
    public void before() {
        // 可以为 null
        Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 7890));
        HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor(new OpenAILogger());
        httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        String apiKey = "xxx";
        int connectTimeout = 50;
        int writeTimeout = 50;
        int readTimeout = 50;
        String apiHost = "https://api.openai.com/";
        v2 = OpenAiClient.builder()
                .apiKey(apiKey)
                .connectTimeout(connectTimeout)
                .writeTimeout(writeTimeout)
                .readTimeout(readTimeout)
                .interceptor(Arrays.asList(httpLoggingInterceptor))
                .proxy(proxy)
                .apiHost(apiHost)
                .build();
    }

Currently, this feature of GitHub Copilot cannot be used in ideas.

Features not available with GitHub Copilot

Based on large model code understanding capabilities and static source code analysis capabilities, CodeFuse supports analysis and understanding of selected code fragments, puts forward optimization and improvement suggestions, and can also directly form code patches based on improvement suggestions, which can help us write better code. .

4. Summary

Although CodeFuse is still in the internal testing stage, the test results are still amazing, especially the code UI style and interaction of the sidebar and the support for custom configuration are relatively friendly.

In this era driven by innovation, the emergence of tools such as CodeFuse not only accelerates the development process of programming projects, but also brings new possibilities to the programming world. For developers who aspire to stay ahead of the curve in technology, CodeFuse is undoubtedly a valuable resource worth trying and exploring in depth.

MySQL 5.7, Moqu, Li Tiaotiao... Taking stock of the (open source) projects and websites that will be "suspended" in 2023. Kingsoft WPS crashed . Linux's Rust experiment was successful. Can Firefox seize the opportunity... 10 predictions about open source The middle school purchased an "intelligent interactive catharsis device" - which is actually a shell for the Nintendo Wii. "Ruiping", the father of Redis, LLM programming: omniscient and omnipotent&& Stupid The "post-open source" era has arrived: the license has expired and cannot serve the general public. Vim 9.1 is released , dedicated to Bram Moolenaar 2024 "New Year's Battle" in the front-end circle: React digs holes but does not fill them, must it rely on documentation to fill them? China Unicom Broadband suddenly limited the upload speed, and a large number of users complained. Niklaus Wirth, the father of Pascal, passed away.
{{o.name}}
{{m.name}}

Guess you like

Origin my.oschina.net/u/6942768/blog/10560465