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
相关推荐
小龙报2 小时前
用ChatGPT 5.5构建个人写作工作流:从大纲、初稿到风格润色的提示词链
人工智能·神经网络·低代码·自然语言处理·chatgpt·gpt-3·知识图谱
小七-七牛开发者18 小时前
Codex 实践系列 Vol.02:让 Codex 读懂开源项目 Typer
ai·chatgpt·openai·agent·工作流·codex·skill·ai coding
极客老王说Agent20 小时前
自动化架构演进:2026年有比RPA更加稳定的技术吗?
人工智能·ai·chatgpt·架构·自动化·rpa
GPT-Image21 天前
AI把世界杯“提前踢开幕”了
人工智能·chatgpt·ai作画·aigc
浩风祭月1 天前
2026 AI工具评测:ChatGPT、Claude、Gemini、Cursor、Kiro 到底怎么选?
人工智能·chatgpt·ai编程
lauo1 天前
当手机开始“编程”:荣耀Robot Phone的影像革命与ibbot青春版的AI“挖矿”之道
大数据·人工智能·chatgpt·智能手机·ai-native
下班走回家1 天前
从 ChatGPT 到 DeepSeek:AI 对话产品的差异化竞争
人工智能·chatgpt
DS随心转APP1 天前
Claude 导出对话多方案横向测评来袭,借助 AI 导出鸭对比各类导出工具优劣,筛选最优处理办法
人工智能·ai·chatgpt·deepseek·ai导出鸭
oscar9991 天前
当电子表格遇上 ChatGPT:像聊天一样做数据分析
chatgpt·数据挖掘·数据分析