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
相关推荐
VIP_CQCRE1 小时前
OpenAI Chat Completion API 接入指南:用 Ace Data Cloud 快速把 ChatGPT 能力接进业务系统
人工智能·chatgpt·openai·api·acedatacloud
孤狼GPT4 小时前
2026年7月怎么充GPT会员?先分清Plus、Pro、Codex和API
人工智能·gpt·chatgpt·codex
oscar99919 小时前
Codex 编程智能体入门指南
ai·chatgpt·codex
云栖梦泽在1 天前
Claude Code / Codex 使用卡顿怎么办?AI 编程 Agent 连接失败与网络排查思路
网络·人工智能·网络协议·chatgpt·性能优化
阿拉斯攀登1 天前
AI Agent 入门:从 ChatGPT 到自主智能体
人工智能·chatgpt·agent·ai编程·loop
跨境生态圈1 天前
2026外贸获客渠道全面洗牌:AI正在重新分配全球流量,你的品牌在答案里吗?
大数据·运维·人工智能·chatgpt
米小虾1 天前
2026年7月AI圈大地震:GPT-5.6被政府限制、Claude入驻Slack、Anthropic自研芯片
人工智能·chatgpt·claude
漫步人生走在路上2 天前
外贸GEO vs 传统SEO:区别有多大?
人工智能·搜索引擎·chatgpt·facebook·twitter
Gp7HH6hrE2 天前
OpenAI 与 Anthropic 开放公共学习平台
人工智能·学习·chatgpt
owCode2 天前
Windows RX6500XT(gfx1034) Ollama AMD ROCm 完整安装教程
语言模型·chatgpt·github·llama·gpu算力