先决条件
开始之前,请确保您拥有:- LangSmith 账户:在 smith.langchain.com 注册或登录。
- LangSmith API 密钥:遵循 创建 API 密钥 指南。
- OpenAI API 密钥:从 OpenAI 控制台 生成。
- UI
- SDK
1. 设置工作区密钥
In the LangSmith UI, ensure that your API key is set as a workspace secret.- Navigate to Settings and then move to the Secrets tab.
- Select Add secret and enter the key environment variable (e.g.,
OPENAI_API_KEYorANTHROPIC_API_KEY) and your API key as the Value. - Select Save secret.
When adding workspace secrets in the LangSmith UI, make sure the secret keys match the environment variable names expected by your model provider.
2. 创建提示词
Playground 使得可以针对不同的提示词、新模型或测试不同的模型配置运行评估。- 在 LangSmith UI 中,点击侧边栏的 Playground。
-
在 Prompts 面板下,将 system 提示词修改为:
保持 Human 消息不变:
{question}。
3. 创建数据集
- 点击 Set up Evaluation,这将在页面底部打开一个 New Experiment 表格。
-
在 Select or create a new dataset 下拉菜单中,点击 + New 按钮创建一个新数据集。

-
将以下示例添加到数据集中:
输入 参考输出 question: 乞力马扎罗山位于哪个国家? output: 乞力马扎罗山位于坦桑尼亚。 question: 地球的最低点是什么? output: 地球的最低点是死海。 - 点击 Save 并输入名称以保存您新创建的数据集。
4. 添加评估器
- 点击 + Evaluator,从 Prebuilt Evaluator 选项中选择 Correctness。
- 在 Correctness 面板中,点击 Save。
5. 运行评估
-
选择右上角的 Start 来运行您的评估。这将在 New Experiment 表格中创建一个带有预览的 实验。您可以点击实验名称查看完整视图。

后续步骤
- 有关评估的更多详细信息,请参阅 评估文档。
- 学习如何在 UI 中 创建和管理数据集。
- 学习如何 从 Playground 运行评估。
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.





