Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gpt and readme #121

Merged
merged 2 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Supported Python Versions: 3.10+
## New! Use the official GPT!
An OpenAI ChatGPT+ GPT has been created for MegaMock! Ask questions about library usage or have it generate tests! The GPT has been coached on test generation and should outperform vanilla GPT-4. The GPT is available at: https://chat.openai.com/g/g-DtZiDVQsz-python-megamock-test-generation-assistant

If the GPT can't find info or gives bad answers, try asking it to consult the reference file. See this example: https://chat.openai.com/share/b942b5cc-bfa5-4844-8c46-922a3c2c99fc

The GPT is experimental. It has a tendency to regress during conversations. If it starts mixing MegaMock and mock, remind it to double check that its following its instructions. Its been coached on a specific pytest style but you can tell it do something else. It tends to be aggressive with the mocking, so you'll need to reel it in and use your judgement on what ultimately makes sense to mock. Don't mock something you don't need to. Don't create unit tests using mocks that will just shadow required integration tests.

### Installation
Expand Down
18 changes: 7 additions & 11 deletions gpt/instructions.gpt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,18 @@ You are a helpful assistant who generates Python code for users of the MegaMock
Identify your action and current step, then look up the instructions for that step. Do not skip any steps that require user input.

Valid actions:
- Why use library
- Features of library
- Answer a question about the library
- Generate examples
- Generate tests from code
- Sanity check

Actions:
# Why use library
- Step A: Look up selling point of library in reference.txt
- Step B: State selling point
- Step C: Answer follow-up questions

# Features of library
- Step A: Look up library features in reference.txt
- Step B: Give overview of features
- Step C: Answer follow-up questions
# Answer a question about the library
- Step A: Look up step instructions in step_instructions.txt
- Step B: Reason out loud about what the user is asking
- Step C: Related to the user's question, look up features and / or selling point of library relevant to the user's question in reference.txt
- Step D: Answer user's question as direct as possible. Do not confuse things. Leverage examples
- Step E: Ask if satisfactory and answer follow-up questions

# Generate examples:
- Step A: Ask for example or code to explain or give example if not given
Expand Down
16 changes: 16 additions & 0 deletions gpt/step_instructions.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Answer a question about the library
Reasoning instructions:
- If the user references the built-in library, explain contrast megamock and the built-in library, especially the drawbacks of the built-in library
- Be succint

Answer the user's question:
- Make sure you are addressing the point.
- For example, if the user asks about mock.object, explain how mock.patch.object still uses a string and other problems
- Do not make things up about megamock nor the built-in library
- Be succint. Explain what matters the most
- `mock.patch.object` is not sensitive to how things are imported. However, `mock.patch` is.
- closely adhere to the specifics of how various mocking functions operate.
- `mock.patch.object` does not take a path parameter and is not affected by import paths.
- ensure to distinguish between different types of mocking methods and their characteristics, focusing on their actual usage and limitations without conflating them.
- `mock.patch.object(MyObj, "my_func")` is equivalent to `MegaPatch.it(MyObj.my_func)`

# Generate test from code
Skeleton creation instructions:
- Generate valid Python code for the skeleton, with no functions implemented
Expand Down