Building Systems with the ChatGPT API - Process Inputs: Chaining Prompts

https://github.com/Ryota-Kawamura/Building-Systems-with-the-ChatGPT-API/tree/81d7d10bb6c0a4c3aeb18785b5c31d6ddc7b3a7b

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
相关推荐
陈大鱼头14 小时前
GPT-6 跟它的重置卡来了!
gpt·chatgpt·openai
ServBay14 小时前
ChatGPT、Grok 和 Claude 同时宕机了,你的在跑项目还好吗?
chatgpt·claude·grok
吨吨ai18 小时前
ChatGPT Plus / Pro + Codex 全栈自动化开发实战:2026年9月2日 从智能体工作流到企业级代码交付的完整技术指南
人工智能·chatgpt·自动化
AIGC大时代2 天前
知网 AIGC 检测在罚什么:均匀句长、低指代、零口癖,并不等于「用过 ChatGPT」
人工智能·chatgpt·nlp·aigc·论文·知网·学术规范
ClouGence2 天前
AI 定时任务火了?写日报、看新闻、做计划、盯价格,它都能自动跑
chatgpt·aigc·claude
嘿嘿-662 天前
VS Code 怎么配置 ChatGPT?用一键脚本把 Codex CLI 配好
chatgpt
顿哥GPT2 天前
ChatGPT Plus / Pro + Codex 实战指南(2026年9月2日)
人工智能·chatgpt
dunge20262 天前
ChatGPT Plus / Pro + Codex 深度实战指南:2026年9月2日 从智能编程到自动化工作流的完整技术手册
运维·chatgpt·自动化
Easy_API2 天前
8月31日,三份“模型合同”同时到期
人工智能·chatgpt