-
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 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.
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.
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.
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.
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.
Or, enter a comment that describes the code you want.
For more information, see the documentation for Getting code suggestions.
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 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.
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.
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.
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.
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.
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.
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.
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.
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.
To set up on IBM Cloud:
- Explore the pricing plans.
- Use the IBM Cloud catalog to provision a service instance of watsonx Code Assistant.
- When you finish provisioning your instance, click Setup to open an onboarding checklist page to help you with configuration.
- Have your developers create an IBM Cloud API Key.
- 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:
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.
This setup is not available for the Eclipse IDE plug-in. It is only available with the Visual Studio Code extension.
- Open the watsonx Code Assistant extension page in the Visual Studio Marketplace.
- Click Install on the Marketplace page.
- In Visual Studio Code, click Install on the extension.
- In the extension settings, set Wca: Backend Provider to ollama.
-
MacOS, Linux, Windows: Download and run the ollama installer
-
On MacOS, you can also use homebrew to install Ollama:
brew install ollama
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.
Get started with IBM watsonx Code Assistant by installing the granite-code:8b
model available in the Ollama library.
-
Open a new console window.
-
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 >>>
-
Type
/bye
after the>>>
to exit the Ollama command shell. -
Try out the model by typing:
ollama run granite-code:8b "How do I create a python class?"
-
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: ...
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:
- In Visual Studio Code, open the extension settings for watsonx Code Assistant.
- In Wca > Local: API Host, add the host IP and port.
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:
- Install the
granite-code:8b-base
model. See Install the IBM Granite code model. - In Visual Studio Code, open the extension settings for watsonx Code Assistant.
- In Wca > Local: Code Gen Model, enter
granite-code:8b-base
.
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.
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.
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.
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.