-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update OpenAI version to v4 and add JS tracing (#21)
- Loading branch information
Showing
6 changed files
with
316 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* This is copy/pasted from braintrust-sdk*/ | ||
export class NoopSpan { | ||
public id: string; | ||
public span_id: string; | ||
public root_span_id: string; | ||
public kind: "span" = "span"; | ||
|
||
constructor() { | ||
this.id = ""; | ||
this.span_id = ""; | ||
this.root_span_id = ""; | ||
} | ||
|
||
public log(_: any) {} | ||
|
||
public startSpan(_0: string, _1?: any) { | ||
return this; | ||
} | ||
|
||
public traced<R>(_0: string, callback: (span: any) => R, _1: any): R { | ||
return callback(this); | ||
} | ||
|
||
public end(args?: any): number { | ||
return args?.endTime ?? new Date().getTime() / 1000; | ||
} | ||
|
||
public close(args?: any): number { | ||
return this.end(args); | ||
} | ||
} | ||
declare global { | ||
var __inherited_braintrust_state: any; | ||
} | ||
export function currentSpan() { | ||
if (globalThis.__inherited_braintrust_state) { | ||
return globalThis.__inherited_braintrust_state.currentSpan.getStore(); | ||
} else { | ||
return new NoopSpan(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.