-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
community-experimental[minor]: feat: implement DatadogLLMObsTracer (#…
…5867) * chore: implement DatadogLLMObsTracer * chore: declare module into langchain-community/langchain.config.js * fix: remove dangling comma from langchain.config.js * fix: wrong import on datadog tracer example * chore: add autogenerated artifacts * fix: typo on UsageExmaple import * chore: move datadog llmobs from tracers to callbacks for consistency * chore: handle propagating tags to spans * chore: update session_id based on recent DD API Schema update * Update imports, move to experimental --------- Co-authored-by: jacoblee93 <jacoblee93@gmail.com>
- Loading branch information
1 parent
bbb7628
commit 16fed47
Showing
10 changed files
with
851 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
docs/core_docs/docs/integrations/callbacks/datadog_tracer.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
sidebar_class_name: beta | ||
--- | ||
|
||
import CodeBlock from "@theme/CodeBlock"; | ||
|
||
# Datadog LLM Observability | ||
|
||
:::warning | ||
LLM Observability is in public beta, and its API is subject to change. | ||
::: | ||
|
||
With [Datadog LLM Observability](https://docs.datadoghq.com/llm_observability/), you can monitor, troubleshoot, and evaluate your LLM-powered applications, such as chatbots. You can investigate the root cause of issues, monitor operational performance, and evaluate the quality, privacy, and safety of your LLM applications. | ||
|
||
This is an experimental community implementation, and it is not officially supported by Datadog. It is based on the [Datadog LLM Observability API](https://docs.datadoghq.com/llm_observability/api). | ||
|
||
## Setup | ||
|
||
import IntegrationInstallTooltip from "@mdx_components/integration_install_tooltip.mdx"; | ||
|
||
<IntegrationInstallTooltip></IntegrationInstallTooltip> | ||
|
||
```bash npm2yarn | ||
npm install @langchain/community | ||
``` | ||
|
||
## Usage | ||
|
||
import UsageExample from "@examples/callbacks/datadog.ts"; | ||
|
||
<CodeBlock language="typescript">{UsageExample}</CodeBlock> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
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 }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.