Files
wehub-resource-sync bac4786e31
Flake8 Lint / flake8 (push) Has been cancelled
Publish Promptflow Doc / Build (push) Has been cancelled
Spell check CI / Spell_Check (push) Has been cancelled
Publish Promptflow Doc / Deploy (push) Has been cancelled
docs: make Chinese README the default
2026-07-13 10:49:35 +00:00

174 lines
9.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!-- WEHUB_ZH_README -->
> [!NOTE]
> 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。
> [English](./README.en.md) · [原始项目](https://github.com/microsoft/promptflow) · [上游 README](https://github.com/microsoft/promptflow/blob/HEAD/README.md)
> 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。
# Prompt flow
[![Python package](https://img.shields.io/pypi/v/promptflow)](https://pypi.org/project/promptflow/)
[![Python](https://img.shields.io/pypi/pyversions/promptflow.svg?maxAge=2592000)](https://pypi.python.org/pypi/promptflow/)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/promptflow)](https://pypi.org/project/promptflow/)
[![CLI](https://img.shields.io/badge/CLI-reference-blue)](https://microsoft.github.io/promptflow/reference/pf-command-reference.html)
[![vsc extension](https://img.shields.io/visual-studio-marketplace/i/prompt-flow.prompt-flow?logo=Visual%20Studio&label=Extension%20)](https://marketplace.visualstudio.com/items?itemName=prompt-flow.prompt-flow)
[![Doc](https://img.shields.io/badge/Doc-online-green)](https://microsoft.github.io/promptflow/index.html)
[![Issue](https://img.shields.io/github/issues/microsoft/promptflow)](https://github.com/microsoft/promptflow/issues/new/choose)
[![Discussions](https://img.shields.io/github/discussions/microsoft/promptflow)](https://github.com/microsoft/promptflow/issues/new/choose)
[![CONTRIBUTING](https://img.shields.io/badge/Contributing-8A2BE2)](https://github.com/microsoft/promptflow/blob/main/CONTRIBUTING.md)
[![License: MIT](https://img.shields.io/github/license/microsoft/promptflow)](https://github.com/microsoft/promptflow/blob/main/LICENSE)
> 欢迎加入我们,通过参与 [讨论](https://github.com/microsoft/promptflow/discussions),
> 提交 [issue](https://github.com/microsoft/promptflow/issues/new/choose),
> 贡献 [PR](https://github.com/microsoft/promptflow/pulls).
> 让 prompt flow 变得更好。
**Prompt flow** 是一套开发工具,旨在简化基于 LLM 的 AI 应用端到端开发周期,涵盖构思、原型设计、测试、评估到生产部署与监控。它让提示词工程(prompt engineering)更加轻松,并帮助你构建具备生产质量的 LLM 应用。
借助 prompt flow,你可以:
- **创建并迭代开发 flow**
- 创建可执行的 [flow](https://microsoft.github.io/promptflow/concepts/concept-flows.html),将 LLM、提示词、Python 代码及其他 [工具](https://microsoft.github.io/promptflow/concepts/concept-tools.html) 串联在一起。
- 调试并迭代你的 flow,尤其是轻松实现 [与 LLM 交互的追踪(tracing](https://microsoft.github.io/promptflow/how-to-guides/tracing/index.html)。
- **评估 flow 质量与性能**
- 使用更大数据集评估 flow 的质量与性能。
- 将测试与评估集成到 CI/CD 系统中,确保 flow 质量。
- **面向生产的精简开发周期**
- 将 flow 部署到你选择的 serving 平台,或轻松集成到应用代码库中。
- (可选但强烈推荐)通过 [Azure AI 中的 Prompt flow](https://learn.microsoft.com/en-us/azure/machine-learning/prompt-flow/overview-what-is-prompt-flow?view=azureml-api-2). 云版本与团队协作。
------
## 安装
若要快速上手,可使用预构建的开发环境。**点击下方按钮**在 GitHub Codespaces 中打开该仓库,然后继续阅读 readme!
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/microsoft/promptflow?quickstart=1)
若要在本地环境开始,请先安装相关包:
请确保已配置 Python 环境,推荐使用 `python>=3.9, <=3.11`
```sh
pip install promptflow promptflow-tools
```
## 快速开始 ⚡
**使用 prompt flow 创建聊天机器人**
运行以下命令,从聊天模板初始化一个 prompt flow;它会创建名为 `my_chatbot` 的文件夹,并在其中生成所需文件:
```sh
pf flow init --flow ./my_chatbot --type chat
```
**为你的 API 密钥配置连接**
对于 OpenAI 密钥,运行以下命令建立连接,使用 `my_chatbot` 文件夹中的 `openai.yaml` 文件存储你的 OpenAI 密钥(可通过 --set 覆盖密钥和名称,避免修改 yaml 文件):
```sh
pf connection create --file ./my_chatbot/openai.yaml --set api_key=<your_api_key> --name open_ai_connection
```
对于 Azure OpenAI 密钥,运行以下命令建立连接,使用 `azure_openai.yaml` 文件:
```sh
pf connection create --file ./my_chatbot/azure_openai.yaml --set api_key=<your_api_key> api_base=<your_api_base> --name open_ai_connection
```
**与你的 flow 对话**
`my_chatbot` 文件夹中,有一个 `flow.dag.yaml` 文件,其中概述了该 flow,包括输入/输出、节点、连接以及 LLM 模型等。
> 请注意,在 `chat` 节点中,我们使用名为 `open_ai_connection` 的连接(在 `connection` 字段中指定)以及 `gpt-35-turbo` 模型(在 `deployment_name` 字段中指定)。deployment_name 字段用于指定 OpenAI 模型,或 Azure OpenAI 部署资源。
运行以下命令与你的聊天机器人交互:(按 `Ctrl + C` 结束会话)
```sh
pf flow test --flow ./my_chatbot --interactive
```
**核心价值:确保从原型到生产的“高质量”**
探索我们的 [**15 分钟教程**](examples/tutorials/flow-fine-tuning-evaluation/promptflow-quality-improvement.md),它将引导你完成提示词调优 ➡ 批量测试 ➡ 评估,全程旨在确保达到可上线的生产质量。
下一步!继续阅读下方的 **教程** 👇 部分,深入了解 prompt flow。
## 教程 🏃‍♂️
Prompt flow 是一款旨在 **构建高质量 LLM 应用** 的工具;在 prompt flow 中的开发流程遵循以下步骤:开发 flow、提升 flow 质量、将 flow 部署到生产环境。
### 开发你自己的 LLM 应用
#### VS Code Extension
我们还提供 VS Code 扩展(flow 设计器),通过 UI 带来交互式 flow 开发体验。
<img src="docs/media/readme/vsc.png" alt="vsc" width="1000"/>
你可以从 <a href="https://marketplace.visualstudio.com/items?itemName=prompt-flow.prompt-flow">Visual Studio Marketplace</a> 安装。
#### 深入 flow 开发
[Getting started with prompt flow](./docs/how-to-guides/quick-start.md):分步指南,帮助你完成首次 flow 运行。
### 从用例中学习
[Tutorial: Chat with PDF](https://github.com/microsoft/promptflow/blob/main/examples/tutorials/e2e-development/chat-with-pdf.md): 一份端到端教程,讲解如何使用 prompt flow 构建高质量聊天应用,包括 flow 开发与基于指标的评估。
> 更多示例见 [此处](https://microsoft.github.io/promptflow/tutorials/index.html#samples). 欢迎贡献新的用例!
### 贡献者环境配置
若你有兴趣参与贡献,请从我们的开发环境配置指南开始:[dev_setup.md](./docs/dev/dev_setup.md)。
下一步!继续阅读下方的 **贡献** 👇 部分,为 prompt flow 做出贡献。
## 贡献
本项目欢迎贡献与建议。大多数贡献需要你同意贡献者许可协议(Contributor License AgreementCLA),声明你有权并确实授予我们使用你贡献内容的权利。详情请访问 https://cla.opensource.microsoft.com.
当你提交 pull request 时,CLA 机器人会自动判断你是否需要提供 CLA,并相应地标注 PR(例如状态检查、评论)。只需按照机器人提供的说明操作即可。在我们使用 CLA 的所有仓库中,你只需完成一次该流程。
本项目已采用 [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
更多信息请参阅 [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/),或通过 [opencode@microsoft.com](mailto:opencode@microsoft.com) 联系我们就其他问题或意见进行咨询。
## 商标
本项目可能包含项目、产品或服务的商标或标识。经授权的 Microsoft 商标或标识使用须遵守并遵循
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
在修改版本中使用 Microsoft 商标或标识不得造成混淆,或暗示 Microsoft 赞助。任何第三方商标或标识的使用均须遵守相应第三方的政策。
## 行为准则
本项目已采纳
[Microsoft 开源行为准则](https://opensource.microsoft.com/codeofconduct/).
更多信息请参阅
[行为准则常见问题(FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
,或通过 [opencode@microsoft.com](mailto:opencode@microsoft.com)
就其他问题或意见与我们联系。
## 数据收集
若配置为启用遥测(telemetry),本软件可能会收集有关您及您使用本软件的信息,
并将其发送至 Microsoft。
Microsoft 可能会使用这些信息来提供服务并改进我们的产品和服务。
您可以按照本仓库中的说明开启遥测。
本软件中还有一些功能可能使您与 Microsoft 能够收集应用程序用户的数据。若您使用这些功能,您
必须遵守适用法律,包括向应用程序用户提供适当的告知,并附上 Microsoft 隐私
声明的副本。我们的隐私声明位于
https://go.microsoft.com/fwlink/?LinkID=824704. 您可以在帮助文档和我们的隐私声明中了解更多关于数据
收集与使用的信息。您使用本软件即表示您同意这些做法。
### 遥测配置
默认开启遥测收集。
若要选择退出,请运行 `pf config set telemetry.enabled=false` 以将其关闭。
## 许可证
Copyright (c) Microsoft Corporation. All rights reserved.
根据 [MIT](LICENSE) 许可证授权。