An iterative feedback loop treats AI output as a draft: assess each result, revise the prompt or implementation, and evaluate again. This keeps work aligned with accuracy, best practices, and the actual task. section 9.5.1
Use the loop to develop a small HTTP API request in Python:
- Split the task into initialization, response display, and error handling. section 9.5.1
- Prompt for each focused implementation, such as a requests-based GET request with best-practice error handling. section 9.5.1
- Review the generated code for efficiency, clarity, response formats, connection failures, timeouts, and non-200 status codes. section 9.5.1
- Rewrite the prompt when the result is weak, then use the same or another LLM as a sanity check. section 9.5.1
Reviewing an API request
After generating a requests-based HTTP GET function, ask: “Is the code efficient, does it follow best practices, and is error handling sufficiently robust?” For response handling, check whether it supports JSON and text clearly; for failures, check connection issues, timeouts, and non-200 responses. Revise the implementation or prompt wherever the review finds a gap. section 9.5.1
Figure 9.6 A chain-of-thought prompt gets the model to reason out a problem like a human would. You break down the problem and experiment with answers until you get the results you desire.
A figure illustrates breaking a problem down, experimenting with answers, and iterating until the result meets the desired outcome. section 9.5.1





























