Generating code using natural language prompts
With the code generation feature, you can use natural language to generate new code. You can either start a new chat conversation or use the chat history to continue an existing conversation.
There are no slash commands for code generation. Hence, users can enter free-form chat messages.
Starting a new chat conversation
You can generate code by starting a new conversation using the Chat Experience interface.
-
Click the Chat icon to start a new chat session.
The WATSONX CODE ASSISTANT: CHAT window opens.
- Using natural language, enter a descriptive chat detailing the requirements of the
program.
For example: Generate an annual income COBOL program. This program displays a prompt saying, "Enter your annual income." It stores the entered value in the variable called INCOME and performs the multiply statement by multiplying the INCOME by 0.22 to calculate the Federal income tax.
- Click Send.
IBM® watsonx Code Assistant™ for Z processes the chat message and determines whether the message is in natural language supported by the application. It then generates an appropriate program.
-
If you want to refine the code, modify your earlier chat message with the required details and click Send.
-
Examine the generated code to verify whether it meets your requirements. Note that you cannot edit the code in the WATSONX CODE ASSISTANT: CHAT window.
If the generated code meets your requirements, you can perform one of the following actions:
- Copy code: Use this option to copy the generated code into your clipboard and paste it at an appropriate location in your COBOL program using the Editor.
- Insert at cursor: In the editor, browse and select an appropriate location within your COBOL program where you want to insert the generated code. Use this option to directly insert the code to the cursor location.
After copying or inserting the code to the required location in your program, you can edit the code in the editor.
Note: You cannot use any shortcut keys or hotkeys to copy the generated code from the WATSONX CODE ASSISTANT: CHAT window.