CodeGeeX: Installation, Deployment, Configuration, and Usage Guide 271

小编 ·

CodeGeeX: Installation, Deployment, Configuration, and Usage Guide

CodeGeeX is a free AI programming assistant that supports multiple languages. It helps developers quickly generate code, fix bugs, and translate code. This guide covers the installation, deployment, configuration, and usage of CodeGeeX.

CodeGeeX: Installation, Deployment, Configuration, and Usage Guide

CodeGeeX is a free AI programming assistant that supports multiple programming languages and helps developers quickly generate code, fix errors, and translate code. Below is a tutorial on how to install, deploy, configure, and use CodeGeeX.

CodeGeeX支持的主流IDE.webp

I. Core Features of CodeGeeX

  • Code generation and completion: Generates code snippets or completes code based on context.

  • Code comment generation: Automatically adds detailed comments to code.

  • Code explanation: Explains the functionality and logic of code.

  • Unit test writing: Automatically generates unit test code.

  • Code Review: Helps developers perform code reviews.

  • Bug fixing: Automatically fixes errors in code.

  • Git commit message generation: Helps developers quickly generate commit messages.

  • Code translation: Supports code translation between different programming languages.

  • Intelligent Q&A: Provides intelligent answers to technical and coding questions.

II. Programming Languages Supported by CodeGeeX

CodeGeeX supports over 100 programming languages, covering frontend, backend, mobile, and other development fields:

  • Frontend: Vue, JavaScript, TypeScript, HTML, CSS, React

  • Backend: C, C++, Java, Python, Go, PHP, Rust, SQL

  • Mobile: Objective-C, Kotlin, Swift, Uni-App

  • Others: Perl, Ruby, GraphQL, COBOL

III. Installing CodeGeeX

1. Install VS Code

CodeGeeX is provided as a VS Code plugin, so you need to install Visual Studio Code first.

2. Install the CodeGeeX Plugin

  1. Open VS Code.

  2. Click the Extensions icon on the left sidebar (or press the shortcut Ctrl+Shift+X).

  3. Type "CodeGeeX" in the search box to find the corresponding plugin.

  4. Click the [Install] button.

  5. After the installation is complete, VS Code will restart automatically.

安装 CodeGeeX 插件.webp

IV. Configuring CodeGeeX

1. Configure API Key (Optional)

If you are using CodeGeeX's online service, you need to configure an API Key (this step is not required if you are using the locally deployed version).

  1. Open VS Code's Settings (Ctrl+, or click the gear icon in the bottom left corner).

  2. Search for CodeGeeX to find the API Key configuration item.

  3. Enter your API Key (obtained from the CodeGeeX official platform).

2. Custom Settings

You can also adjust the following settings as needed:

  • Candidate Num: The number of code candidates to generate.

  • Prompt Templates: Customize the prompt templates for code generation.

  • Language: Set the default programming language.

V. Using CodeGeeX

CodeGeeX requires login to use.

Login Method

  1. Click the CodeGeeX icon on the left sidebar of VSCode to open the CodeGeeX sidebar.

  2. Click "Go to Login".

  3. VSCode will prompt whether to allow CodeGeeX to log in. Click "Allow".

  4. Click "Open" to bring up the browser.

  5. On the CodeGeeX login page opened in the browser, enter your email and password to log in.

  6. After successful login, return to VSCode and you can start using it.

CodeGeeX登录方法.webp

1. Stealth Mode (Recommended)

  • Open a code file (such as Python, Java, etc.).

  • Start writing code. When the cursor stops inputting, CodeGeeX will automatically generate code from the cursor position.

  • The generated code will be displayed in gray. Press the Tab key to insert the code.

2. Interactive Mode

  • After typing part of the code, press Ctrl+Enter.

  • CodeGeeX will generate multiple candidate codes and display them in the right-side window.

  • Click the "use code" button to insert the selected code.

3. Translation Mode

  1. Select a piece of code.

  2. Press the shortcut Ctrl+Alt+T or right-click and select CodeGeeX: Translate Code.

  3. CodeGeeX will translate the code into the target language (e.g., from Python to Java).

  4. Click the "use code" button above the translation result to insert the code.

4. Prompt Mode (Experimental Feature)

  1. Select code and press Alt+T.

  2. CodeGeeX will display a list of predefined templates.

  3. After selecting a template, CodeGeeX will generate code based on the template.

VI. Other Usage Methods

1. Code Comments

  • Select code, right-click and select CodeGeeX: Add Comment.

  • Or type /comment in the chat box and press Enter.

  • CodeGeeX will generate detailed comments for the code.

2. Code Fixing

  • Select code, type /fixbug in the chat box and press Enter.

  • CodeGeeX will attempt to fix errors in the code.

3. Unit Test Generation

  • Select code, type "generate unit tests" in the chat box.

  • CodeGeeX will generate the corresponding unit test code.

VII. Local Deployment Tutorial (Advanced Users)

If you need to use CodeGeeX offline, you can refer to its open-source code for local deployment:

1. Install Ollama

Ollama is an open-source project used to quickly run various open-source large models locally. The installation steps are as follows:

1.1 Install Ollama

MacOS and Windows: It is recommended to install Ollama 0.2 or higher. You can use a one-click installer.

MacOS: Install using the following command:

brew install ollama

Windows: Download the installer and run it.

inux: Use the following command to install:

curl -fsSL https://ollama.com/install.sh | sh

1.2 Verify the Installation

After the installation is complete, open the terminal and enter the following command:

ollama

If the installation is successful, you will see the relevant information about Ollama.

2. Download the CodeGeeX4-ALL-9B Model

  1. Open the Ollama official website.

  2. Type CodeGeeX4 in the search box.

  3. Find the details page for the CodeGeeX4-ALL-9B model.

  4. Copy the run command provided on the page, for example:

ollama pull codegeex4-all-9b

After running this command, the model will be automatically downloaded and loaded into Ollama. The terminal will prompt "Send a message", indicating that the model has been successfully loaded and you can start a conversation with the model directly.

3. Configure Environment Variables

To integrate the CodeGeeX4-ALL-9B model into the local mode of the CodeGeeX plugin, you need to set the environment variables:

3.1 Set the Environment Variable

MacOS and Linux:

export OLLAMA_ORIGINS="*"
launchctl setenv OLLAMA_ORIGINS "*"

Windows:

  1. Open "System Properties".

  2. Click "Environment Variables".

  3. In "System variables", create a new variable named OLLAMA_ORIGINS with the value *.

4. Install the CodeGeeX Plugin

  1. Open your IDE (such as VSCode or JetBrains IDE).

  2. Search for CodeGeeX in the plugin marketplace.

  3. Download and install the plugin.

5. Restart the Service and IDE

After setting the environment variables, you need to restart the Ollama service and the IDE for the configuration to take effect:

  • Restart the Ollama service:

ollama restart
  • Restart the IDE: Close and reopen your IDE.

6. Use the CodeGeeX Plugin

After the installation and configuration are complete, you can use the local mode of the CodeGeeX plugin in the IDE:

  1. Open a code file.

  2. Use CodeGeeX's features, such as code completion, intelligent Q&A, etc.

  3. If you need to switch to local mode, you can select local mode in the plugin settings.

The above is the tutorial on installing, locally deploying, configuring, and using CodeGeeX. If you encounter any issues during the deployment, you can refer to Ollama's official documentation or the CodeGeeX community.

Related: Latest 2025 Compilation: 20+ Best AI Programming Tools and AI Coding Assistants