Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 committed Jul 7, 2024
1 parent 69aa1b5 commit 73a0698
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 29 deletions.
6 changes: 0 additions & 6 deletions langchain-core/src/runnables/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,6 @@ export abstract class Runnable<
// to surface immediately.
const config = ensureConfig(options);
const callbackManager = await getCallbackManagerForConfig(config);
console.log(
"ABOUT TO STREAM",
config,
callbackManager?.getParentRunId(),
callbackManager?.handlers
);
const wrappedGenerator = new AsyncGeneratorWithSetup({
generator: this._streamIterator(input, config),
config,
Expand Down
22 changes: 6 additions & 16 deletions langchain-core/src/singletons/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { type Client, RunTree } from "langsmith";
import { RunTree } from "langsmith";
import { isTracingEnabled } from "../utils/callbacks.js";

export interface AsyncLocalStorageInterface {
Expand Down Expand Up @@ -49,21 +49,13 @@ class AsyncLocalStorageProvider {
_lc_runnable_config: config,
};
} else {
let parentRun: RunTree | undefined;
let projectName: string | undefined;
let client: Client | undefined;

let tracingEnabled = isTracingEnabled();

console.log("PARENT RUN ID", parentRunId);
const langChainTracer = handlers?.find(
(handler: any) => handler?.name == "langchain_tracer"
(handler: any) => handler?.name === "langchain_tracer"
);

parentRun = langChainTracer?.getRun?.(parentRunId);
projectName = langChainTracer?.projectName;
client = langChainTracer?.client;
tracingEnabled = tracingEnabled || !!langChainTracer;
const tracingEnabled = isTracingEnabled() || !!langChainTracer;
const parentRun = langChainTracer?.getRun?.(parentRunId);
const projectName = langChainTracer?.projectName;
const client = langChainTracer?.client;
newRunTree = new RunTree({
client,
tracingEnabled,
Expand All @@ -77,8 +69,6 @@ class AsyncLocalStorageProvider {
},
});
}
// return storage.run({ extra: { _lc_runnable_config: config }}, callback);
// console.log("NEW RUN TREE", newRunTree);
return storage.run(newRunTree, callback);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,17 @@ test("Config should be automatically populated after setting global async local
).toEqual(1);
});

test.only("Runnable streamEvents method with streaming nested in a RunnableLambda", async () => {
test("Runnable streamEvents method with streaming nested in a RunnableLambda", async () => {
AsyncLocalStorageProviderSingleton.initializeGlobalInstance(
new AsyncLocalStorage()
);
const asyncLocalStorage = AsyncLocalStorageProviderSingleton.getInstance();
const chat = new FakeListChatModel({
responses: ["Hello"],
});
const outerRunId = v4();
const myFunc = async (input: string) => {
const outerCallbackManager = await getCallbackManagerForConfig(
asyncLocalStorage.getStore()
AsyncLocalStorageProviderSingleton.getRunnableConfig()
);
expect(outerCallbackManager?.getParentRunId()).toEqual(outerRunId);
for await (const _ of await chat.stream(input)) {
Expand All @@ -155,8 +154,6 @@ test.only("Runnable streamEvents method with streaming nested in a RunnableLambd

const myNestedLambda = RunnableLambda.from(myFunc);

// console.log(await myNestedLambda.invoke("hello"));

const events = [];
for await (const event of myNestedLambda.streamEvents("hello", {
version: "v1",
Expand Down
1 change: 0 additions & 1 deletion langchain-core/src/tracers/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ export abstract class BaseTracer extends BaseCallbackHandler {
}

protected async _startTrace(run: Run) {
console.log("STARTING RUN", run, this.runMap);
const currentDottedOrder = convertToDottedOrderFormat(
run.start_time,
run.id,
Expand Down
1 change: 0 additions & 1 deletion langchain-core/src/utils/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ export class AsyncGeneratorWithSetup<
this.config = params.config;
this.parentRunId = params.parentRunId;
this.handlers = params.handlers;
console.log("IN SETUP", this.parentRunId, this.handlers);
// setup is a promise that resolves only after the first iterator value
// is available. this is useful when setup of several piped generators
// needs to happen in logical order, ie. in the order in which input to
Expand Down

0 comments on commit 73a0698

Please sign in to comment.