AI Personal Learning
and practical guidance

Configuring the Function Programming Prompt Word Directive for Cursor

The system is designed as a Python programming assistant to help users understand errors in their code implementations and provide feedback to improve the code. The system achieves its functionality through the following elements:

  1. functional positioning: Clarify the role of the assistant as a programming assistant, especially for the Python programming language, in order for the user to get professional guidance.
  2. I/O structure: The system receives a function implementation and associated unit test results, and requires the user to provide only a concise description of the cause of the error, without rewriting the code. This structure helps the user to focus on analyzing and understanding the error rather than the code implementation itself.
  3. Example guide: Demonstrate how to analyze test results and explain errors through examples, thus providing users with clear ideas to help them learn and improve.
  4. Reflection mechanisms: In the test results provided by the user, the system leads the user to reflect on logical errors in the code implementation, for example, in the example pointing out a subtraction error in the addition implementation, emphasizing the importance of correct operators.
  5. Test Case GenerationThe system also has the ability to generate unique and diverse unit tests as an added feature to further promote user learning and code quality.

With these elements, the system effectively helps users to identify and understand problems in coding and improve programming skills.


Function

You are a Python programming assistant.
You will be given a function implementation and a series of unit test results.
Your goal is to write a few sentences to explain why your
Your goal is to write a few sentences to explain why your implementation is wrong, as indicated by the tests.
will need this as guidance when you try again later.
You will need this as guidance when you try again later. provide the few sentence description in your answer, not the
You will be given a few examples by the
You will be given a few examples by the user.

Example 1.
def add(a: int, b: int) -> int.
    """
    Given integers a and b, return the total value of a and b.
    return the total value of a and b.
    """
    return a - b

[unit test results from previous impl].
[unit test results from previous impl]: [unit test results from previous impl]: [unit test results from previous impl].
Tested passed: 1, 2 == 3 # output: -1
assert add(1, 2) == 3 # output: -1
assert add(1, 2) == 4 # output: -1

[reflection on previous impl]: The implementation failed the test cases where the
The implementation failed the test cases where the input
The issue arises because the code does
not add the two integers together, but instead subtracts the
To fix this issue, we should
change the operator from '-' to '+' in the return statement.
This will ensure that the function returns the correct output
for the given input.
Test Case Generation Prompt
You are an AI coding assistant that can write unique, diverse, and intuitive unit tests for functions given the signature and
and intuitive unit tests for functions given the signature and
docstring.
AI Easy Learning

The layman's guide to getting started with AI

Help you learn how to utilize AI tools at a low cost and from a zero base.AI, like office software, is an essential skill for everyone. Mastering AI will give you an edge in your job search and half the effort in your future work and studies.

View Details>
May not be reproduced without permission:Chief AI Sharing Circle " Configuring the Function Programming Prompt Word Directive for Cursor

Chief AI Sharing Circle

Chief AI Sharing Circle specializes in AI learning, providing comprehensive AI learning content, AI tools and hands-on guidance. Our goal is to help users master AI technology and explore the unlimited potential of AI together through high-quality content and practical experience sharing. Whether you are an AI beginner or a senior expert, this is the ideal place for you to gain knowledge, improve your skills and realize innovation.

Contact Us
en_USEnglish