@lmnr-ai/lmnr 0.4.7-alpha → 0.4.7
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/dist/index.d.mts +123 -2
- package/dist/index.d.ts +123 -2
- package/dist/index.js +661 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +668 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import * as _opentelemetry_api from '@opentelemetry/api';
|
|
2
|
-
import { AttributeValue, TimeInput } from '@opentelemetry/api';
|
|
3
|
-
import {
|
|
2
|
+
import { TextMapPropagator, ContextManager, AttributeValue, TimeInput } from '@opentelemetry/api';
|
|
3
|
+
import { SpanExporter, SpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
4
|
+
import * as openai from 'openai';
|
|
5
|
+
import * as anthropic from '@anthropic-ai/sdk';
|
|
6
|
+
import * as azure from '@azure/openai';
|
|
7
|
+
import * as cohere from 'cohere-ai';
|
|
8
|
+
import * as bedrock from '@aws-sdk/client-bedrock-runtime';
|
|
9
|
+
import * as aiplatform from '@google-cloud/aiplatform';
|
|
10
|
+
import * as vertexAI from '@google-cloud/vertexai';
|
|
11
|
+
import * as pinecone from '@pinecone-database/pinecone';
|
|
12
|
+
import * as ChainsModule from 'langchain/chains';
|
|
13
|
+
import * as AgentsModule from 'langchain/agents';
|
|
14
|
+
import * as ToolsModule from 'langchain/tools';
|
|
15
|
+
import * as RunnableModule from '@langchain/core/runnables';
|
|
16
|
+
import * as VectorStoreModule from '@langchain/core/vectorstores';
|
|
17
|
+
import * as llamaindex from 'llamaindex';
|
|
18
|
+
import * as chromadb from 'chromadb';
|
|
19
|
+
import * as qdrant from '@qdrant/js-client-rest';
|
|
4
20
|
|
|
5
21
|
type StringUUID = `${string}-${string}-${string}-${string}-${string}`;
|
|
6
22
|
|
|
@@ -43,6 +59,91 @@ type EvaluationDatapoint<D, T, O> = {
|
|
|
43
59
|
};
|
|
44
60
|
type EvaluationStatus = 'Started' | 'Finished' | 'Error';
|
|
45
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Options for initializing the Traceloop SDK.
|
|
64
|
+
*/
|
|
65
|
+
interface InitializeOptions {
|
|
66
|
+
/**
|
|
67
|
+
* The app name to be used when reporting traces. Optional.
|
|
68
|
+
* Defaults to the package name.
|
|
69
|
+
*/
|
|
70
|
+
appName?: string;
|
|
71
|
+
/**
|
|
72
|
+
* The API Key for sending traces data. Optional.
|
|
73
|
+
* Defaults to the TRACELOOP_API_KEY environment variable.
|
|
74
|
+
*/
|
|
75
|
+
apiKey?: string;
|
|
76
|
+
/**
|
|
77
|
+
* The OTLP endpoint for sending traces data. Optional.
|
|
78
|
+
* Defaults to TRACELOOP_BASE_URL environment variable or https://api.traceloop.com/
|
|
79
|
+
*/
|
|
80
|
+
baseUrl?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Sends traces and spans without batching, for local developement. Optional.
|
|
83
|
+
* Defaults to false.
|
|
84
|
+
*/
|
|
85
|
+
disableBatch?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Defines default log level for SDK and all instrumentations. Optional.
|
|
88
|
+
* Defaults to error.
|
|
89
|
+
*/
|
|
90
|
+
logLevel?: "debug" | "info" | "warn" | "error";
|
|
91
|
+
/**
|
|
92
|
+
* Whether to log prompts, completions and embeddings on traces. Optional.
|
|
93
|
+
* Defaults to true.
|
|
94
|
+
*/
|
|
95
|
+
traceContent?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* The OpenTelemetry SpanExporter to be used for sending traces data. Optional.
|
|
98
|
+
* Defaults to the OTLP exporter.
|
|
99
|
+
*/
|
|
100
|
+
exporter?: SpanExporter;
|
|
101
|
+
/**
|
|
102
|
+
* The OpenTelemetry SpanProcessor to be used for processing traces data. Optional.
|
|
103
|
+
* Defaults to the BatchSpanProcessor.
|
|
104
|
+
*/
|
|
105
|
+
processor?: SpanProcessor;
|
|
106
|
+
/**
|
|
107
|
+
* The OpenTelemetry Propagator to use. Optional.
|
|
108
|
+
* Defaults to OpenTelemetry SDK defaults.
|
|
109
|
+
*/
|
|
110
|
+
propagator?: TextMapPropagator;
|
|
111
|
+
/**
|
|
112
|
+
* The OpenTelemetry ContextManager to use. Optional.
|
|
113
|
+
* Defaults to OpenTelemetry SDK defaults.
|
|
114
|
+
*/
|
|
115
|
+
contextManager?: ContextManager;
|
|
116
|
+
/**
|
|
117
|
+
* Explicitly specify modules to instrument. Optional.
|
|
118
|
+
* This is a workaround specific to Next.js, see https://www.traceloop.com/docs/openllmetry/getting-started-nextjs
|
|
119
|
+
*/
|
|
120
|
+
instrumentModules?: {
|
|
121
|
+
openAI?: typeof openai.OpenAI;
|
|
122
|
+
anthropic?: typeof anthropic;
|
|
123
|
+
azureOpenAI?: typeof azure;
|
|
124
|
+
cohere?: typeof cohere;
|
|
125
|
+
bedrock?: typeof bedrock;
|
|
126
|
+
google_vertexai?: typeof vertexAI;
|
|
127
|
+
google_aiplatform?: typeof aiplatform;
|
|
128
|
+
pinecone?: typeof pinecone;
|
|
129
|
+
langchain?: {
|
|
130
|
+
chainsModule?: typeof ChainsModule;
|
|
131
|
+
agentsModule?: typeof AgentsModule;
|
|
132
|
+
toolsModule?: typeof ToolsModule;
|
|
133
|
+
runnablesModule?: typeof RunnableModule;
|
|
134
|
+
vectorStoreModule?: typeof VectorStoreModule;
|
|
135
|
+
};
|
|
136
|
+
llamaIndex?: typeof llamaindex;
|
|
137
|
+
chromadb?: typeof chromadb;
|
|
138
|
+
qdrant?: typeof qdrant;
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Whether to silence the initialization message. Optional.
|
|
142
|
+
* Defaults to false.
|
|
143
|
+
*/
|
|
144
|
+
silenceInitializationMessage?: boolean;
|
|
145
|
+
}
|
|
146
|
+
|
|
46
147
|
interface LaminarInitializeProps {
|
|
47
148
|
projectApiKey?: string;
|
|
48
149
|
env?: Record<string, string>;
|
|
@@ -66,6 +167,26 @@ declare class Laminar {
|
|
|
66
167
|
* @param baseUrl - Url of Laminar endpoint, or the custom open telemetry ingester.
|
|
67
168
|
* If not specified, defaults to https://api.lmnr.ai:8443. For locally hosted Laminar,
|
|
68
169
|
* default setting must be http://localhost:8001.
|
|
170
|
+
* @param instrumentModules - List of modules to instrument.
|
|
171
|
+
* If not specified, all auto-instrumentable modules will be instrumented, which include
|
|
172
|
+
* LLM calls (OpenAI, Anthropic, etc), Langchain, VectorDB calls (Pinecone, Qdrant, etc).
|
|
173
|
+
* Pass an empty object {} to disable any kind of automatic instrumentation.
|
|
174
|
+
* If you only want to auto-instrument specific modules, then pass them in the object.
|
|
175
|
+
*
|
|
176
|
+
* Example:
|
|
177
|
+
* ```typescript
|
|
178
|
+
* import { Laminar as L } from '@lmnr-ai/lmnr';
|
|
179
|
+
* import { OpenAI } from 'openai';
|
|
180
|
+
* import * as ChainsModule from "langchain/chains";
|
|
181
|
+
*
|
|
182
|
+
* // Initialize Laminar while auto-instrumenting Langchain and OpenAI modules.
|
|
183
|
+
* L.initialize({ projectApiKey: "<LMNR_PROJECT_API_KEY>", instrumentModules: {
|
|
184
|
+
* langchain: {
|
|
185
|
+
* chainsModule: ChainsModule
|
|
186
|
+
* },
|
|
187
|
+
* openAI: OpenAI
|
|
188
|
+
* } });
|
|
189
|
+
* ```
|
|
69
190
|
*
|
|
70
191
|
* @throws {Error} - If project API key is not set
|
|
71
192
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import * as _opentelemetry_api from '@opentelemetry/api';
|
|
2
|
-
import { AttributeValue, TimeInput } from '@opentelemetry/api';
|
|
3
|
-
import {
|
|
2
|
+
import { TextMapPropagator, ContextManager, AttributeValue, TimeInput } from '@opentelemetry/api';
|
|
3
|
+
import { SpanExporter, SpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
4
|
+
import * as openai from 'openai';
|
|
5
|
+
import * as anthropic from '@anthropic-ai/sdk';
|
|
6
|
+
import * as azure from '@azure/openai';
|
|
7
|
+
import * as cohere from 'cohere-ai';
|
|
8
|
+
import * as bedrock from '@aws-sdk/client-bedrock-runtime';
|
|
9
|
+
import * as aiplatform from '@google-cloud/aiplatform';
|
|
10
|
+
import * as vertexAI from '@google-cloud/vertexai';
|
|
11
|
+
import * as pinecone from '@pinecone-database/pinecone';
|
|
12
|
+
import * as ChainsModule from 'langchain/chains';
|
|
13
|
+
import * as AgentsModule from 'langchain/agents';
|
|
14
|
+
import * as ToolsModule from 'langchain/tools';
|
|
15
|
+
import * as RunnableModule from '@langchain/core/runnables';
|
|
16
|
+
import * as VectorStoreModule from '@langchain/core/vectorstores';
|
|
17
|
+
import * as llamaindex from 'llamaindex';
|
|
18
|
+
import * as chromadb from 'chromadb';
|
|
19
|
+
import * as qdrant from '@qdrant/js-client-rest';
|
|
4
20
|
|
|
5
21
|
type StringUUID = `${string}-${string}-${string}-${string}-${string}`;
|
|
6
22
|
|
|
@@ -43,6 +59,91 @@ type EvaluationDatapoint<D, T, O> = {
|
|
|
43
59
|
};
|
|
44
60
|
type EvaluationStatus = 'Started' | 'Finished' | 'Error';
|
|
45
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Options for initializing the Traceloop SDK.
|
|
64
|
+
*/
|
|
65
|
+
interface InitializeOptions {
|
|
66
|
+
/**
|
|
67
|
+
* The app name to be used when reporting traces. Optional.
|
|
68
|
+
* Defaults to the package name.
|
|
69
|
+
*/
|
|
70
|
+
appName?: string;
|
|
71
|
+
/**
|
|
72
|
+
* The API Key for sending traces data. Optional.
|
|
73
|
+
* Defaults to the TRACELOOP_API_KEY environment variable.
|
|
74
|
+
*/
|
|
75
|
+
apiKey?: string;
|
|
76
|
+
/**
|
|
77
|
+
* The OTLP endpoint for sending traces data. Optional.
|
|
78
|
+
* Defaults to TRACELOOP_BASE_URL environment variable or https://api.traceloop.com/
|
|
79
|
+
*/
|
|
80
|
+
baseUrl?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Sends traces and spans without batching, for local developement. Optional.
|
|
83
|
+
* Defaults to false.
|
|
84
|
+
*/
|
|
85
|
+
disableBatch?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Defines default log level for SDK and all instrumentations. Optional.
|
|
88
|
+
* Defaults to error.
|
|
89
|
+
*/
|
|
90
|
+
logLevel?: "debug" | "info" | "warn" | "error";
|
|
91
|
+
/**
|
|
92
|
+
* Whether to log prompts, completions and embeddings on traces. Optional.
|
|
93
|
+
* Defaults to true.
|
|
94
|
+
*/
|
|
95
|
+
traceContent?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* The OpenTelemetry SpanExporter to be used for sending traces data. Optional.
|
|
98
|
+
* Defaults to the OTLP exporter.
|
|
99
|
+
*/
|
|
100
|
+
exporter?: SpanExporter;
|
|
101
|
+
/**
|
|
102
|
+
* The OpenTelemetry SpanProcessor to be used for processing traces data. Optional.
|
|
103
|
+
* Defaults to the BatchSpanProcessor.
|
|
104
|
+
*/
|
|
105
|
+
processor?: SpanProcessor;
|
|
106
|
+
/**
|
|
107
|
+
* The OpenTelemetry Propagator to use. Optional.
|
|
108
|
+
* Defaults to OpenTelemetry SDK defaults.
|
|
109
|
+
*/
|
|
110
|
+
propagator?: TextMapPropagator;
|
|
111
|
+
/**
|
|
112
|
+
* The OpenTelemetry ContextManager to use. Optional.
|
|
113
|
+
* Defaults to OpenTelemetry SDK defaults.
|
|
114
|
+
*/
|
|
115
|
+
contextManager?: ContextManager;
|
|
116
|
+
/**
|
|
117
|
+
* Explicitly specify modules to instrument. Optional.
|
|
118
|
+
* This is a workaround specific to Next.js, see https://www.traceloop.com/docs/openllmetry/getting-started-nextjs
|
|
119
|
+
*/
|
|
120
|
+
instrumentModules?: {
|
|
121
|
+
openAI?: typeof openai.OpenAI;
|
|
122
|
+
anthropic?: typeof anthropic;
|
|
123
|
+
azureOpenAI?: typeof azure;
|
|
124
|
+
cohere?: typeof cohere;
|
|
125
|
+
bedrock?: typeof bedrock;
|
|
126
|
+
google_vertexai?: typeof vertexAI;
|
|
127
|
+
google_aiplatform?: typeof aiplatform;
|
|
128
|
+
pinecone?: typeof pinecone;
|
|
129
|
+
langchain?: {
|
|
130
|
+
chainsModule?: typeof ChainsModule;
|
|
131
|
+
agentsModule?: typeof AgentsModule;
|
|
132
|
+
toolsModule?: typeof ToolsModule;
|
|
133
|
+
runnablesModule?: typeof RunnableModule;
|
|
134
|
+
vectorStoreModule?: typeof VectorStoreModule;
|
|
135
|
+
};
|
|
136
|
+
llamaIndex?: typeof llamaindex;
|
|
137
|
+
chromadb?: typeof chromadb;
|
|
138
|
+
qdrant?: typeof qdrant;
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Whether to silence the initialization message. Optional.
|
|
142
|
+
* Defaults to false.
|
|
143
|
+
*/
|
|
144
|
+
silenceInitializationMessage?: boolean;
|
|
145
|
+
}
|
|
146
|
+
|
|
46
147
|
interface LaminarInitializeProps {
|
|
47
148
|
projectApiKey?: string;
|
|
48
149
|
env?: Record<string, string>;
|
|
@@ -66,6 +167,26 @@ declare class Laminar {
|
|
|
66
167
|
* @param baseUrl - Url of Laminar endpoint, or the custom open telemetry ingester.
|
|
67
168
|
* If not specified, defaults to https://api.lmnr.ai:8443. For locally hosted Laminar,
|
|
68
169
|
* default setting must be http://localhost:8001.
|
|
170
|
+
* @param instrumentModules - List of modules to instrument.
|
|
171
|
+
* If not specified, all auto-instrumentable modules will be instrumented, which include
|
|
172
|
+
* LLM calls (OpenAI, Anthropic, etc), Langchain, VectorDB calls (Pinecone, Qdrant, etc).
|
|
173
|
+
* Pass an empty object {} to disable any kind of automatic instrumentation.
|
|
174
|
+
* If you only want to auto-instrument specific modules, then pass them in the object.
|
|
175
|
+
*
|
|
176
|
+
* Example:
|
|
177
|
+
* ```typescript
|
|
178
|
+
* import { Laminar as L } from '@lmnr-ai/lmnr';
|
|
179
|
+
* import { OpenAI } from 'openai';
|
|
180
|
+
* import * as ChainsModule from "langchain/chains";
|
|
181
|
+
*
|
|
182
|
+
* // Initialize Laminar while auto-instrumenting Langchain and OpenAI modules.
|
|
183
|
+
* L.initialize({ projectApiKey: "<LMNR_PROJECT_API_KEY>", instrumentModules: {
|
|
184
|
+
* langchain: {
|
|
185
|
+
* chainsModule: ChainsModule
|
|
186
|
+
* },
|
|
187
|
+
* openAI: OpenAI
|
|
188
|
+
* } });
|
|
189
|
+
* ```
|
|
69
190
|
*
|
|
70
191
|
* @throws {Error} - If project API key is not set
|
|
71
192
|
*/
|