Write Effective Prompts for Polyspace Copilot
Polyspace® Copilot provides generative AI capabilities while using Polyspace. You can ask Polyspace related questions, get explanations of Polyspace results with links to relevant documentation, and generate fixes for Polyspace results. You can ask follow-up prompts to clarify responses from Polyspace Copilot.
A prompt is the text that you submit to a generative AI tool as a request to perform a task. Typically, a prompt is a question or statement that you write using natural language. When you use Polyspace Copilot, you submit prompts in the Polyspace Copilot pane that opens when you log into your MathWorks account. See Configure Polyspace Copilot.
To maximize the effectiveness of Polyspace Copilot, it is important to write clear and detailed prompts with precise instructions and necessary context. You might need to iterate through several prompts and responses to generate useful output.
Consider these best practices while writing prompts.
Be Specific
When you write a prompt, clearly specify what you want Polyspace Copilot to do. Clarify vague prompts by providing detailed instructions or requirements.
For example, this prompt is vague:
Help me configure Polyspace.
Polyspace Copilot does not know what you want to configure. Avoid any implicit instructions. Instead, explicitly ask Polyspace Copilot what you want to configure and what platform you are using that requires configuring.
How can I configure Checkers in Polyspace as You Code for Visual Studio Code?How can I import an existing justifications catalog in Visual Studio Code?
Provide Context
Provide context in your prompt for Polyspace Copilot to better understand your area of
interest and requirements. For example, if you use the vague prompt, Help
me configure Polyspace, you might get a response saying to use the
command polyspace-configure buildCommand from within MATLAB®. If you want a response for specifically for Polyspace
as You Code™, you need to provide the context in your prompt. For example:
How can I configure the Polyspace as You Code extension to analyze my code in
real-time?
Specify Presentation of Response
Specify in your prompt how you want Polyspace Copilot to present its responses. For example, you can ask to get a detailed overview, or a brief explanation in only a few sentences. You can also specify the format of the response, such as a bulleted list or step-by-step instructions.
How I can import an existing justifications catalog in Visual Studio Code in a couple sentences?Provide a step-by-step list to configure Checkers in Polyspace as You Code for Visual Studio Code
Write Follow-Up Prompts
If your generated response is too vague, you can write follow-up prompts to extract more details from Polyspace Copilot. Polyspace Copilot uses the conversation history to provide more specific details in its responses.
For example, this prompt could provide a broad overview of configuring Polyspace as You Code:
How can I configure the Polyspace as You Code extension to analyze my code in real-time?
Polyspace Copilot could respond to this prompt by mentioning different settings, such as the working directory or the checkers selection. To gain additional details, ask a follow-up in the same chat window so Polyspace Copilot can use the conversation history as further information. For example:
Provide more details about the setting checkers in Polyspace as You
Code
When you ask Polyspace Copilot about a particular Polyspace result, Polyspace Copilot creates a new conversation and provides details about the result. You can ask follow-up questions in the conversation to clarify the response, further explain the risks surrounding the result, or provide additional information about the proposed fix for your code.
Polyspace Copilot provides suggested follow-up prompts after each response. If your initial prompt generates a response that is not useful or relevant, the follow-up prompt may also not be relevant.
Give Feedback and Describe Mistakes
Chat with Polyspace Copilot as though it were a colleague helping you with a project. When you get a response, follow up with a prompt providing feedback to Polyspace Copilot on its response. Tell Polyspace Copilot which parts of the response helped you and which parts did not. If Polyspace Copilot makes a mistake, describe it in a follow-up prompt.
Giving feedback to Polyspace Copilot includes asking it to generate a different fix for a certain result. If Polyspace Copilot generates a fix for your code that is not satisfactory, you can respond to Polyspace Copilot, providing additional details and feedback, and generate a different fix. Iterating on Polyspace Copilot responses by providing feedback and alerting Polyspace Copilot to the mistakes it has made can help it generate more relevant, accurate responses.
Provide feedback on generated responses to MathWorks® by clicking the thumbs-up button or thumbs-down button next to each response.
Create New Conversations for Unrelated Questions
Polyspace Copilot allows you to engage in multiple different conversations at once. Create a new conversation for each topic you want to discuss. Each time you ask Polyspace Copilot to explain a particular result or to generate a fix for a result, Polyspace Copilot starts a new conversation about the specific ask.
Keep unrelated conversations separate. If you ask Polyspace Copilot to explain the fix for a particular result in a conversation, do not use the same conversation to ask about other results. Polyspace Copilot uses the conversation history for context, and it can provide inaccurate responses when you ask follow-up questions about unrelated topics.
Break Down Complex Tasks
If your request to Polyspace Copilot involves multiple steps, break it down into simpler parts. You can submit the parts as separate prompts or as a paragraph in which you describe each part in a separate sentence.
Try Example Prompts
Polyspace Copilot provides example prompts at the start of a chat session. Try the example prompts to explore the capabilities and get started with Polyspace Copilot. Here are some example prompts:
What types of coding errors can Polyspace as You Code help me identify during development?How does Polyspace as You Code help identify potential run-time errors in my C/C++ code?Can Polyspace as You Code assist in ensuring compliance with coding standards like MISRA or CERT?
Rewrite Prompts as Needed
If Polyspace Copilot generates a response that is not helpful, you can edit your prompt by
adding details and context and submit a new request. Click the edit Polyspace
Copilot prompt icon
, craft your new prompt, and click the
Submit button to generate a new response. Polyspace
Copilot replaces the initial response with a new generated response using your
edited prompt.