-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
initialize.ts
32 lines (30 loc) · 990 Bytes
/
initialize.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { LangChainTracer } from "./tracer_langchain.js";
import { LangChainTracerV1 } from "./tracer_langchain_v1.js";
/**
* @deprecated Use the V2 handler instead.
*
* Function that returns an instance of `LangChainTracerV1`. If a session
* is provided, it loads that session into the tracer; otherwise, it loads
* a default session.
* @param session Optional session to load into the tracer.
* @returns An instance of `LangChainTracerV1`.
*/
export async function getTracingCallbackHandler(
session?: string
): Promise<LangChainTracerV1> {
const tracer = new LangChainTracerV1();
if (session) {
await tracer.loadSession(session);
} else {
await tracer.loadDefaultSession();
}
return tracer;
}
/**
* Function that returns an instance of `LangChainTracer`. It does not
* load any session data.
* @returns An instance of `LangChainTracer`.
*/
export async function getTracingV2CallbackHandler(): Promise<LangChainTracer> {
return new LangChainTracer();
}