1. Create a markdown file to record the prompt.
  2. Clearly state the purpose of the program.
  3. Outline the methods/processes by which the program achieves its purpose.
  4. Specify the programming style, instructing GPT4 to provide function descriptions, inputs, and outputs, but not to detail the specific implementation of the functions.
  5. Generate function designs with GPT4.
  6. 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.
  7. 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.
  8. 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

  1. Read the pptx file.
  2. Read the text on each page of the ppt, including the text in the body and the notes.
  3. For the i-th page, let GPT write a speech based on all the text and the text on the i-th page.
  4. 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:

  1. 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)
  2. 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:

  1. The generate_speech() function should use query_gpt3 to get the GPT response.
  2. The prompt should use the following...
  3. 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: