Data Science Workshop (DSW) includes Lingma, an AI coding assistant that helps you write code faster with features such as code generation, code completion, code explanation, and code optimization.
Get started
This section walks you through Lingma's core features using a hands-on example: writing Python code that calls the Alibaba Cloud qwen-plus model. Before you begin, 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 WebIDE sidebar, click the Lingma icon
. In the dialog box, describe what you need. 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 generates the code automatically. Click
to insert the code at the cursor, or click
to copy it.
If the output does not meet your needs, continue the conversation in the input box to refine it.

After inserting the code, right-click and select Run Python > Run Python File in Terminal to verify that it runs correctly.
Before running the code:
Obtain a Model Studio API key and replace
your-api-keyin the code.Run
pip install openaiin the terminal to install the OpenAI dependency.

LLM-generated code may differ from the example shown here due to the stochastic nature of large language models. This is expected behavior.
Code explanation
Select a block of code in the editor, right-click, and choose Lingma > Explain. The explanation appears in the sidebar. Click Chinese to switch the explanation language.

Code refactoring and improvements
Select a block of code in the editor, right-click, and choose Lingma > Optimize. The refactored code appears in the sidebar. By default, Lingma retrieves the API key from an environment variable rather than hardcoding it, which reduces the risk of accidental key exposure.
For more information, see Configure a system environment variable .

Unit testing
Select the call_qwen_plus method's code block, right-click, and choose Lingma > UnitTest. Click
. Lingma creates a new Python file and adds the generated unit test code to it.

Code completion
As you type, Lingma suggests inline code completions shown as grayed-out text. For example, when writing a call_qwen_plus_with_retry method, press Tab to accept the full suggestion, or press Enter then Tab to accept it line by line. If no suggestion appears, press Enter or wait a few seconds.

Code comment generation
Select the target code in the editor, right-click, and choose Lingma > Comment. Lingma generates comments for the selected code and displays them in the sidebar.

More tips
Lingma also supports the following customization options:
Custom keyboard shortcuts: For custom keyboard shortcuts and saving code snippets, see AI chat.
Adjust code completion triggers: For personalized settings such as completion triggers and theme colors, see Configuration and feedback.
-
Switch models: The current model name is shown in the lower-left corner of the page. Click it to switch models.

Billing
The personal edition of Lingma in DSW is currently free to use. For free quota limits and future pricing details, see Billing of Lingma.
FAQ
Q: Does Lingma store my code? Are there security and privacy issues?
No. Lingma does not store your code:
For code completion, Lingma analyzes the surrounding code context to generate suggestions. This contextual data is not stored or used for any other purpose. You retain full ownership and control over your code.
For AI chat, your chat history (excluding code) is used to improve the underlying algorithm only when you explicitly provide feedback (thumbs up or thumbs down). All such data is fully anonymized before use.
For the full privacy policy, see the Lingma Privacy Policy.
Q: Do I need to register or log on to Lingma separately?
No. When 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.