Skip to content

Commit 39e439a

Browse files
committed
📦 NEW: Handle langbase.workflow
1 parent a71909c commit 39e439a

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

packages/langbase/src/langbase/langbase.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ export class Langbase {
640640
};
641641
};
642642

643-
public workflow: (config: {debug?: boolean; name?: string}) => Workflow;
643+
public workflow: (config?: {debug?: boolean; name?: string}) => Workflow;
644644

645645
public traces: {
646646
create: (trace: any) => Promise<any>;
@@ -731,7 +731,8 @@ export class Langbase {
731731
run: this.runAgent.bind(this),
732732
};
733733

734-
this.workflow = config => new Workflow({...config, langbase: this});
734+
this.workflow = (config = {}) =>
735+
new Workflow({...config, langbase: this});
735736

736737
this.traces = {
737738
create: this.createTrace.bind(this),

packages/langbase/src/langbase/workflows.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,11 @@ export class Workflow {
131131

132132
// Notify collector if traceId was found
133133
if (traceId && _global._activeTraceCollector) {
134-
if (debug)
134+
if (debug) {
135135
console.log(
136136
`🔍 Trace ID extracted: ${traceId}`,
137137
);
138+
}
138139
_global._activeTraceCollector(traceId);
139140
}
140141
}
@@ -391,7 +392,9 @@ export class Workflow {
391392
if (!this.langbase || !this.traceManager || !this.traceId) return;
392393
// Finalise and grab the trace
393394
this.traceManager.endTrace(this.traceId);
394-
this.traceManager.printTrace(this.traceId);
395+
if (this.debug) {
396+
this.traceManager.printTrace(this.traceId);
397+
}
395398
const traceData = this.traceManager.getTrace(this.traceId);
396399

397400
// --- send to LB API v1/traces/create using SDK method ---

0 commit comments

Comments
 (0)