Cover illustration

Architecture diagram

Who this is for

  • Team Collaborative Development of AI Applications Engineer
  • The technical leader who needs to do the Prompt review

What problem does this article solve?

Prompt has no record for modification, and the reason cannot be positioned after the effect of the online effect is deteriorated.

Key concepts

  • Prompt version
  • Evaluation example
  • change log
  • Grayscale release
  • roll back

Walkthrough

  1. Create prompt.yaml
  2. Save versions and instructions
  3. Prepare a fixed test set
  4. output comparison report

Python code example

The companion demo is generated in:

cd examples/llm-guides/008_prompt_versioning
python demo.py

The example follows two principles:

  • From OPENAI_API_KEY , load the key at runtime to avoid hard-coding it.
  • Without an API key, the example runs in mock mode so you can follow the workflow.

The essential call looks like this:

import os

api_key = os.getenv("OPENAI_API_KEY")
if not api_key:
    print("未配置 OPENAI_API_KEY,进入 mock 模式。")
else:
    # 真实项目中在这里初始化 SDK 客户端并发起请求。
    print("已读取 OPENAI_API_KEY,可以调用模型。")

Common pitfalls

  • Publishing after a single successful demo run leaves out error handling, logging and human review.
  • Including API keys, real file paths, account details or business data in published articles or code.
  • Readers can struggle to reproduce an example if it is unclear which parts are mocked and which run in production.
  • Citing an API or framework feature without checking its documentation can mislead readers when versions change.

Summary

  • LLM Guide 08 shows how to version prompts like code. When edits go unrecorded, it is hard to trace a drop in production quality back to the change that caused it.
  • Make the workflow reproducible, reversible and easy to review. One good generation tells you little about how it will hold up in use.
  • Before publishing, check current documentation for model capabilities, API parameters and third-party frameworks.

CSDN tags

Prompt, engineering, large model, Python, test

WeChat article summary

A minimal versioning workflow lets a team review prompt changes and roll them back when needed.

Alternative title for Zhihu

  • Does Prompt also need version management?
  • How can the team avoid prompts and messes?
  • How to publish the Prompt of the large model application?

References and further reading

  • Check the OpenAI documentation for your model, SDK and account permissions.
  • Python documentation on environment variables, virtual environments and exception handling.
  • Consult the documentation for the tools used in the example, such as LangChain, LlamaIndex, Haystack or the vector database.