@mastra/core 1.18.1-alpha.0 → 1.19.0-alpha.2
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/CHANGELOG.md +32 -0
- package/dist/agent/agent-legacy.d.ts +3 -1
- package/dist/agent/agent-legacy.d.ts.map +1 -1
- package/dist/agent/agent.d.ts +3 -1
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/index.cjs +8 -8
- package/dist/agent/index.js +1 -1
- package/dist/agent/workflows/prepare-stream/map-results-step.d.ts.map +1 -1
- package/dist/{chunk-AV4YSAZL.cjs → chunk-2OYWVA6F.cjs} +17 -2
- package/dist/chunk-2OYWVA6F.cjs.map +1 -0
- package/dist/{chunk-45LU555A.cjs → chunk-2RTFET56.cjs} +7 -7
- package/dist/{chunk-45LU555A.cjs.map → chunk-2RTFET56.cjs.map} +1 -1
- package/dist/{chunk-LKZQG2ZZ.cjs → chunk-4TUILCMR.cjs} +7 -6
- package/dist/chunk-4TUILCMR.cjs.map +1 -0
- package/dist/{chunk-NMDKJUHA.cjs → chunk-5OBBDZBA.cjs} +185 -185
- package/dist/{chunk-NMDKJUHA.cjs.map → chunk-5OBBDZBA.cjs.map} +1 -1
- package/dist/{chunk-OF7ELKXY.js → chunk-6TEEIOHA.js} +4 -4
- package/dist/{chunk-OF7ELKXY.js.map → chunk-6TEEIOHA.js.map} +1 -1
- package/dist/{chunk-KG5NOH3Z.js → chunk-6XYHMM2X.js} +8 -8
- package/dist/{chunk-KG5NOH3Z.js.map → chunk-6XYHMM2X.js.map} +1 -1
- package/dist/{chunk-IVXAQT6H.js → chunk-BS5UESNT.js} +93 -42
- package/dist/chunk-BS5UESNT.js.map +1 -0
- package/dist/{chunk-NRIT3KHS.js → chunk-CSIKD56W.js} +3 -3
- package/dist/{chunk-NRIT3KHS.js.map → chunk-CSIKD56W.js.map} +1 -1
- package/dist/{chunk-KEYCLRBI.js → chunk-D5EXC3XM.js} +4 -4
- package/dist/{chunk-KEYCLRBI.js.map → chunk-D5EXC3XM.js.map} +1 -1
- package/dist/{chunk-XQRTJIC7.cjs → chunk-E2SMTTP6.cjs} +45 -16
- package/dist/chunk-E2SMTTP6.cjs.map +1 -0
- package/dist/{chunk-RVBOSWN5.cjs → chunk-E3JUOJME.cjs} +5 -5
- package/dist/{chunk-RVBOSWN5.cjs.map → chunk-E3JUOJME.cjs.map} +1 -1
- package/dist/{chunk-FA4PTEBK.js → chunk-EWPUWV33.js} +18 -3
- package/dist/chunk-EWPUWV33.js.map +1 -0
- package/dist/{chunk-BWRB3RPC.js → chunk-F4PVOQKD.js} +3 -3
- package/dist/{chunk-BWRB3RPC.js.map → chunk-F4PVOQKD.js.map} +1 -1
- package/dist/{chunk-TJNYXDI7.cjs → chunk-GFQPMPSV.cjs} +7 -113
- package/dist/chunk-GFQPMPSV.cjs.map +1 -0
- package/dist/{chunk-V2NQOABM.cjs → chunk-GNA52EF4.cjs} +9 -9
- package/dist/{chunk-V2NQOABM.cjs.map → chunk-GNA52EF4.cjs.map} +1 -1
- package/dist/{chunk-GALW5K2E.js → chunk-IOHKSHT4.js} +3 -3
- package/dist/{chunk-GALW5K2E.js.map → chunk-IOHKSHT4.js.map} +1 -1
- package/dist/{chunk-Z7DO2WCR.cjs → chunk-IQV2SVCE.cjs} +52 -52
- package/dist/{chunk-Z7DO2WCR.cjs.map → chunk-IQV2SVCE.cjs.map} +1 -1
- package/dist/{chunk-GXXNF6NF.cjs → chunk-L2FL7HMV.cjs} +35 -30
- package/dist/chunk-L2FL7HMV.cjs.map +1 -0
- package/dist/{chunk-HZI7AYCD.js → chunk-M62LMDHE.js} +8 -7
- package/dist/chunk-M62LMDHE.js.map +1 -0
- package/dist/{chunk-TPE5VTVF.cjs → chunk-MN7WNZE6.cjs} +6 -6
- package/dist/{chunk-TPE5VTVF.cjs.map → chunk-MN7WNZE6.cjs.map} +1 -1
- package/dist/{chunk-7W6PDCOH.cjs → chunk-NWOPWLJ3.cjs} +83 -82
- package/dist/chunk-NWOPWLJ3.cjs.map +1 -0
- package/dist/{chunk-CJ4RMDJJ.cjs → chunk-O542TXPV.cjs} +145 -94
- package/dist/chunk-O542TXPV.cjs.map +1 -0
- package/dist/{chunk-4FMKWOPC.js → chunk-OZHBY6NY.js} +32 -5
- package/dist/chunk-OZHBY6NY.js.map +1 -0
- package/dist/{chunk-MJF7NZEF.js → chunk-PPCEPCG7.js} +3 -3
- package/dist/{chunk-MJF7NZEF.js.map → chunk-PPCEPCG7.js.map} +1 -1
- package/dist/{chunk-CU764D5P.cjs → chunk-QB4YHCVA.cjs} +15 -15
- package/dist/{chunk-CU764D5P.cjs.map → chunk-QB4YHCVA.cjs.map} +1 -1
- package/dist/{chunk-K7AE4BHR.js → chunk-QIOD3LOP.js} +4 -3
- package/dist/chunk-QIOD3LOP.js.map +1 -0
- package/dist/{chunk-DTT543MP.cjs → chunk-RD76XK7E.cjs} +3 -3
- package/dist/{chunk-DTT543MP.cjs.map → chunk-RD76XK7E.cjs.map} +1 -1
- package/dist/{chunk-HRT662B6.js → chunk-SVIEJH5H.js} +13 -8
- package/dist/chunk-SVIEJH5H.js.map +1 -0
- package/dist/{chunk-KFL6ZGWG.js → chunk-VYZRHQUD.js} +5 -5
- package/dist/{chunk-KFL6ZGWG.js.map → chunk-VYZRHQUD.js.map} +1 -1
- package/dist/{chunk-H5ZOJOQ2.cjs → chunk-WKAEIA42.cjs} +9 -9
- package/dist/{chunk-H5ZOJOQ2.cjs.map → chunk-WKAEIA42.cjs.map} +1 -1
- package/dist/{chunk-L3V6LSQF.js → chunk-X5BBF6AG.js} +3 -3
- package/dist/{chunk-L3V6LSQF.js.map → chunk-X5BBF6AG.js.map} +1 -1
- package/dist/{chunk-WGJL6F3F.js → chunk-Z6I5PBGG.js} +6 -112
- package/dist/chunk-Z6I5PBGG.js.map +1 -0
- package/dist/datasets/index.cjs +17 -17
- package/dist/datasets/index.js +2 -2
- package/dist/docs/SKILL.md +8 -18
- package/dist/docs/assets/SOURCE_MAP.json +266 -266
- package/dist/docs/references/docs-agents-overview.md +4 -4
- package/dist/docs/references/docs-agents-processors.md +1 -1
- package/dist/docs/references/{docs-observability-datasets-overview.md → docs-evals-datasets-overview.md} +12 -12
- package/dist/docs/references/{docs-observability-datasets-running-experiments.md → docs-evals-datasets-running-experiments.md} +9 -9
- package/dist/docs/references/docs-evals-overview.md +8 -9
- package/dist/docs/references/docs-memory-observational-memory.md +20 -11
- package/dist/docs/references/docs-memory-overview.md +4 -4
- package/dist/docs/references/docs-memory-semantic-recall.md +28 -19
- package/dist/docs/references/docs-memory-storage.md +4 -4
- package/dist/docs/references/docs-rag-chunking-and-embedding.md +2 -2
- package/dist/docs/references/docs-server-auth-composite-auth.md +1 -7
- package/dist/docs/references/docs-server-auth-custom-auth-provider.md +2 -4
- package/dist/docs/references/docs-server-auth-jwt.md +1 -1
- package/dist/docs/references/docs-server-auth-simple-auth.md +1 -7
- package/dist/docs/references/docs-server-custom-adapters.md +3 -1
- package/dist/docs/references/docs-server-custom-api-routes.md +1 -1
- package/dist/docs/references/docs-server-mastra-client.md +1 -3
- package/dist/docs/references/docs-server-mastra-server.md +8 -0
- package/dist/docs/references/docs-server-request-context.md +17 -17
- package/dist/docs/references/docs-streaming-events.md +1 -90
- package/dist/docs/references/docs-studio-auth.md +142 -0
- package/dist/docs/references/docs-studio-deployment.md +260 -0
- package/dist/docs/references/docs-studio-observability.md +98 -0
- package/dist/docs/references/docs-studio-overview.md +127 -0
- package/dist/docs/references/docs-workflows-agents-and-tools.md +7 -10
- package/dist/docs/references/docs-workflows-control-flow.md +1 -1
- package/dist/docs/references/docs-workflows-overview.md +12 -7
- package/dist/docs/references/docs-workflows-suspend-and-resume.md +1 -1
- package/dist/docs/references/guides-concepts-multi-agent-systems.md +4 -4
- package/dist/docs/references/reference-agents-agent.md +1 -1
- package/dist/docs/references/reference-configuration.md +4 -4
- package/dist/docs/references/reference-memory-observational-memory.md +1 -1
- package/dist/docs/references/reference-storage-cloudflare-d1.md +1 -1
- package/dist/docs/references/reference-storage-lance.md +1 -1
- package/dist/docs/references/reference-storage-upstash.md +1 -1
- package/dist/docs/references/reference.md +16 -14
- package/dist/evals/index.cjs +5 -5
- package/dist/evals/index.js +2 -2
- package/dist/evals/scoreTraces/index.cjs +3 -3
- package/dist/evals/scoreTraces/index.js +1 -1
- package/dist/harness/harness.d.ts.map +1 -1
- package/dist/harness/index.cjs +19 -18
- package/dist/harness/index.cjs.map +1 -1
- package/dist/harness/index.js +9 -8
- package/dist/harness/index.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/integration/index.cjs +2 -2
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.cjs +16 -16
- package/dist/llm/index.js +5 -5
- package/dist/llm/model/aisdk/v5/model.d.ts +5 -0
- package/dist/llm/model/aisdk/v5/model.d.ts.map +1 -1
- package/dist/llm/model/aisdk/v6/model.d.ts +5 -0
- package/dist/llm/model/aisdk/v6/model.d.ts.map +1 -1
- package/dist/llm/model/provider-types.generated.d.ts +1 -50
- package/dist/loop/index.cjs +14 -14
- package/dist/loop/index.js +1 -1
- package/dist/loop/network/validation.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +14 -14
- package/dist/memory/index.js +1 -1
- package/dist/models-dev-VAVD7BDV.cjs +12 -0
- package/dist/{models-dev-674ULLFE.cjs.map → models-dev-VAVD7BDV.cjs.map} +1 -1
- package/dist/models-dev-VFIUOVG4.js +3 -0
- package/dist/{models-dev-AVV7SNWL.js.map → models-dev-VFIUOVG4.js.map} +1 -1
- package/dist/netlify-KL3UR26O.cjs +12 -0
- package/dist/{netlify-QP3MZ4FK.cjs.map → netlify-KL3UR26O.cjs.map} +1 -1
- package/dist/netlify-Q3SJTV4U.js +3 -0
- package/dist/{netlify-KWEJPG27.js.map → netlify-Q3SJTV4U.js.map} +1 -1
- package/dist/processor-provider/index.cjs +10 -10
- package/dist/processor-provider/index.js +1 -1
- package/dist/processors/index.cjs +44 -44
- package/dist/processors/index.js +1 -1
- package/dist/provider-registry-COX4XKGI.js +3 -0
- package/dist/{provider-registry-L3LFTZUA.js.map → provider-registry-COX4XKGI.js.map} +1 -1
- package/dist/provider-registry-IAU4XHVY.cjs +40 -0
- package/dist/{provider-registry-KZN4FOFE.cjs.map → provider-registry-IAU4XHVY.cjs.map} +1 -1
- package/dist/provider-registry.json +2 -108
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/storage/index.cjs +74 -74
- package/dist/storage/index.js +1 -1
- package/dist/stream/aisdk/v5/compat/prepare-tools.d.ts.map +1 -1
- package/dist/stream/index.cjs +8 -8
- package/dist/stream/index.js +1 -1
- package/dist/test-utils/llm-mock.cjs +4 -4
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/tool-loop-agent/index.cjs +4 -4
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/tools/index.cjs +8 -8
- package/dist/tools/index.js +1 -1
- package/dist/tools/is-vercel-tool.cjs +2 -2
- package/dist/tools/is-vercel-tool.js +1 -1
- package/dist/tools/tool-builder/builder.d.ts.map +1 -1
- package/dist/tools/validation.d.ts.map +1 -1
- package/dist/utils.cjs +31 -23
- package/dist/utils.d.ts +10 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/vector/index.cjs +7 -7
- package/dist/vector/index.js +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/index.cjs +24 -24
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/dist/workspace/index.cjs +68 -68
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/workspace.d.ts +1 -0
- package/dist/workspace/workspace.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/llm/model/provider-types.generated.d.ts +1 -50
- package/dist/chunk-4FMKWOPC.js.map +0 -1
- package/dist/chunk-7W6PDCOH.cjs.map +0 -1
- package/dist/chunk-AV4YSAZL.cjs.map +0 -1
- package/dist/chunk-CJ4RMDJJ.cjs.map +0 -1
- package/dist/chunk-FA4PTEBK.js.map +0 -1
- package/dist/chunk-GXXNF6NF.cjs.map +0 -1
- package/dist/chunk-HRT662B6.js.map +0 -1
- package/dist/chunk-HZI7AYCD.js.map +0 -1
- package/dist/chunk-IVXAQT6H.js.map +0 -1
- package/dist/chunk-K7AE4BHR.js.map +0 -1
- package/dist/chunk-LKZQG2ZZ.cjs.map +0 -1
- package/dist/chunk-TJNYXDI7.cjs.map +0 -1
- package/dist/chunk-WGJL6F3F.js.map +0 -1
- package/dist/chunk-XQRTJIC7.cjs.map +0 -1
- package/dist/docs/references/docs-observability-logging.md +0 -99
- package/dist/docs/references/docs-observability-overview.md +0 -70
- package/dist/docs/references/docs-observability-tracing-bridges-otel.md +0 -209
- package/dist/docs/references/docs-observability-tracing-exporters-arize.md +0 -272
- package/dist/docs/references/docs-observability-tracing-exporters-braintrust.md +0 -126
- package/dist/docs/references/docs-observability-tracing-exporters-cloud.md +0 -127
- package/dist/docs/references/docs-observability-tracing-exporters-datadog.md +0 -317
- package/dist/docs/references/docs-observability-tracing-exporters-default.md +0 -209
- package/dist/docs/references/docs-observability-tracing-exporters-laminar.md +0 -100
- package/dist/docs/references/docs-observability-tracing-exporters-langfuse.md +0 -213
- package/dist/docs/references/docs-observability-tracing-exporters-langsmith.md +0 -198
- package/dist/docs/references/docs-observability-tracing-exporters-otel.md +0 -476
- package/dist/docs/references/docs-observability-tracing-exporters-posthog.md +0 -148
- package/dist/docs/references/docs-observability-tracing-overview.md +0 -1112
- package/dist/models-dev-674ULLFE.cjs +0 -12
- package/dist/models-dev-AVV7SNWL.js +0 -3
- package/dist/netlify-KWEJPG27.js +0 -3
- package/dist/netlify-QP3MZ4FK.cjs +0 -12
- package/dist/provider-registry-KZN4FOFE.cjs +0 -40
- package/dist/provider-registry-L3LFTZUA.js +0 -3
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
# Langfuse exporter
|
|
2
|
-
|
|
3
|
-
[Langfuse](https://langfuse.com/) is an open-source observability platform specifically designed for LLM applications. The Langfuse exporter sends your traces to Langfuse, providing detailed insights into model performance, token usage, and conversation flows.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
**npm**:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install @mastra/langfuse@latest
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
**pnpm**:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
pnpm add @mastra/langfuse@latest
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
**Yarn**:
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
yarn add @mastra/langfuse@latest
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
**Bun**:
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
bun add @mastra/langfuse@latest
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Configuration
|
|
32
|
-
|
|
33
|
-
### Prerequisites
|
|
34
|
-
|
|
35
|
-
1. **Langfuse Account**: Sign up at [cloud.langfuse.com](https://cloud.langfuse.com) or deploy self-hosted
|
|
36
|
-
2. **API Keys**: Create public/secret key pair in Langfuse Settings → API Keys
|
|
37
|
-
3. **Environment Variables**: Set your credentials
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
LANGFUSE_PUBLIC_KEY=pk-lf-xxxxxxxxxxxx
|
|
41
|
-
LANGFUSE_SECRET_KEY=sk-lf-xxxxxxxxxxxx
|
|
42
|
-
LANGFUSE_BASE_URL=https://cloud.langfuse.com # Or your self-hosted URL
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### Zero-Config Setup
|
|
46
|
-
|
|
47
|
-
With environment variables set, use the exporter with no configuration:
|
|
48
|
-
|
|
49
|
-
```typescript
|
|
50
|
-
import { Mastra } from '@mastra/core'
|
|
51
|
-
import { Observability } from '@mastra/observability'
|
|
52
|
-
import { LangfuseExporter } from '@mastra/langfuse'
|
|
53
|
-
|
|
54
|
-
export const mastra = new Mastra({
|
|
55
|
-
observability: new Observability({
|
|
56
|
-
configs: {
|
|
57
|
-
langfuse: {
|
|
58
|
-
serviceName: 'my-service',
|
|
59
|
-
exporters: [new LangfuseExporter()],
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
}),
|
|
63
|
-
})
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### Explicit Configuration
|
|
67
|
-
|
|
68
|
-
You can also pass credentials directly (takes precedence over environment variables):
|
|
69
|
-
|
|
70
|
-
```typescript
|
|
71
|
-
import { Mastra } from '@mastra/core'
|
|
72
|
-
import { Observability } from '@mastra/observability'
|
|
73
|
-
import { LangfuseExporter } from '@mastra/langfuse'
|
|
74
|
-
|
|
75
|
-
export const mastra = new Mastra({
|
|
76
|
-
observability: new Observability({
|
|
77
|
-
configs: {
|
|
78
|
-
langfuse: {
|
|
79
|
-
serviceName: 'my-service',
|
|
80
|
-
exporters: [
|
|
81
|
-
new LangfuseExporter({
|
|
82
|
-
publicKey: process.env.LANGFUSE_PUBLIC_KEY!,
|
|
83
|
-
secretKey: process.env.LANGFUSE_SECRET_KEY!,
|
|
84
|
-
baseUrl: process.env.LANGFUSE_BASE_URL,
|
|
85
|
-
options: {
|
|
86
|
-
environment: process.env.NODE_ENV,
|
|
87
|
-
},
|
|
88
|
-
}),
|
|
89
|
-
],
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
}),
|
|
93
|
-
})
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
## Configuration options
|
|
97
|
-
|
|
98
|
-
### Realtime vs Batch Mode
|
|
99
|
-
|
|
100
|
-
The Langfuse exporter supports two modes for sending traces:
|
|
101
|
-
|
|
102
|
-
#### Realtime Mode (Development)
|
|
103
|
-
|
|
104
|
-
Traces appear immediately in Langfuse dashboard, ideal for debugging:
|
|
105
|
-
|
|
106
|
-
```typescript
|
|
107
|
-
new LangfuseExporter({
|
|
108
|
-
publicKey: process.env.LANGFUSE_PUBLIC_KEY!,
|
|
109
|
-
secretKey: process.env.LANGFUSE_SECRET_KEY!,
|
|
110
|
-
realtime: true, // Flush after each event
|
|
111
|
-
})
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
#### Batch Mode (Production)
|
|
115
|
-
|
|
116
|
-
Better performance with automatic batching:
|
|
117
|
-
|
|
118
|
-
```typescript
|
|
119
|
-
new LangfuseExporter({
|
|
120
|
-
publicKey: process.env.LANGFUSE_PUBLIC_KEY!,
|
|
121
|
-
secretKey: process.env.LANGFUSE_SECRET_KEY!,
|
|
122
|
-
realtime: false, // Default - batch traces
|
|
123
|
-
})
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
### Complete Configuration
|
|
127
|
-
|
|
128
|
-
```typescript
|
|
129
|
-
new LangfuseExporter({
|
|
130
|
-
// Required credentials
|
|
131
|
-
publicKey: process.env.LANGFUSE_PUBLIC_KEY!,
|
|
132
|
-
secretKey: process.env.LANGFUSE_SECRET_KEY!,
|
|
133
|
-
|
|
134
|
-
// Optional settings
|
|
135
|
-
baseUrl: process.env.LANGFUSE_BASE_URL, // Default: https://cloud.langfuse.com
|
|
136
|
-
realtime: process.env.NODE_ENV === 'development', // Dynamic mode selection
|
|
137
|
-
logLevel: 'info', // Diagnostic logging: debug | info | warn | error
|
|
138
|
-
|
|
139
|
-
// Langfuse-specific options
|
|
140
|
-
options: {
|
|
141
|
-
environment: process.env.NODE_ENV, // Shows in UI for filtering
|
|
142
|
-
version: process.env.APP_VERSION, // Track different versions
|
|
143
|
-
release: process.env.GIT_COMMIT, // Git commit hash
|
|
144
|
-
},
|
|
145
|
-
})
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
## Prompt linking
|
|
149
|
-
|
|
150
|
-
You can link LLM generations to prompts stored in [Langfuse Prompt Management](https://langfuse.com/docs/prompt-management). This enables version tracking and metrics for your prompts.
|
|
151
|
-
|
|
152
|
-
### Using the Helper (Recommended)
|
|
153
|
-
|
|
154
|
-
Use `withLangfusePrompt` with `buildTracingOptions` for the cleanest API:
|
|
155
|
-
|
|
156
|
-
```typescript
|
|
157
|
-
import { Agent } from '@mastra/core/agent'
|
|
158
|
-
import { buildTracingOptions } from '@mastra/observability'
|
|
159
|
-
import { withLangfusePrompt } from '@mastra/langfuse'
|
|
160
|
-
import { Langfuse } from 'langfuse'
|
|
161
|
-
|
|
162
|
-
// Reads credentials from LANGFUSE_SECRET_KEY, LANGFUSE_PUBLIC_KEY, LANGFUSE_BASE_URL env vars
|
|
163
|
-
const langfuse = new Langfuse()
|
|
164
|
-
|
|
165
|
-
// Fetch the prompt from Langfuse Prompt Management
|
|
166
|
-
const prompt = await langfuse.getPrompt('customer-support')
|
|
167
|
-
|
|
168
|
-
export const supportAgent = new Agent({
|
|
169
|
-
name: 'support-agent',
|
|
170
|
-
instructions: prompt.prompt, // Use the prompt text from Langfuse
|
|
171
|
-
model: 'openai/gpt-5.4',
|
|
172
|
-
defaultGenerateOptions: {
|
|
173
|
-
tracingOptions: buildTracingOptions(withLangfusePrompt(prompt)),
|
|
174
|
-
},
|
|
175
|
-
})
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
The `withLangfusePrompt` helper automatically extracts `name`, `version`, and `id` from the Langfuse prompt object.
|
|
179
|
-
|
|
180
|
-
### Manual Fields
|
|
181
|
-
|
|
182
|
-
You can also pass manual fields if you're not using the Langfuse SDK:
|
|
183
|
-
|
|
184
|
-
```typescript
|
|
185
|
-
const tracingOptions = buildTracingOptions(withLangfusePrompt({ name: 'my-prompt', version: 1 }))
|
|
186
|
-
|
|
187
|
-
// Or with just an ID
|
|
188
|
-
const tracingOptions = buildTracingOptions(withLangfusePrompt({ id: 'prompt-uuid-12345' }))
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### Prompt Object Fields
|
|
192
|
-
|
|
193
|
-
The prompt object supports these fields:
|
|
194
|
-
|
|
195
|
-
| Field | Type | Description |
|
|
196
|
-
| --------- | ------ | ---------------------------------- |
|
|
197
|
-
| `name` | string | The prompt name in Langfuse |
|
|
198
|
-
| `version` | number | The prompt version number |
|
|
199
|
-
| `id` | string | The prompt UUID for direct linking |
|
|
200
|
-
|
|
201
|
-
You can link prompts using either:
|
|
202
|
-
|
|
203
|
-
- `id` alone (the UUID uniquely identifies a prompt version)
|
|
204
|
-
- `name` + `version` together
|
|
205
|
-
- All three fields
|
|
206
|
-
|
|
207
|
-
When set on a `MODEL_GENERATION` span, the Langfuse exporter automatically links the generation to the corresponding prompt.
|
|
208
|
-
|
|
209
|
-
## Related
|
|
210
|
-
|
|
211
|
-
- [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview)
|
|
212
|
-
- [Langfuse Documentation](https://langfuse.com/docs)
|
|
213
|
-
- [Langfuse Prompt Management](https://langfuse.com/docs/prompt-management)
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
# LangSmith exporter
|
|
2
|
-
|
|
3
|
-
[LangSmith](https://smith.langchain.com/) is LangChain's platform for monitoring and evaluating LLM applications. The LangSmith exporter sends your traces to LangSmith, providing insights into model performance, debugging capabilities, and evaluation workflows.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
**npm**:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install @mastra/langsmith@latest
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
**pnpm**:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
pnpm add @mastra/langsmith@latest
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
**Yarn**:
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
yarn add @mastra/langsmith@latest
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
**Bun**:
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
bun add @mastra/langsmith@latest
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Configuration
|
|
32
|
-
|
|
33
|
-
### Prerequisites
|
|
34
|
-
|
|
35
|
-
1. **LangSmith Account**: Sign up at [smith.langchain.com](https://smith.langchain.com)
|
|
36
|
-
2. **API Key**: Generate an API key in LangSmith Settings → API Keys
|
|
37
|
-
3. **Environment Variables**: Set your credentials
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
# Required
|
|
41
|
-
LANGSMITH_API_KEY=ls-xxxxxxxxxxxx
|
|
42
|
-
|
|
43
|
-
# Optional
|
|
44
|
-
LANGCHAIN_PROJECT=my-project # Default project for traces
|
|
45
|
-
LANGSMITH_BASE_URL=https://api.smith.langchain.com # For self-hosted
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Zero-Config Setup
|
|
49
|
-
|
|
50
|
-
With environment variables set, use the exporter with no configuration:
|
|
51
|
-
|
|
52
|
-
```typescript
|
|
53
|
-
import { Mastra } from '@mastra/core'
|
|
54
|
-
import { Observability } from '@mastra/observability'
|
|
55
|
-
import { LangSmithExporter } from '@mastra/langsmith'
|
|
56
|
-
|
|
57
|
-
export const mastra = new Mastra({
|
|
58
|
-
observability: new Observability({
|
|
59
|
-
configs: {
|
|
60
|
-
langsmith: {
|
|
61
|
-
serviceName: 'my-service',
|
|
62
|
-
exporters: [new LangSmithExporter()],
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
}),
|
|
66
|
-
})
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### Explicit Configuration
|
|
70
|
-
|
|
71
|
-
You can also pass credentials directly (takes precedence over environment variables):
|
|
72
|
-
|
|
73
|
-
```typescript
|
|
74
|
-
import { Mastra } from '@mastra/core'
|
|
75
|
-
import { Observability } from '@mastra/observability'
|
|
76
|
-
import { LangSmithExporter } from '@mastra/langsmith'
|
|
77
|
-
|
|
78
|
-
export const mastra = new Mastra({
|
|
79
|
-
observability: new Observability({
|
|
80
|
-
configs: {
|
|
81
|
-
langsmith: {
|
|
82
|
-
serviceName: 'my-service',
|
|
83
|
-
exporters: [
|
|
84
|
-
new LangSmithExporter({
|
|
85
|
-
apiKey: process.env.LANGSMITH_API_KEY,
|
|
86
|
-
}),
|
|
87
|
-
],
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
}),
|
|
91
|
-
})
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
## Configuration options
|
|
95
|
-
|
|
96
|
-
### Complete Configuration
|
|
97
|
-
|
|
98
|
-
```typescript
|
|
99
|
-
new LangSmithExporter({
|
|
100
|
-
// Required credentials
|
|
101
|
-
apiKey: process.env.LANGSMITH_API_KEY!,
|
|
102
|
-
|
|
103
|
-
// Optional settings
|
|
104
|
-
apiUrl: process.env.LANGSMITH_BASE_URL, // Default: https://api.smith.langchain.com
|
|
105
|
-
projectName: 'my-project', // Project to send traces to (overrides LANGCHAIN_PROJECT env var)
|
|
106
|
-
callerOptions: {
|
|
107
|
-
// HTTP client options
|
|
108
|
-
timeout: 30000, // Request timeout in ms
|
|
109
|
-
maxRetries: 3, // Retry attempts
|
|
110
|
-
},
|
|
111
|
-
logLevel: 'info', // Diagnostic logging: debug | info | warn | error
|
|
112
|
-
|
|
113
|
-
// LangSmith-specific options
|
|
114
|
-
hideInputs: false, // Hide input data in UI
|
|
115
|
-
hideOutputs: false, // Hide output data in UI
|
|
116
|
-
})
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### Environment variables
|
|
120
|
-
|
|
121
|
-
| Variable | Description |
|
|
122
|
-
| -------------------- | ----------------------------------------------------------------- |
|
|
123
|
-
| `LANGSMITH_API_KEY` | Your LangSmith API key (required) |
|
|
124
|
-
| `LANGCHAIN_PROJECT` | Default project name for traces (optional, defaults to "default") |
|
|
125
|
-
| `LANGSMITH_BASE_URL` | API URL for self-hosted instances (optional) |
|
|
126
|
-
|
|
127
|
-
The `projectName` config option takes precedence over the `LANGCHAIN_PROJECT` environment variable, allowing you to programmatically route traces to different projects.
|
|
128
|
-
|
|
129
|
-
## Dynamic configuration
|
|
130
|
-
|
|
131
|
-
You can dynamically override LangSmith settings per-span using `withLangsmithMetadata`. This is useful for routing traces to different projects based on runtime conditions (e.g., customer, environment, or feature).
|
|
132
|
-
|
|
133
|
-
### Using the Helper
|
|
134
|
-
|
|
135
|
-
Use `withLangsmithMetadata` with `buildTracingOptions` to set LangSmith-specific options:
|
|
136
|
-
|
|
137
|
-
```typescript
|
|
138
|
-
import { Agent } from '@mastra/core/agent'
|
|
139
|
-
import { buildTracingOptions } from '@mastra/observability'
|
|
140
|
-
import { withLangsmithMetadata } from '@mastra/langsmith'
|
|
141
|
-
|
|
142
|
-
export const supportAgent = new Agent({
|
|
143
|
-
id: 'support-agent',
|
|
144
|
-
name: 'support-agent',
|
|
145
|
-
instructions: 'You are a helpful support agent.',
|
|
146
|
-
model: 'openai/gpt-5.4',
|
|
147
|
-
defaultOptions: {
|
|
148
|
-
tracingOptions: buildTracingOptions(withLangsmithMetadata({ projectName: 'customer-support' })),
|
|
149
|
-
},
|
|
150
|
-
})
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
### Dynamic Project Routing
|
|
154
|
-
|
|
155
|
-
Use `requestContext` to route traces to different projects based on runtime conditions.
|
|
156
|
-
|
|
157
|
-
```typescript
|
|
158
|
-
import { Agent } from '@mastra/core/agent'
|
|
159
|
-
import { buildTracingOptions } from '@mastra/observability'
|
|
160
|
-
import { withLangsmithMetadata } from '@mastra/langsmith'
|
|
161
|
-
|
|
162
|
-
export const supportAgent = new Agent({
|
|
163
|
-
id: 'support-agent',
|
|
164
|
-
name: 'support-agent',
|
|
165
|
-
instructions: 'You are a helpful support agent.',
|
|
166
|
-
model: 'openai/gpt-5.4',
|
|
167
|
-
defaultOptions: ({ requestContext }) => {
|
|
168
|
-
const userTier = requestContext?.get('user-tier') as string
|
|
169
|
-
const userId = requestContext?.get('user-id') as string
|
|
170
|
-
|
|
171
|
-
return {
|
|
172
|
-
tracingOptions: buildTracingOptions(
|
|
173
|
-
withLangsmithMetadata({
|
|
174
|
-
projectName: userTier === 'enterprise' ? 'enterprise-traces' : 'standard-traces',
|
|
175
|
-
sessionId: userId,
|
|
176
|
-
}),
|
|
177
|
-
),
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
})
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
### Available Fields
|
|
184
|
-
|
|
185
|
-
The `withLangsmithMetadata` helper accepts these fields:
|
|
186
|
-
|
|
187
|
-
| Field | Type | Description |
|
|
188
|
-
| ------------- | ------ | ----------------------------------- |
|
|
189
|
-
| `projectName` | string | Override the project for this trace |
|
|
190
|
-
| `sessionId` | string | Group related traces by session |
|
|
191
|
-
| `sessionName` | string | Display name for the session |
|
|
192
|
-
|
|
193
|
-
All fields are optional. The helper merges with any existing metadata, so you can call it multiple times or combine with other tracing options.
|
|
194
|
-
|
|
195
|
-
## Related
|
|
196
|
-
|
|
197
|
-
- [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview)
|
|
198
|
-
- [LangSmith Documentation](https://docs.smith.langchain.com/)
|