How to split complex tasks into a series of simpler subtasks by chaining multiple prompts together
- Using one long, complicated instruction where you have to manage multiple xxx and timing simultaneously, it can be challenging to keep track of everything and ensure that each component is perfect
- Chaining prompts, on the other hand, is done in stages where you focus on one component at a time, ensuring that each part is correct before moving on to the next.
Chaing Prompts
- More Focused
- Breaks down a complex task
- Making it easier to manage and reducing the likelihood of errors

- Each subtask contains only the instructions required for a single state of the task, which makes the system easier to manage, makes sure the model has all the information it needs to carry out a task, and reduces the likelihood of errors
- Reduce the number of tokens used in a prompt
- Skip some chains of the workflow when not needed for the task
- Easier to test
- Include human-in-the-loop
- For complex tasks, keep track of state
- External to the LLM(in your own code)
- Use external tools(web search, databases)
import os
import openai
import utils
from dotenv import load_dotenv, find_dotenv
_ = load_dotenv(find_dotenv()) # read local .env file
openai.api_key = os.environ['OPENAI_API_KEY']
- Context Limitations
- Max tokens for input prompt and output response
- Reduce Costs
- pay per token