langwatch 0.1.7 → 0.3.0-prerelease.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +16 -0
- package/LICENSE +7 -0
- package/README.md +268 -1
- package/copy-types.sh +19 -8
- package/examples/langchain/.env.example +2 -0
- package/examples/langchain/README.md +42 -0
- package/examples/langchain/package-lock.json +2930 -0
- package/examples/langchain/package.json +27 -0
- package/examples/langchain/src/cli-markdown.d.ts +137 -0
- package/examples/langchain/src/index.ts +109 -0
- package/examples/langchain/tsconfig.json +25 -0
- package/examples/langgraph/.env.example +2 -0
- package/examples/langgraph/README.md +42 -0
- package/examples/langgraph/package-lock.json +3031 -0
- package/examples/langgraph/package.json +28 -0
- package/examples/langgraph/src/cli-markdown.d.ts +137 -0
- package/examples/langgraph/src/index.ts +196 -0
- package/examples/langgraph/tsconfig.json +25 -0
- package/examples/mastra/.env.example +2 -0
- package/examples/mastra/README.md +57 -0
- package/examples/mastra/package-lock.json +5296 -0
- package/examples/mastra/package.json +32 -0
- package/examples/mastra/src/cli-markdown.d.ts +137 -0
- package/examples/mastra/src/index.ts +120 -0
- package/examples/mastra/src/mastra/agents/weather-agent.ts +30 -0
- package/examples/mastra/src/mastra/index.ts +21 -0
- package/examples/mastra/src/mastra/tools/weather-tool.ts +102 -0
- package/examples/mastra/tsconfig.json +25 -0
- package/examples/vercel-ai/.env.example +2 -0
- package/examples/vercel-ai/README.md +38 -0
- package/examples/vercel-ai/package-lock.json +2571 -0
- package/examples/vercel-ai/package.json +27 -0
- package/examples/vercel-ai/src/cli-markdown.d.ts +137 -0
- package/examples/vercel-ai/src/index.ts +110 -0
- package/examples/vercel-ai/src/instrumentation.ts +9 -0
- package/examples/vercel-ai/tsconfig.json +25 -0
- package/package.json +80 -33
- package/src/__tests__/client-browser.test.ts +92 -0
- package/src/__tests__/client-node.test.ts +76 -0
- package/src/__tests__/client.test.ts +71 -0
- package/src/__tests__/integration/client-browser.test.ts +46 -0
- package/src/__tests__/integration/client-node.test.ts +46 -0
- package/src/client-browser.ts +70 -0
- package/src/client-node.ts +82 -0
- package/src/client-shared.ts +72 -0
- package/src/client.ts +119 -0
- package/src/evaluation/__tests__/record-evaluation.test.ts +112 -0
- package/src/evaluation/__tests__/run-evaluation.test.ts +171 -0
- package/src/evaluation/index.ts +2 -0
- package/src/evaluation/record-evaluation.ts +101 -0
- package/src/evaluation/run-evaluation.ts +133 -0
- package/src/evaluation/tracer.ts +3 -0
- package/src/evaluation/types.ts +23 -0
- package/src/index.ts +10 -591
- package/src/internal/api/__tests__/errors.test.ts +98 -0
- package/src/internal/api/client.ts +30 -0
- package/src/internal/api/errors.ts +32 -0
- package/src/internal/generated/types/.gitkeep +0 -0
- package/src/observability/__tests__/integration/base.test.ts +74 -0
- package/src/observability/__tests__/integration/browser-setup-ordering.test.ts +60 -0
- package/src/observability/__tests__/integration/complex-nested-spans.test.ts +29 -0
- package/src/observability/__tests__/integration/error-handling.test.ts +24 -0
- package/src/observability/__tests__/integration/langwatch-disabled-otel.test.ts +24 -0
- package/src/observability/__tests__/integration/langwatch-first-then-vercel.test.ts +24 -0
- package/src/observability/__tests__/integration/multiple-setup-attempts.test.ts +27 -0
- package/src/observability/__tests__/integration/otel-ordering.test.ts +27 -0
- package/src/observability/__tests__/integration/vercel-configurations.test.ts +20 -0
- package/src/observability/__tests__/integration/vercel-first-then-langwatch.test.ts +27 -0
- package/src/observability/__tests__/span.test.ts +214 -0
- package/src/observability/__tests__/trace.test.ts +180 -0
- package/src/observability/exporters/index.ts +1 -0
- package/src/observability/exporters/langwatch-exporter.ts +53 -0
- package/src/observability/index.ts +4 -0
- package/src/observability/instrumentation/langchain/__tests__/integration/langchain-chatbot.test.ts +112 -0
- package/src/observability/instrumentation/langchain/__tests__/langchain.test.ts +284 -0
- package/src/observability/instrumentation/langchain/index.ts +624 -0
- package/src/observability/processors/__tests__/filterable-batch-span-exporter.test.ts +98 -0
- package/src/observability/processors/filterable-batch-span-processor.ts +99 -0
- package/src/observability/processors/index.ts +1 -0
- package/src/observability/semconv/attributes.ts +185 -0
- package/src/observability/semconv/events.ts +42 -0
- package/src/observability/semconv/index.ts +16 -0
- package/src/observability/semconv/values.ts +159 -0
- package/src/observability/span.ts +728 -0
- package/src/observability/trace.ts +301 -0
- package/src/prompt/__tests__/prompt.test.ts +139 -0
- package/src/prompt/get-prompt-version.ts +49 -0
- package/src/prompt/get-prompt.ts +44 -0
- package/src/prompt/index.ts +3 -0
- package/src/prompt/prompt.ts +133 -0
- package/src/prompt/service.ts +221 -0
- package/src/prompt/tracer.ts +3 -0
- package/src/prompt/types.ts +0 -0
- package/ts-to-zod.config.js +11 -0
- package/tsconfig.json +3 -9
- package/tsup.config.ts +11 -1
- package/vitest.config.ts +1 -0
- package/dist/chunk-FWBCQQYZ.mjs +0 -711
- package/dist/chunk-FWBCQQYZ.mjs.map +0 -1
- package/dist/index.d.mts +0 -1010
- package/dist/index.d.ts +0 -1010
- package/dist/index.js +0 -27294
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -959
- package/dist/index.mjs.map +0 -1
- package/dist/utils-B0pgWcps.d.mts +0 -303
- package/dist/utils-B0pgWcps.d.ts +0 -303
- package/dist/utils.d.mts +0 -2
- package/dist/utils.d.ts +0 -2
- package/dist/utils.js +0 -703
- package/dist/utils.js.map +0 -1
- package/dist/utils.mjs +0 -11
- package/dist/utils.mjs.map +0 -1
- package/example/.env.example +0 -12
- package/example/.eslintrc.json +0 -26
- package/example/LICENSE +0 -13
- package/example/README.md +0 -12
- package/example/app/(chat)/chat/[id]/page.tsx +0 -60
- package/example/app/(chat)/layout.tsx +0 -14
- package/example/app/(chat)/page.tsx +0 -27
- package/example/app/actions.ts +0 -156
- package/example/app/globals.css +0 -76
- package/example/app/guardrails/page.tsx +0 -26
- package/example/app/langchain/page.tsx +0 -27
- package/example/app/langchain-rag/page.tsx +0 -28
- package/example/app/late-update/page.tsx +0 -27
- package/example/app/layout.tsx +0 -64
- package/example/app/login/actions.ts +0 -71
- package/example/app/login/page.tsx +0 -18
- package/example/app/manual/page.tsx +0 -27
- package/example/app/new/page.tsx +0 -5
- package/example/app/opengraph-image.png +0 -0
- package/example/app/share/[id]/page.tsx +0 -58
- package/example/app/signup/actions.ts +0 -111
- package/example/app/signup/page.tsx +0 -18
- package/example/app/twitter-image.png +0 -0
- package/example/auth.config.ts +0 -42
- package/example/auth.ts +0 -45
- package/example/components/button-scroll-to-bottom.tsx +0 -36
- package/example/components/chat-history.tsx +0 -49
- package/example/components/chat-list.tsx +0 -52
- package/example/components/chat-message-actions.tsx +0 -40
- package/example/components/chat-message.tsx +0 -80
- package/example/components/chat-panel.tsx +0 -139
- package/example/components/chat-share-dialog.tsx +0 -95
- package/example/components/chat.tsx +0 -84
- package/example/components/clear-history.tsx +0 -75
- package/example/components/empty-screen.tsx +0 -38
- package/example/components/external-link.tsx +0 -29
- package/example/components/footer.tsx +0 -19
- package/example/components/header.tsx +0 -114
- package/example/components/login-button.tsx +0 -42
- package/example/components/login-form.tsx +0 -97
- package/example/components/markdown.tsx +0 -9
- package/example/components/prompt-form.tsx +0 -115
- package/example/components/providers.tsx +0 -17
- package/example/components/sidebar-actions.tsx +0 -125
- package/example/components/sidebar-desktop.tsx +0 -19
- package/example/components/sidebar-footer.tsx +0 -16
- package/example/components/sidebar-item.tsx +0 -124
- package/example/components/sidebar-items.tsx +0 -42
- package/example/components/sidebar-list.tsx +0 -38
- package/example/components/sidebar-mobile.tsx +0 -31
- package/example/components/sidebar-toggle.tsx +0 -24
- package/example/components/sidebar.tsx +0 -21
- package/example/components/signup-form.tsx +0 -95
- package/example/components/stocks/events-skeleton.tsx +0 -31
- package/example/components/stocks/events.tsx +0 -30
- package/example/components/stocks/index.tsx +0 -36
- package/example/components/stocks/message.tsx +0 -134
- package/example/components/stocks/spinner.tsx +0 -16
- package/example/components/stocks/stock-purchase.tsx +0 -146
- package/example/components/stocks/stock-skeleton.tsx +0 -22
- package/example/components/stocks/stock.tsx +0 -210
- package/example/components/stocks/stocks-skeleton.tsx +0 -9
- package/example/components/stocks/stocks.tsx +0 -67
- package/example/components/tailwind-indicator.tsx +0 -14
- package/example/components/theme-toggle.tsx +0 -31
- package/example/components/ui/alert-dialog.tsx +0 -141
- package/example/components/ui/badge.tsx +0 -36
- package/example/components/ui/button.tsx +0 -57
- package/example/components/ui/codeblock.tsx +0 -148
- package/example/components/ui/dialog.tsx +0 -122
- package/example/components/ui/dropdown-menu.tsx +0 -205
- package/example/components/ui/icons.tsx +0 -507
- package/example/components/ui/input.tsx +0 -25
- package/example/components/ui/label.tsx +0 -26
- package/example/components/ui/select.tsx +0 -164
- package/example/components/ui/separator.tsx +0 -31
- package/example/components/ui/sheet.tsx +0 -140
- package/example/components/ui/sonner.tsx +0 -31
- package/example/components/ui/switch.tsx +0 -29
- package/example/components/ui/textarea.tsx +0 -24
- package/example/components/ui/tooltip.tsx +0 -30
- package/example/components/user-menu.tsx +0 -53
- package/example/components.json +0 -17
- package/example/instrumentation.ts +0 -11
- package/example/lib/chat/guardrails.tsx +0 -181
- package/example/lib/chat/langchain-rag.tsx +0 -191
- package/example/lib/chat/langchain.tsx +0 -112
- package/example/lib/chat/late-update.tsx +0 -208
- package/example/lib/chat/manual.tsx +0 -605
- package/example/lib/chat/vercel-ai.tsx +0 -576
- package/example/lib/hooks/use-copy-to-clipboard.tsx +0 -33
- package/example/lib/hooks/use-enter-submit.tsx +0 -23
- package/example/lib/hooks/use-local-storage.ts +0 -24
- package/example/lib/hooks/use-scroll-anchor.tsx +0 -86
- package/example/lib/hooks/use-sidebar.tsx +0 -60
- package/example/lib/hooks/use-streamable-text.ts +0 -25
- package/example/lib/types.ts +0 -41
- package/example/lib/utils.ts +0 -89
- package/example/middleware.ts +0 -8
- package/example/next-env.d.ts +0 -5
- package/example/next.config.js +0 -16
- package/example/package-lock.json +0 -9990
- package/example/package.json +0 -84
- package/example/pnpm-lock.yaml +0 -5712
- package/example/postcss.config.js +0 -6
- package/example/prettier.config.cjs +0 -34
- package/example/public/apple-touch-icon.png +0 -0
- package/example/public/favicon-16x16.png +0 -0
- package/example/public/favicon.ico +0 -0
- package/example/public/next.svg +0 -1
- package/example/public/thirteen.svg +0 -1
- package/example/public/vercel.svg +0 -1
- package/example/tailwind.config.ts +0 -81
- package/example/tsconfig.json +0 -35
- package/src/LangWatchExporter.ts +0 -91
- package/src/evaluations.ts +0 -219
- package/src/index.test.ts +0 -402
- package/src/langchain.ts +0 -557
- package/src/typeUtils.ts +0 -89
- package/src/types.ts +0 -79
- package/src/utils.ts +0 -205
- /package/src/{server/types → internal/generated/openapi}/.gitkeep +0 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filterable Batch Span Exporter for OpenTelemetry
|
|
3
|
+
*
|
|
4
|
+
* This module provides a BatchSpanProcessor subclass that allows filtering of spans before export
|
|
5
|
+
* based on configurable rules. Spans matching any exclude rule are dropped and not exported.
|
|
6
|
+
*
|
|
7
|
+
* @module filterable-batch-span-exporter
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
BatchSpanProcessor,
|
|
12
|
+
ReadableSpan,
|
|
13
|
+
SpanExporter,
|
|
14
|
+
} from '@opentelemetry/sdk-trace-base';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A rule for excluding spans from export based on their name or instrumentation scope name.
|
|
18
|
+
*
|
|
19
|
+
* @property fieldName - The span field to match against ('span_name' or 'instrumentation_scope_name').
|
|
20
|
+
* @property matchValue - The value to match against the field.
|
|
21
|
+
* @property matchOperation - The operation to use for matching ('includes', 'exact_match', 'starts_with', 'ends_with').
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const rule: SpanProcessingExcludeRule = {
|
|
25
|
+
* fieldName: 'span_name',
|
|
26
|
+
* matchValue: 'heartbeat',
|
|
27
|
+
* matchOperation: 'exact_match',
|
|
28
|
+
* };
|
|
29
|
+
*/
|
|
30
|
+
export interface SpanProcessingExcludeRule {
|
|
31
|
+
fieldName: "span_name" | "instrumentation_scope_name";
|
|
32
|
+
matchValue: string;
|
|
33
|
+
matchOperation: "includes" | "exact_match" | "starts_with" | "ends_with";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A BatchSpanProcessor that filters out spans matching any of the provided exclude rules before export.
|
|
38
|
+
*
|
|
39
|
+
* This is useful for dropping noisy or irrelevant spans (e.g., health checks, heartbeats) from being exported to your tracing backend.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* import { FilterableBatchSpanProcessor } from './filterable-batch-span-exporter';
|
|
43
|
+
* import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
|
44
|
+
*
|
|
45
|
+
* const exporter = new OTLPTraceExporter({ url: '...' });
|
|
46
|
+
* const filters = [
|
|
47
|
+
* { fieldName: 'span_name', matchValue: 'heartbeat', matchOperation: 'exact_match' },
|
|
48
|
+
* { fieldName: 'instrumentation_scope_name', matchValue: 'internal', matchOperation: 'starts_with' },
|
|
49
|
+
* ];
|
|
50
|
+
* provider.addSpanProcessor(new FilterableBatchSpanProcessor(exporter, filters));
|
|
51
|
+
*/
|
|
52
|
+
export class FilterableBatchSpanProcessor extends BatchSpanProcessor {
|
|
53
|
+
private readonly _filters: SpanProcessingExcludeRule[];
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Create a new FilterableBatchSpanProcessor.
|
|
57
|
+
*
|
|
58
|
+
* @param exporter - The underlying SpanExporter to use for exporting spans.
|
|
59
|
+
* @param filters - An array of rules for excluding spans from export.
|
|
60
|
+
*/
|
|
61
|
+
constructor(exporter: SpanExporter, filters: SpanProcessingExcludeRule[]) {
|
|
62
|
+
super(exporter);
|
|
63
|
+
this._filters = filters;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Called when a span ends. If the span matches any exclude rule, it is dropped and not exported.
|
|
68
|
+
*
|
|
69
|
+
* @param span - The ReadableSpan that has ended.
|
|
70
|
+
*/
|
|
71
|
+
override onEnd(span: ReadableSpan): void {
|
|
72
|
+
for (const filter of this._filters) {
|
|
73
|
+
let sourceValue: string;
|
|
74
|
+
|
|
75
|
+
if (filter.fieldName === "span_name") {
|
|
76
|
+
sourceValue = span.name;
|
|
77
|
+
} else if (filter.fieldName === "instrumentation_scope_name") {
|
|
78
|
+
sourceValue = span.instrumentationScope.name;
|
|
79
|
+
} else {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const matchValue = filter.matchValue;
|
|
84
|
+
const matchOperation = filter.matchOperation;
|
|
85
|
+
|
|
86
|
+
switch (true) {
|
|
87
|
+
case matchOperation === "exact_match" && sourceValue === matchValue:
|
|
88
|
+
case matchOperation === "includes" && sourceValue.includes(matchValue):
|
|
89
|
+
case matchOperation === "starts_with" && sourceValue.startsWith(matchValue):
|
|
90
|
+
case matchOperation === "ends_with" && sourceValue.endsWith(matchValue):
|
|
91
|
+
return;
|
|
92
|
+
|
|
93
|
+
default: break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
super.onEnd(span);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./filterable-batch-span-processor";
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/*
|
|
2
|
+
This file contains the semantic conventions for attributes either owned by LangWatch, or
|
|
3
|
+
which are no yet part of the OpenTelemetry semantic conventions for Gen AI.
|
|
4
|
+
|
|
5
|
+
Any that are not yet part of the OpenTelemetry semantic conventions for Gen AI are
|
|
6
|
+
marked with an UNSTABLE_ prefix.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* LangWatch input data attribute key
|
|
11
|
+
* Used to store the input data for a span or event
|
|
12
|
+
*/
|
|
13
|
+
export const ATTR_LANGWATCH_INPUT = "langwatch.input";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* LangWatch output data attribute key
|
|
17
|
+
* Used to store the output data for a span or event
|
|
18
|
+
*/
|
|
19
|
+
export const ATTR_LANGWATCH_OUTPUT = "langwatch.output";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* LangWatch span type attribute key
|
|
23
|
+
* Used to identify the type of span being traced
|
|
24
|
+
*/
|
|
25
|
+
export const ATTR_LANGWATCH_SPAN_TYPE = "langwatch.span.type";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* LangWatch RAG contexts attribute key
|
|
29
|
+
* Used to store retrieval-augmented generation contexts
|
|
30
|
+
*/
|
|
31
|
+
export const ATTR_LANGWATCH_RAG_CONTEXTS = "langwatch.contexts";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* LangWatch metrics attribute key
|
|
35
|
+
* Used to store custom metrics data
|
|
36
|
+
*/
|
|
37
|
+
export const ATTR_LANGWATCH_METRICS = "langwatch.metrics";
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* LangWatch SDK version attribute key
|
|
41
|
+
* Used to track the version of the LangWatch SDK being used
|
|
42
|
+
*/
|
|
43
|
+
export const ATTR_LANGWATCH_SDK_VERSION = "langwatch.sdk.version";
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* LangWatch SDK name attribute key
|
|
47
|
+
* Used to identify the LangWatch SDK implementation
|
|
48
|
+
*/
|
|
49
|
+
export const ATTR_LANGWATCH_SDK_NAME = "langwatch.sdk.name";
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* LangWatch SDK language attribute key
|
|
53
|
+
* Used to identify the programming language of the SDK
|
|
54
|
+
*/
|
|
55
|
+
export const ATTR_LANGWATCH_SDK_LANGUAGE = "langwatch.sdk.language";
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* LangWatch timestamps attribute key
|
|
59
|
+
* Used to store timing information for events
|
|
60
|
+
*/
|
|
61
|
+
export const ATTR_LANGWATCH_TIMESTAMPS = "langwatch.timestamps";
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* LangWatch custom evaluation attribute key
|
|
65
|
+
* Used to store custom evaluation data
|
|
66
|
+
*/
|
|
67
|
+
export const ATTR_LANGWATCH_EVALUATION_CUSTOM = "langwatch.evaluation.custom";
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* LangWatch parameters attribute key
|
|
71
|
+
* Used to store parameter data for operations
|
|
72
|
+
*/
|
|
73
|
+
export const ATTR_LANGWATCH_PARAMS = "langwatch.params";
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* LangWatch customer ID attribute key
|
|
77
|
+
* Used to identify the customer associated with the trace
|
|
78
|
+
*/
|
|
79
|
+
export const ATTR_LANGWATCH_CUSTOMER_ID = "langwatch.customer.id";
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* LangWatch thread ID attribute key
|
|
83
|
+
* Used to group related operations within a conversation thread
|
|
84
|
+
*/
|
|
85
|
+
export const ATTR_LANGWATCH_THREAD_ID = "langwatch.thread.id";
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* LangWatch streaming attribute key
|
|
89
|
+
* Used to indicate if the operation involves streaming
|
|
90
|
+
*/
|
|
91
|
+
export const ATTR_LANGWATCH_STREAMING = "langwatch.gen_ai.streaming";
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* LangWatch prompt ID attribute key
|
|
95
|
+
* Used to identify the specific prompt being used
|
|
96
|
+
*/
|
|
97
|
+
export const ATTR_LANGWATCH_PROMPT_ID = "langwatch.prompt.id";
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* LangWatch prompt version ID attribute key
|
|
101
|
+
* Used to identify the specific version of a prompt
|
|
102
|
+
*/
|
|
103
|
+
export const ATTR_LANGWATCH_PROMPT_VERSION_ID = "langwatch.prompt.version.id";
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* LangWatch prompt variables attribute key
|
|
107
|
+
* Used to store variables used in prompt templates
|
|
108
|
+
*/
|
|
109
|
+
export const ATTR_LANGWATCH_PROMPT_VARIABLES = "langwatch.prompt.variables";
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* LangWatch prompt selected ID attribute key
|
|
113
|
+
* Used to identify which prompt was selected from a set
|
|
114
|
+
*/
|
|
115
|
+
export const ATTR_LANGWATCH_PROMPT_SELECTED_ID = "langwatch.prompt.selected.id";
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* LangWatch prompt version number attribute key
|
|
119
|
+
* Used to track the version number of a prompt
|
|
120
|
+
*/
|
|
121
|
+
export const ATTR_LANGWATCH_PROMPT_VERSION_NUMBER =
|
|
122
|
+
"langwatch.prompt.version.number";
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* LangWatch gen AI log event imposter attribute key
|
|
126
|
+
* Used to identify imposter events in log records
|
|
127
|
+
*/
|
|
128
|
+
export const ATTR_LANGWATCH_GEN_AI_LOG_EVENT_IMPOSTER =
|
|
129
|
+
"langwatch.gen_ai.log_event.imposter";
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* LangWatch gen AI log event body attribute key
|
|
133
|
+
* Used to store the body content of log events
|
|
134
|
+
*/
|
|
135
|
+
export const ATTR_LANGWATCH_GEN_AI_LOG_EVENT_BODY =
|
|
136
|
+
"langwatch.gen_ai.log_event.body";
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* LangWatch LangChain tags attribute key
|
|
140
|
+
* Used to store tags associated with LangChain operations
|
|
141
|
+
*/
|
|
142
|
+
export const ATTR_LANGWATCH_LANGCHAIN_TAGS = "langwatch.langchain.tags";
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* LangWatch LangChain event name attribute key
|
|
146
|
+
* Used to identify the specific LangChain event type
|
|
147
|
+
*/
|
|
148
|
+
export const ATTR_LANGWATCH_LANGCHAIN_EVENT_NAME = "langwatch.langchain.event_name";
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* LangWatch LangChain run ID attribute key
|
|
152
|
+
* Used to identify a specific LangChain run
|
|
153
|
+
*/
|
|
154
|
+
export const ATTR_LANGWATCH_LANGCHAIN_RUN_ID = "langwatch.langchain.run.id";
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* LangWatch LangChain run tags attribute key
|
|
158
|
+
* Used to store tags associated with a LangChain run
|
|
159
|
+
*/
|
|
160
|
+
export const ATTR_LANGWATCH_LANGCHAIN_RUN_TAGS = "langwatch.langchain.run.tags";
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* LangWatch LangChain run type attribute key
|
|
164
|
+
* Used to identify the type of LangChain run
|
|
165
|
+
*/
|
|
166
|
+
export const ATTR_LANGWATCH_LANGCHAIN_RUN_TYPE = "langwatch.langchain.run.type";
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* LangWatch LangChain run metadata attribute key
|
|
170
|
+
* Used to store metadata associated with a LangChain run
|
|
171
|
+
*/
|
|
172
|
+
export const ATTR_LANGWATCH_LANGCHAIN_RUN_METADATA = "langwatch.langchain.run.metadata";
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* LangWatch LangChain run extra parameters attribute key
|
|
176
|
+
* Used to store additional parameters for a LangChain run
|
|
177
|
+
*/
|
|
178
|
+
export const ATTR_LANGWATCH_LANGCHAIN_RUN_EXTRA_PARAMS = "langwatch.langchain.run.extra_params";
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* LangWatch LangChain run parent ID attribute key
|
|
182
|
+
* Used to identify the parent run in a hierarchical structure
|
|
183
|
+
*/
|
|
184
|
+
export const ATTR_LANGWATCH_LANGCHAIN_RUN_PARENT_ID =
|
|
185
|
+
"langwatch.langchain.run.parent.id";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
This file contains the values for the OpenTelemetry semantic conventions for GenAI log
|
|
3
|
+
record event names.
|
|
4
|
+
|
|
5
|
+
👉 https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-events/
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* GenAI system message event name
|
|
10
|
+
* Used for log records representing system messages in AI conversations
|
|
11
|
+
*/
|
|
12
|
+
export const LOG_EVNT_GEN_AI_SYSTEM_MESSAGE = "gen.ai.system_message";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* GenAI user message event name
|
|
16
|
+
* Used for log records representing user messages in AI conversations
|
|
17
|
+
*/
|
|
18
|
+
export const LOG_EVNT_GEN_AI_USER_MESSAGE = "gen.ai.user_message";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* GenAI assistant message event name
|
|
22
|
+
* Used for log records representing assistant responses in AI conversations
|
|
23
|
+
*/
|
|
24
|
+
export const LOG_EVNT_GEN_AI_ASSISTANT_MESSAGE = "gen.ai.assistant_message";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* GenAI tool message event name
|
|
28
|
+
* Used for log records representing tool calls or responses in AI conversations
|
|
29
|
+
*/
|
|
30
|
+
export const LOG_EVNT_GEN_AI_TOOL_MESSAGE = "gen.ai.tool_message";
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* GenAI choice event name
|
|
34
|
+
* Used for log records representing choices made by AI models
|
|
35
|
+
*/
|
|
36
|
+
export const LOG_EVNT_GEN_AI_CHOICE = "gen.ai.choice";
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* LangWatch LangChain callback event name
|
|
40
|
+
* Used for log records representing LangChain callback events
|
|
41
|
+
*/
|
|
42
|
+
export const EVNT_LANGWATCH_LANGCHAIN_CALLBACK = "langwatch.langchain.callback";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Semantic conventions module for LangWatch observability
|
|
3
|
+
*
|
|
4
|
+
* This module exports all semantic convention constants used for:
|
|
5
|
+
* - Attributes: Key-value pairs for span and event metadata
|
|
6
|
+
* - Values: Predefined values for semantic convention attributes
|
|
7
|
+
* - Events: Event names for log records and traces
|
|
8
|
+
*
|
|
9
|
+
* @see {@link ./attributes} for attribute constants
|
|
10
|
+
* @see {@link ./values} for value constants
|
|
11
|
+
* @see {@link ./events} for event constants
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export * from "./attributes";
|
|
15
|
+
export * from "./values";
|
|
16
|
+
export * from "./events";
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/*
|
|
2
|
+
This file contains the values for the OpenTelemetry semantic conventions for Gen AI,
|
|
3
|
+
some of which are still in development and therefor currently considered to be
|
|
4
|
+
experimental.
|
|
5
|
+
|
|
6
|
+
👉 https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-events/
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Anthropic AI system identifier
|
|
11
|
+
* Used to identify Anthropic's Claude models
|
|
12
|
+
*/
|
|
13
|
+
export const VAL_GEN_AI_SYSTEM_ANTHROPIC = "anthropic";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* AWS Bedrock system identifier
|
|
17
|
+
* Used to identify AWS Bedrock AI services
|
|
18
|
+
*/
|
|
19
|
+
export const VAL_GEN_AI_SYSTEM_AWS_BEDROCK = "aws.bedrock";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Azure AI Inference system identifier
|
|
23
|
+
* Used to identify Azure AI Inference services
|
|
24
|
+
*/
|
|
25
|
+
export const VAL_GEN_AI_SYSTEM_AZURE_AI_INFERENCE = "azure.ai.inference";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Azure AI OpenAI system identifier
|
|
29
|
+
* Used to identify Azure OpenAI services
|
|
30
|
+
*/
|
|
31
|
+
export const VAL_GEN_AI_SYSTEM_AZURE_AI_OPENAI = "azure.ai.openai";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Cohere system identifier
|
|
35
|
+
* Used to identify Cohere AI models
|
|
36
|
+
*/
|
|
37
|
+
export const VAL_GEN_AI_SYSTEM_COHERE = "cohere";
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* DeepSeek system identifier
|
|
41
|
+
* Used to identify DeepSeek AI models
|
|
42
|
+
*/
|
|
43
|
+
export const VAL_GEN_AI_SYSTEM_DEEPSEEK = "deepseek";
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* GCP Gemini system identifier
|
|
47
|
+
* Used to identify Google Cloud Gemini models
|
|
48
|
+
*/
|
|
49
|
+
export const VAL_GEN_AI_SYSTEM_GCP_GEMINI = "gcp.gemini";
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* GCP Gen AI system identifier
|
|
53
|
+
* Used to identify Google Cloud Generative AI services
|
|
54
|
+
*/
|
|
55
|
+
export const VAL_GEN_AI_SYSTEM_GCP_GEN_AI = "gcp.gen_ai";
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* GCP Vertex AI system identifier
|
|
59
|
+
* Used to identify Google Cloud Vertex AI services
|
|
60
|
+
*/
|
|
61
|
+
export const VAL_GEN_AI_SYSTEM_GCP_VERTEX_AI = "gcp.vertex_ai";
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Groq system identifier
|
|
65
|
+
* Used to identify Groq AI models
|
|
66
|
+
*/
|
|
67
|
+
export const VAL_GEN_AI_SYSTEM_GROQ = "groq";
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* IBM WatsonX AI system identifier
|
|
71
|
+
* Used to identify IBM WatsonX AI services
|
|
72
|
+
*/
|
|
73
|
+
export const VAL_GEN_AI_SYSTEM_IBM_WATSONX_AI = "ibm.watsonx.ai";
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Mistral AI system identifier
|
|
77
|
+
* Used to identify Mistral AI models
|
|
78
|
+
*/
|
|
79
|
+
export const VAL_GEN_AI_SYSTEM_MISTRAL_AI = "mistral_ai";
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* OpenAI system identifier
|
|
83
|
+
* Used to identify OpenAI models and services
|
|
84
|
+
*/
|
|
85
|
+
export const VAL_GEN_AI_SYSTEM_OPENAI = "openai";
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Perplexity system identifier
|
|
89
|
+
* Used to identify Perplexity AI models
|
|
90
|
+
*/
|
|
91
|
+
export const VAL_GEN_AI_SYSTEM_PERPLEXITY = "perplexity";
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* XAI system identifier
|
|
95
|
+
* Used to identify XAI models and services
|
|
96
|
+
*/
|
|
97
|
+
export const VAL_GEN_AI_SYSTEM_XAI = "xai";
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Content filter finish reason
|
|
101
|
+
* Used when generation stops due to content filtering
|
|
102
|
+
*/
|
|
103
|
+
export const VAL_GEN_AI_FINISH_REASON_CONTENT_FILTER = "content_filter";
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Error finish reason
|
|
107
|
+
* Used when generation stops due to an error
|
|
108
|
+
*/
|
|
109
|
+
export const VAL_GEN_AI_FINISH_REASON_ERROR = "error";
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Length finish reason
|
|
113
|
+
* Used when generation stops due to length limits
|
|
114
|
+
*/
|
|
115
|
+
export const VAL_GEN_AI_FINISH_REASON_LENGTH = "length";
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Stop finish reason
|
|
119
|
+
* Used when generation stops due to stop tokens
|
|
120
|
+
*/
|
|
121
|
+
export const VAL_GEN_AI_FINISH_REASON_STOP = "stop";
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Tool calls finish reason
|
|
125
|
+
* Used when generation stops due to tool calls
|
|
126
|
+
*/
|
|
127
|
+
export const VAL_GEN_AI_FINISH_REASON_TOOL_CALLS = "tool_calls";
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Union type of all supported GenAI system identifiers
|
|
131
|
+
* Used for type safety when working with system identification
|
|
132
|
+
*/
|
|
133
|
+
export type VAL_GEN_AI_SYSTEMS =
|
|
134
|
+
| typeof VAL_GEN_AI_SYSTEM_ANTHROPIC
|
|
135
|
+
| typeof VAL_GEN_AI_SYSTEM_AWS_BEDROCK
|
|
136
|
+
| typeof VAL_GEN_AI_SYSTEM_AZURE_AI_INFERENCE
|
|
137
|
+
| typeof VAL_GEN_AI_SYSTEM_AZURE_AI_OPENAI
|
|
138
|
+
| typeof VAL_GEN_AI_SYSTEM_COHERE
|
|
139
|
+
| typeof VAL_GEN_AI_SYSTEM_DEEPSEEK
|
|
140
|
+
| typeof VAL_GEN_AI_SYSTEM_GCP_GEMINI
|
|
141
|
+
| typeof VAL_GEN_AI_SYSTEM_GCP_GEN_AI
|
|
142
|
+
| typeof VAL_GEN_AI_SYSTEM_GCP_VERTEX_AI
|
|
143
|
+
| typeof VAL_GEN_AI_SYSTEM_GROQ
|
|
144
|
+
| typeof VAL_GEN_AI_SYSTEM_IBM_WATSONX_AI
|
|
145
|
+
| typeof VAL_GEN_AI_SYSTEM_MISTRAL_AI
|
|
146
|
+
| typeof VAL_GEN_AI_SYSTEM_OPENAI
|
|
147
|
+
| typeof VAL_GEN_AI_SYSTEM_PERPLEXITY
|
|
148
|
+
| typeof VAL_GEN_AI_SYSTEM_XAI;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Union type of all supported GenAI finish reasons
|
|
152
|
+
* Used for type safety when working with generation completion reasons
|
|
153
|
+
*/
|
|
154
|
+
export type VAL_GEN_AI_FINISH_REASONS =
|
|
155
|
+
| typeof VAL_GEN_AI_FINISH_REASON_CONTENT_FILTER
|
|
156
|
+
| typeof VAL_GEN_AI_FINISH_REASON_ERROR
|
|
157
|
+
| typeof VAL_GEN_AI_FINISH_REASON_LENGTH
|
|
158
|
+
| typeof VAL_GEN_AI_FINISH_REASON_STOP
|
|
159
|
+
| typeof VAL_GEN_AI_FINISH_REASON_TOOL_CALLS;
|