Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow using simple span processor in evals #42

Merged
merged 1 commit into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lmnr-ai/lmnr",
"version": "0.4.29",
"version": "0.4.30",
"description": "TypeScript SDK for Laminar AI",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
7 changes: 7 additions & 0 deletions src/evaluations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ interface EvaluatorConfig {
* See {@link https://docs.lmnr.ai/tracing/automatic-instrumentation}
*/
instrumentModules?: InitializeOptions['instrumentModules'];
/**
* If true, then the spans will not be batched.
*/
disableTraceBatch?: boolean;
}

/**
Expand Down Expand Up @@ -210,6 +214,7 @@ class Evaluation<D, T, O> {
private groupId?: string;
private name?: string;
private batchSize: number = DEFAULT_BATCH_SIZE;
private disableTraceBatch: boolean = false;

constructor({
data, executor, evaluators, humanEvaluators, groupId, name, config
Expand Down Expand Up @@ -238,13 +243,15 @@ class Evaluation<D, T, O> {
this.name = name;
if (config) {
this.batchSize = config.batchSize ?? DEFAULT_BATCH_SIZE;
this.disableTraceBatch = config.disableTraceBatch ?? false;
}
Laminar.initialize({
projectApiKey: config?.projectApiKey,
baseUrl: config?.baseUrl,
httpPort: config?.httpPort,
grpcPort: config?.grpcPort,
instrumentModules: config?.instrumentModules,
disableBatch: this.disableTraceBatch,
});
}

Expand Down
5 changes: 4 additions & 1 deletion src/laminar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ interface LaminarInitializeProps {
instrumentModules?: InitializeOptions["instrumentModules"];
useExternalTracerProvider?: boolean;
preserveNextJsSpans?: boolean;
disableBatch?: boolean;
}

export class Laminar {
Expand All @@ -57,6 +58,7 @@ export class Laminar {
private static projectApiKey: string;
private static env: Record<string, string> = {};
private static isInitialized: boolean = false;
private static disableBatch: boolean = false;

/**
* Initialize Laminar context across the application.
Expand Down Expand Up @@ -114,6 +116,7 @@ export class Laminar {
instrumentModules,
useExternalTracerProvider,
preserveNextJsSpans,
disableBatch,
}: LaminarInitializeProps) {

let key = projectApiKey ?? process.env.LMNR_PROJECT_API_KEY;
Expand Down Expand Up @@ -148,7 +151,7 @@ export class Laminar {
exporter,
silenceInitializationMessage: true,
instrumentModules,
disableBatch: false,
disableBatch,
useExternalTracerProvider,
preserveNextJsSpans,
});
Expand Down
Loading