Skip to content

IBM watsonx Code Assistant simplifies and accelerates coding workflows across Python, Java, C, C++, Go, JavaScript, Typescript, and more. It leverages the Granite model to augment programmer skill sets, simplifying and automating coding and modernization efforts.

License

Notifications You must be signed in to change notification settings

IBM/watsonx-code-assistant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License

  • The license for IBM watsonx Code Assistant can be found in the product-licenses folder in this repository.

  • You can use this repository to add issues for watsonx Code Assistant. The license for issues, discussion, and any files or samples shared in issues can be found in the LICENSE file.

IBM® watsonx™ Code Assistant

IBM® watsonx™ Code Assistant is an innovative, generative AI coding companion that offers robust, contextually aware assistance for popular programming languages including Go, C, C++, Java, JavaScript, Python, TypeScript, and more. Seamlessly integrated into your IDE, you can accelerate your productivity and simplify coding tasks, all with trust, security, and compliance.

Features

Get code suggestions

Use chat conversations: Use natural language prompts to generate code suggestions. Use a chat conversation to enter a prompt that explains the code you need, and watsonx Code Assistant generates something you can choose to use.

Use a chat conversation in IBM watsonx Code Assistant

Reference code: To ask questions or refine a specific file, class, function, or method in your workspace, you can use a code reference. These references provide important context and can help to increase the accuracy of the answer. As part of your chat message, type the @ symbol to see a list of files, classes, and methods from your workspace. Click to select the reference, and watsonx Code Assistant sends the contents of the reference as part of your message.

Reference code in IBM watsonx Code Assistant

Code completion: Or, complete code in the editor. Start typing a line of code, then pause. IBM watsonx Code Assistant adds a code suggestion to complete the line that you typed.

Single-line completion in IBM watsonx Code Assistant

You can also get a multiline code suggestion. Start typing a line of code, then use a keyboard shortcut, and watsonx Code Assistant adds a multiline code suggestion.

Multi-line completion in IBM watsonx Code Assistant

Or, enter a comment that describes the code you want.

Comment to code generation in IBM watsonx Code Assistant

For more information, see the documentation for Getting code suggestions.

Explain code

Use generative AI to analyze and summarize your code to understand what the code does. Click the Explain option that precedes a code block or enter /explain in a chat conversation. IBM watsonx Code Assistant analyzes the code and provides a detailed explanation of what the code does.

For more information, see the documentation for Explaining code.

Document code

Generate comment lines that document what your code does. Click the Document option that precedes a code block or enter /document in a chat conversation. IBM watsonx Code Assistant analyzes the code and adds comments that document what the code does.

For more information, see the documentation for Documenting code.

Generate unit tests

Create unit tests to evaluate your code functions. Click the Unit Test option that precedes a code block or enter /unit-test in a chat conversation. IBM watsonx Code Assistant analyzes the code and creates a unit test.

For more information, see the documentation for Generating unit tests.

Translate code from one language to another

Use watsonx Code Assistant to translate code. In a chat conversation, use the syntax translate [from <source language >] to <target_language> <code reference>

For more information, see the documentation for Translating code from one language to another.

IBM® watsonx™ Code Assistant for Enterprise Java Applications

For use with the Standard plan, IBM® watsonx™ Code Assistant for Enterprise Java Applications adds features for Java application upgrades and modernization, and enhanced code explanation and unit test generation.

Features

Java runtime modernization

Analyze your Java application runtime and modernize it to a more lightweight, flexible, and efficient runtime. Receive a prescriptive plan that describes the changes that are needed to modernize your application, with a detailed assessment of complexity and required development effort. Use automation to quickly implement code and configuration changes. Transform code with generative Al assistance to resolve more complex issues.

For more information, see the documentation for Modernizing Java applications.

Java version upgrade

Identify changes required to upgrade Java code, automatically apply fixes, and use generative AI to transform Java code. Receive a prescriptive plan that describes the changes that are needed to upgrade your application, with a detailed assessment of complexity and required development effort. Use automation to quickly implement code and configuration changes. Transform code with generative Al assistance to resolve more complex issues.

For more information, see the documentation for Upgrading the Java version for your application.

Explain code and applications

Understand complex code structures by using generative AI to summarize your application's key functions, services, and dependencies.

With the Standard plan, get enhanced code explanations. Use generative AI to analyze and summarize your code to understand what the code does. Click the Explain option that precedes a code block or enter /explain in a chat conversation. IBM watsonx Code Assistant analyzes the code and provides a detailed explanation of what the code does.

For more information, see the documentation for Explaining code.

Generate unit tests

Use generative AI to create tests that help maintain critical application functions.

With the Standard plan, create enhanced unit tests to evaluate your code functions. Click the Unit Test option that precedes a code block or enter /unit-test in a chat conversation. IBM watsonx Code Assistant analyzes the code and creates a unit test.

For more information, see the documentation for Generating unit tests.

Setup

