- Create a markdown file to record the prompt.
- Clearly state the purpose of the program.
- Outline the methods/processes by which the program achieves its purpose.
- Specify the programming style, instructing GPT4 to provide function descriptions, inputs, and outputs, but not to detail the specific implementation of the functions.
- Generate function designs with GPT4.
- Specify the libraries to be used, list a few typical examples from the libraries, and hand over all the above sections to GPT4 for code generation.
- Debug, submit the code and errors together to GPT4, ask for the reasons for the errors, and make modifications. Note that GPT4's knowledge may be outdated, it may refer to functions in libraries that do not exist, and may need assistance from ChatPDF or Bing Chat or manually finding the corresponding functions. Also, find the instructions or examples and hand them over to GPT4 to generate new code.
- Record the key points of debugging in the file.
In collaborative programming with GPT4, the program restores its original meaning: the process of doing things.
After explaining the method and process of the program itself to complete tasks to GPT, it can further refine them. This top-down process is what SICP has been explaining from the beginning. Now, with the help of GPT, you can keep part of the black box without having to open it, and just focus on designing the overall architecture. Since GPTx always has a length limit on input and output, decomposing tasks layer by layer from top to bottom can limit the subsequent debugging process within a smaller range, which is suitable for the limited length of input and output.
Okay, let's give an example, which is actually similar to putting an elephant into a refrigerator.
- Problem: Write a speech for a ppt
- Purpose: Read all the text in a ppt and write a speech for each page in turn.
Process Design
- Read the pptx file.
- Read the text on each page of the ppt, including the text in the body and the notes.
- For the i-th page, let GPT write a speech based on all the text and the text on the i-th page.
- Save the speech as a separate markdown file.
Function Design
Written in Python, structured programming in a functional programming style, and finally called by main().
- Libraries to be used
python-pptx, markdown
The above is designed by humans. Starting here, ask GPT: "For the above process, please design the corresponding functions, list the function descriptions, inputs, and outputs for each function, but do not list the specific implementation of each function."
GPT will respond to you:
- read_pptx(file_path: str) -> List[str]
Function Description: Reads a pptx file and returns a list containing the text content of each page.
Input: File path (string)
Output: List containing the text content of each page (list of strings)- extract_text_and_notes(slide: pptx.slide.Slide) -> str
……
Manually inspect these descriptions to see if there are any issues. If there are, you can add requirements:
- The generate_speech() function should use query_gpt3 to get the GPT response.
- The prompt should use the following...
- The speeches for different pages should be separated by xx.
Next, open the cursor, press ctrl+k, (or go to the ChatGPT webpage) select all of the above and paste it in. Wait.
If the cursor stops running and you think there's more output to come, remember we asked for the final call to be made by main(), so if the main() function hasn't appeared yet, it means it's not finished.
At this point, press ctrl+k again, say "continue," and wait for it to finish outputting. Now you have your initial program.
This task is quite simple, and one or two corrections will do.
There's nothing special here, it's just telling GPT the process of doing things, step by step, without involving any complex algorithms.
Of course, there are complex algorithms involved, such as generating a speech based on the content of a ppt page, which was still a very advanced algorithm a few months ago, and still is, it's just that you can delegate it to GPT to solve.
So what's left is simplifying the ctrl+C/V operation. Just tell it how you plan to do it.
As for how to plan to do something, that's the core of program design.
Recommended References: