工具允许语言模型与外部系统交互并执行超越生成文本的操作。在 LangSmith playground 中,您可以使用两种类型的工具:
  1. 内置工具:由模型提供商(如 OpenAI 和 Anthropic)提供的预配置工具,可随时使用。这些包括网络搜索、代码解释等功能。
  2. 自定义工具:您定义用于执行特定任务的函数。当您需要与自己的系统集成或创建专门功能时,这些很有用。当您在 LangSmith Playground 中定义自定义工具时,您可以验证模型是否正确识别并使用正确的参数调用这些工具。我们计划很快支持直接执行这些自定义工具调用。

何时使用工具

  • 当您需要网络搜索或代码解释等常见功能时,请使用内置工具。这些由模型提供商构建和维护。
  • 当您想要测试和验证自己的工具设计时,请使用自定义工具,包括:
    • 验证模型选择使用哪些工具并查看它在工具调用中提供的特定参数
    • 模拟工具交互

内置工具

LangSmith Playground 原生支持来自 OpenAI 和 Anthropic 的各种工具。如果您想使用 Playground 中未明确列出的工具,您仍然可以通过手动指定其 type 和任何必需的参数来添加它。

OpenAI 工具

Anthropic 工具

Adding and using tools

Add a tool

To add a tool to your prompt, click the + Tool button at the bottom of the prompt editor.

Use a built-in tool

  1. In the tool section, select the built-in tool you want to use. You’ll only see the tools that are compatible with the provider and model you’ve chosen.
  2. When the model calls the tool, the playground will display the response

Create a custom tool

To create a custom tool, you’ll need to provide:
  • Name: A descriptive name for your tool
  • Description: Clear explanation of what the tool does
  • Arguments: The inputs your tool requires
Note: When running a custom tool in the playground, the model will respond with a JSON object containing the tool name and the tool call. Currently, there’s no way to connect this to a hosted tool via MCP.

Tool choice settings

Some models provide control over which tools are called. To configure this:
  1. Go to prompt settings
  2. Navigate to tool settings
  3. Select tool choice
To understand the available tool choice options, check the documentation for your specific provider. For example, OpenAI’s documentation on tool choice.
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.