Provision a watsonx Code Assistant service instance on IBM Cloud for your organization to get the best performance and the full set of features. Or for individuals, you can use watsonx Code Assistant Individual to access a local IBM Granite model.

Use a watsonx Code Assistant service instance on IBM Cloud

To set up on IBM Cloud:

  1. Explore the pricing plans.
  2. Use the IBM Cloud catalog to provision a service instance of watsonx Code Assistant.
  3. When you finish provisioning your instance, click Setup to open an onboarding checklist page to help you with configuration.
  4. Have your developers create an IBM Cloud API Key.
  5. Have your developers install the Visual Studio Code extension or Eclipse IDE plug-in for watsonx Code Assistant.

For more information, see the documentation for:

Use watsonx Code Assistant Individual with a local IBM Granite model

Free for individual use on a personal laptop, use IBM watsonx Code Assistant Individual to access a local model through Ollama, which is a widely-used local inferencing engine for LLMs. Ollama wraps the underlying model-serving project llama.cpp.

Install the IBM watsonx Code Assistant Visual Studio Code extension

This setup is not available for the Eclipse IDE plug-in. It is only available with the Visual Studio Code extension.

  1. Open the watsonx Code Assistant extension page in the Visual Studio Marketplace.
  2. Click Install on the Marketplace page.
  3. In Visual Studio Code, click Install on the extension.
  4. In the extension settings, set Wca: Backend Provider to ollama.

Install Ollama

  • MacOS, Linux, Windows: Download and run the ollama installer

  • On MacOS, you can also use homebrew to install Ollama:

    brew install ollama

Start the Ollama inference server

In a console window, run:

ollama serve

Leave that window open while you use Ollama.

If you receive the message Error: listen tcp 127.0.0.1:11434: bind: address already in use, the Ollama server is already started.

Install the IBM Granite code model

Get started with IBM watsonx Code Assistant by installing the granite-code:8b model available in the Ollama library.

  1. Open a new console window.

  2. On the command line, type ollama run granite-code:8b to download and deploy the model. You see output similar to the following example:

    pulling manifest 
    pulling 8718ec280572... 100% ▕███████████████████████ 4.6 GB
    pulling e50df8490144... 100% ▕███████████████████████ ▏  123 B
    pulling 58d1e17ffe51... 100% ▕███████████████████████▏  11 KB
    pulling 9893bb2c2917... 100% ▕███████████████████████▏  108 B
    pulling 0e851433eda0... 100% ▕███████████████████████▏  485 B
    verifying sha256 digest 
    writing manifest 
    removing any unused layers 
    success 
    >>> 
  3. Type /bye after the >>>to exit the Ollama command shell.

  4. Try out the model by typing:

    ollama run granite-code:8b "How do I create a python class?"
  5. You should see a response similar to:

    To create a Python class, you can define a new class using the "class" keyword followed by the name of the class and a colon. Inside the class definition, you can specify the methods and attributes that the class will have. Here is an example: ...

Configure the Ollama host

By default, the Ollama server runs on IP address 127.0.0.1, port 11434, and http as a protocol. If you change the IP address or the port where Ollama is available:

  1. In Visual Studio Code, open the extension settings for watsonx Code Assistant.
  2. In Wca > Local: API Host, add the host IP and port.

Configure the Granite model to use

By default, watsonx Code Assistant uses the granite-code:8b model for both chat and code completion. If your environment has enough capacity, install the granite-code:8b-base model.

To use a different model:

  1. Install the granite-code:8b-base model. See Install the IBM Granite code model.
  2. In Visual Studio Code, open the extension settings for watsonx Code Assistant.
  3. In Wca > Local: Code Gen Model, enter granite-code:8b-base.

Securing your setup

Your IDE environment

IBM watsonx Code Assistant does not provide any additional security controls. It's recommended the following steps be taken to properly secure your setup:

  • Apply all updates for your IDE to help ensure you have the latest security and bug fixes.
  • The IBM watsonx Code Assistant logs are stored in *.log files under <your home directory>/.wca. These files are not encrypted, other than the encryption that your file system provides. Safeguard the logs against improper access.

Chat conversation storage

IBM watsonx Code Assistant stores all your chat conversations locally in your file system under <your home directory>/.wca/chat.db, in a database format defined by SQLite. IBM watsonx Code Assistant does not share these conversations with anyone. This file is not encrypted, other than the encryption that your file system provides. Safeguard this file against improper access.

Telemetry data

IBM watsonx Code Assistant does not collect any telemetry data. In general, IBM watsonx Code Assistant does not send any data that it processes to a third party, IBM included.

Connecting IBM watsonx Code Assistant and Ollama

By default, the Ollama server runs on IP address 127.0.0.1, port 11434, using http as a protocol, on your local device. To use https instead, or go through a proxy server, see the Ollama documentation.

About

IBM watsonx Code Assistant simplifies and accelerates coding workflows across Python, Java, C, C++, Go, JavaScript, Typescript, and more. It leverages the Granite model to augment programmer skill sets, simplifying and automating coding and modernization efforts.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •