@@ -37,9 +37,9 @@ export class LangChainInstrumentation extends InstrumentationBase<any> {
3737 agentsModule,
3838 toolsModule,
3939 } : {
40- chainsModule ?: any & { openLLMetryPatched ?: boolean } ;
41- agentsModule ?: any & { openLLMetryPatched ?: boolean } ;
42- toolsModule ?: any & { openLLMetryPatched ?: boolean } ;
40+ chainsModule ?: any ;
41+ agentsModule ?: any ;
42+ toolsModule ?: any ;
4343 } ) {
4444 if ( chainsModule ) {
4545 this . patchChainModule ( chainsModule ) ;
@@ -74,13 +74,7 @@ export class LangChainInstrumentation extends InstrumentationBase<any> {
7474 return [ chainModule , agentModule , toolsModule ] ;
7575 }
7676
77- private patchChainModule (
78- moduleExports : typeof ChainsModule & { openLLMetryPatched ?: boolean } ,
79- ) {
80- if ( moduleExports . openLLMetryPatched ) {
81- return moduleExports ;
82- }
83-
77+ private patchChainModule ( moduleExports : typeof ChainsModule ) {
8478 this . _wrap (
8579 moduleExports . RetrievalQAChain . prototype ,
8680 "_call" ,
@@ -98,13 +92,7 @@ export class LangChainInstrumentation extends InstrumentationBase<any> {
9892 return moduleExports ;
9993 }
10094
101- private patchAgentModule (
102- moduleExports : typeof AgentsModule & { openLLMetryPatched ?: boolean } ,
103- ) {
104- if ( moduleExports . openLLMetryPatched ) {
105- return moduleExports ;
106- }
107-
95+ private patchAgentModule ( moduleExports : typeof AgentsModule ) {
10896 this . _wrap (
10997 moduleExports . AgentExecutor . prototype ,
11098 "_call" ,
@@ -117,13 +105,7 @@ export class LangChainInstrumentation extends InstrumentationBase<any> {
117105 return moduleExports ;
118106 }
119107
120- private patchToolsModule (
121- moduleExports : typeof ToolsModule & { openLLMetryPatched ?: boolean } ,
122- ) {
123- if ( moduleExports . openLLMetryPatched ) {
124- return moduleExports ;
125- }
126-
108+ private patchToolsModule ( moduleExports : typeof ToolsModule ) {
127109 this . _wrap (
128110 moduleExports . Tool . prototype ,
129111 "call" ,
@@ -132,30 +114,18 @@ export class LangChainInstrumentation extends InstrumentationBase<any> {
132114 return moduleExports ;
133115 }
134116
135- private unpatchChainModule (
136- moduleExports : any & { openLLMetryPatched ?: boolean } ,
137- ) {
138- moduleExports . openLLMetryPatched = false ;
139-
117+ private unpatchChainModule ( moduleExports : any ) {
140118 this . _unwrap ( moduleExports . RetrievalQAChain . prototype , "_call" ) ;
141119 this . _unwrap ( moduleExports . BaseChain . prototype , "call" ) ;
142120 return moduleExports ;
143121 }
144122
145- private unpatchAgentModule (
146- moduleExports : any & { openLLMetryPatched ?: boolean } ,
147- ) {
148- moduleExports . openLLMetryPatched = false ;
149-
123+ private unpatchAgentModule ( moduleExports : any ) {
150124 this . _unwrap ( moduleExports . AgentExecutor . prototype , "_call" ) ;
151125 return moduleExports ;
152126 }
153127
154- private unpatchToolsModule (
155- moduleExports : any & { openLLMetryPatched ?: boolean } ,
156- ) {
157- moduleExports . openLLMetryPatched = false ;
158-
128+ private unpatchToolsModule ( moduleExports : any ) {
159129 this . _unwrap ( moduleExports . AgentExecutor . prototype , "_call" ) ;
160130 return moduleExports ;
161131 }
0 commit comments