> ## Documentation Index
> Fetch the complete documentation index at: https://cndoc-langchain.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 测试多轮对话

本操作指南将引导你了解为多轮对话设置演练场的各种方法，这将允许你针对更长的消息线程测试不同的工具配置和系统提示。

<img src="https://mintcdn.com/other-405835d4/X4LKQZjW6RjHveuz/langsmith/images/multiturn-diagram.png?fit=max&auto=format&n=X4LKQZjW6RjHveuz&q=85&s=95777c50af1118d17c0b0f0b151aa0de" alt="多轮对话示意图" width="963" height="552" data-path="langsmith/images/multiturn-diagram.png" />

## 从现有运行中

首先，确保你已正确[追踪](/langsmith/observability)一个多轮对话，然后导航到你的追踪项目。进入追踪项目后，只需打开该运行，选择LLM调用，并按如下方式在演练场中打开它：

<img src="https://mintcdn.com/other-405835d4/X4LKQZjW6RjHveuz/langsmith/images/multiturn-from-run.gif?s=6515ad1241b330b9b328745bb27c7616" alt="从运行中获取多轮对话" width="1632" height="1080" data-path="langsmith/images/multiturn-from-run.gif" />

然后，你可以编辑系统提示，调整工具和/或输出模式，并观察多轮对话的输出如何变化。

## 从数据集中

开始之前，请确保你已[设置好数据集](/langsmith/manage-datasets-in-application)。由于你想评估多轮对话，请确保你的输入中有一个包含消息列表的键。

创建数据集后，前往演练场并[加载你的数据集](/langsmith/manage-datasets-in-application#from-the-playground)进行评估。

然后，向你的提示中添加一个消息列表变量，确保其名称与输入中包含消息列表的键相同：

<img src="https://mintcdn.com/other-405835d4/X4LKQZjW6RjHveuz/langsmith/images/multiturn-from-dataset.gif?s=7251958f1e84c34ccf0101e2d132420a" alt="从数据集中获取多轮对话" width="1632" height="1080" data-path="langsmith/images/multiturn-from-dataset.gif" />

当你运行提示时，每个示例中的消息将作为列表添加到“消息列表”变量的位置。

## 手动创建

有两种方法可以手动创建多轮对话。第一种方法是简单地将消息附加到提示中：

<img src="https://mintcdn.com/other-405835d4/X4LKQZjW6RjHveuz/langsmith/images/multiturn-manual.gif?s=6012cb8ff3ddf31c6e58f67fd87dc1a1" alt="手动创建多轮对话" width="1632" height="1080" data-path="langsmith/images/multiturn-manual.gif" />

这对于快速迭代很有帮助，但由于多轮对话是硬编码的，因此比较死板。相反，如果你希望你的提示适用于任何多轮对话，你可以添加一个“消息列表”变量，并在那里添加你的多轮对话：

<img src="https://mintcdn.com/other-405835d4/X4LKQZjW6RjHveuz/langsmith/images/multiturn-manual-list.gif?s=58797b88a3838649ff69017b884574b8" alt="手动创建多轮对话列表" width="1632" height="1080" data-path="langsmith/images/multiturn-manual-list.gif" />

这允许你只调整系统提示或工具，同时允许任何多轮对话替代`消息列表`变量，使你可以在各种运行中重复使用此提示。

## 后续步骤

现在你知道如何为多轮交互设置演练场，你可以手动检查和判断输出，或者你可以[添加评估器](/langsmith/code-evaluator-ui)来对结果进行分类。

你也可以阅读[这些操作指南](/langsmith/create-a-prompt)，以了解更多关于如何使用演练场运行评估的信息。

***

<div className="source-links">
  <Callout icon="terminal-2">
    [连接这些文档](/use-these-docs)到Claude、VSCode等，通过MCP获取实时答案。
  </Callout>

  <Callout icon="edit">
    [在GitHub上编辑此页面](https://github.com/langchain-ai/docs/edit/main/src/langsmith/multiple-messages.mdx)或[提交问题](https://github.com/langchain-ai/docs/issues/new/choose)。
  </Callout>
</div>
