Skip to main content

Datadog LLM 可观测性

danger

LLM 可观测性目前处于公开测试阶段,其 API 可能会发生变更。

通过 Datadog LLM 可观测性,您可以监控、调试和评估基于 LLM 的应用程序(例如聊天机器人)。您可以调查问题的根本原因、监控运行性能,并评估 LLM 应用程序的质量、隐私性和安全性。

这是一个实验性的社区实现,不由 Datadog 官方提供支持。它基于 Datadog LLM 可观测性 API

安装配置

:::提示 请参阅安装集成包的一般说明部分。 :::

npm install @langchain/community @langchain/core

使用方法

import { OpenAI } from "@langchain/openai";
import { DatadogLLMObsTracer } from "@langchain/community/experimental/callbacks/handlers/datadog";

/**
* This example demonstrates how to use the DatadogLLMObsTracer with the OpenAI model.
* It will produce a "llm" span with the input and output of the model inside the meta field.
*
* To run this example, you need to have a valid Datadog API key and OpenAI API key.
*/
export const run = async () => {
const model = new OpenAI({
model: "gpt-4",
temperature: 0.7,
maxTokens: 1000,
maxRetries: 5,
});

const res = await model.invoke(
"Question: What would be a good company name a company that makes colorful socks?\nAnswer:",
{
callbacks: [
new DatadogLLMObsTracer({
mlApp: "my-ml-app",
}),
],
}
);

console.log({ res });
};

API Reference:


Was this page helpful?


You can also leave detailed feedback on GitHub.