LangSmith 支持在追踪记录中存储并展示图像,目前适用于多模态 LLM 运行。 要记录图像,请分别在 Python 或 TypeScript 中使用 wrap_openaiwrapOpenAI,并在输入中提供图像 URL 或 base64 编码图像。
from openai import OpenAI
from langsmith.wrappers import wrap_openai
client = wrap_openai(OpenAI())
response = client.chat.completions.create(
    model="gpt-4-turbo",
    messages=[
      {
        "role": "user",
        "content": [
          {"type": "text", "text": "What's in this image?"},
          {
            "type": "image_url",
            "image_url": {
              "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
            },
          },
        ],
      }
    ],
)
print(response.choices[0])
LangSmith UI 会在追踪详情中渲染该图像。 LangSmith 多模态追踪界面示例
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.