Skip to main content

在 GitHub 存储库中存储提示

直接在 GitHub 存储库中存储提示,以利用自动文本汇总和其他 AI 驱动的功能。

可以直接将提示存储为 GitHub 存储库中的文件。 这可以解锁以下功能:在井然有序的 UI 中查看提示、与非技术利益干系人共享这些提示,以及针对模型和提示的调整运行无缝迭代和比较。

优点

  • 在 GitHub 上直接与新的 AI 开发工具套件轻松集成。
  • 简单且可从简单用例扩展到复杂用例。
  • 使用广泛支持的格式,与现有工具兼容。

支持的文件格式

在 YAML 文件中存储提示。

该文件可以位于存储库中的任意位置,但必须具有扩展名 .prompt.yml.prompt.yaml。__

示例:

YAML
name: Text Summarizer
description: Summarizes input text concisely
model: openai/gpt-4o-mini
modelParameters:
  temperature: 0.5
messages:
  - role: system
    content: You are a text summarizer. Your only job is to summarize text given to you.
  - role: user
    content: |
      Summarize the given text, beginning with "Summary -":
      <text>
      {{input}}
      </text>
testData:
  - input: |
      The quick brown fox jumped over the lazy dog.
      The dog was too tired to react.
    expected: Summary - A fox jumped over a lazy, unresponsive dog.
evaluators:
  - name: Output should start with 'Summary -'
    string:
      startsWith: 'Summary -'

提示结构

提示有两个关键部分:

  • 运行时信息(必需)****
    • 使用简单的 {{variable}} 占位符提示模板(系统、用户等)
  • 开发信息(可选)****
    • 易于理解的名称和说明
    • 模型标识符和参数
    • 用于测试和评估的示例数据
    • 描述评估程序本身的数据

限制

不能将提示存储为:

  • 复杂的模板化语言
  • 专有或复杂的文件格式(例如 .ghprompt.prompty