Skip to content

Commit

Permalink
Merge branch 'main' into brace/mistral-llm-completions
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul authored May 29, 2024
2 parents 6d5a259 + 9f0b1c3 commit 6a17555
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions langchain-core/src/singletons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,19 @@ export class MockAsyncLocalStorage implements AsyncLocalStorageInterface {
}
}

class AsyncLocalStorageProvider {
private asyncLocalStorage: AsyncLocalStorageInterface =
new MockAsyncLocalStorage();

private hasBeenInitialized = false;
const mockAsyncLocalStorage = new MockAsyncLocalStorage();

class AsyncLocalStorageProvider {
getInstance(): AsyncLocalStorageInterface {
return this.asyncLocalStorage;
return (
(globalThis as any).__lc_tracing_async_local_storage ??
mockAsyncLocalStorage
);
}

initializeGlobalInstance(instance: AsyncLocalStorageInterface) {
if (!this.hasBeenInitialized) {
this.hasBeenInitialized = true;
this.asyncLocalStorage = instance;
if ((globalThis as any).__lc_tracing_async_local_storage === undefined) {
(globalThis as any).__lc_tracing_async_local_storage = instance;
}
}
}
Expand Down

0 comments on commit 6a17555

Please sign in to comment.