Data Science Workshop (DSW) includes Lingma, which offers AI-powered features such as code generation, code completion, code explanation, and code optimization to help you code more efficiently.
Get started
This section demonstrates the main features of Lingma by showing you how to write code that calls the Alibaba Cloud qwen-plus model. After you create and start a Data Science Workshop (DSW) instance, switch to the WebIDE tab and create a new Python file, such as test.py.
Code generation
In the sidebar of the WebIDE, click the Lingma icon
. In the dialog box, enter your requirements for the code. For example: Please write a simple Python code example to call the Alibaba Cloud Model Studio qwen-plus model. The code must be compatible with the OpenAI API standard. Lingma automatically generates the code. After the code is generated, click the
icon to insert the code at the cursor in the editor, or click the
icon to copy the code.
If the generated code does not meet your requirements, you can continue the conversation in the input box to refine it with Lingma.

After you insert the code, right-click and select Run Python > Run Python File in Terminal to verify that the code executes correctly.
Note: Before running the code, complete these steps:
Obtain a Model Studio API key and replace
your-api-keyin the code.Run
pip install openaiin the terminal to install the OpenAI dependency package.

The code generated by the large language model (LLM) may differ from the example in this document due to its stochastic nature. This is normal.
Code explanation
To understand a block of code, select it in the editor, right-click, and choose Lingma > Explain. An explanation of the code appears in the sidebar, where you can click Chinese to switch the language.

Code refactoring and improvements
To optimize a block of code, select it in the editor, right-click, and choose Lingma > Optimize. The optimized code appears in the sidebar. The new code is more secure because it retrieves the API key from an environment variable by default. This approach helps prevent accidental key exposure.
For more information, see Configure a system environment variable.

Unit testing
To generate a unit test for the call_qwen_plus method, select its code block, right-click, and choose Lingma > UnitTest. Click the
button. Lingma automatically creates a new Python file and adds the unit test code to it.

Code completion
As you write code, Lingma provides inline code completion suggestions. For example, when writing a call_qwen_plus_with_retry method, the suggested code appears as grayed-out text. Press the Tab key to accept the suggestion. To accept the suggestion line by line, press Enter and then Tab for each line. If no suggestion appears, try pressing Enter or waiting a few seconds.

Code comment generation
You can use Lingma to generate comments for your code. Select the target code in the editor, right-click, and choose Lingma > Comment. Lingma automatically generates the comments in the sidebar.

More tips
In addition to the features described above, you can explore the following advanced features and personalized settings to further improve your development experience:
Custom keyboard shortcuts: To explore more features, including custom keyboard shortcuts and saving code snippets, see AI chat.
Switch models: The name of the current model is displayed in the lower-left corner of the page. To switch models, click the model name.

Billing
The personal edition of Lingma in DSW is currently free to use. For information about free quota limits and future commercialization strategies, see Billing of Lingma.
FAQ
Q: Does Lingma store my code? Are there security and privacy issues?
Lingma strictly adheres to privacy protection principles and does not store your code data:
For code completion, Lingma analyzes the context of your code. However, this contextual information is not stored or used for any other purpose. You retain full ownership and control over this data.
For AI chat, your chat history (excluding code) is used to improve the algorithm only when you provide feedback (thumbs up or thumbs down). This data is fully anonymized before use.
For more information about the privacy policy, see the Lingma Privacy Policy.
Q: Do I need to register or log on to Lingma separately?
No. After DSW starts, you are automatically logged on to Lingma using the Alibaba Cloud account of the instance owner.
For answers to other common questions, see FAQ about Lingma.