@@ -37,9 +37,9 @@ export class LangChainInstrumentation extends InstrumentationBase<any> {
37
37
agentsModule,
38
38
toolsModule,
39
39
} : {
40
- chainsModule ?: any & { openLLMetryPatched ?: boolean } ;
41
- agentsModule ?: any & { openLLMetryPatched ?: boolean } ;
42
- toolsModule ?: any & { openLLMetryPatched ?: boolean } ;
40
+ chainsModule ?: any ;
41
+ agentsModule ?: any ;
42
+ toolsModule ?: any ;
43
43
} ) {
44
44
if ( chainsModule ) {
45
45
this . patchChainModule ( chainsModule ) ;
@@ -74,13 +74,7 @@ export class LangChainInstrumentation extends InstrumentationBase<any> {
74
74
return [ chainModule , agentModule , toolsModule ] ;
75
75
}
76
76
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 ) {
84
78
this . _wrap (
85
79
moduleExports . RetrievalQAChain . prototype ,
86
80
"_call" ,
@@ -98,13 +92,7 @@ export class LangChainInstrumentation extends InstrumentationBase<any> {
98
92
return moduleExports ;
99
93
}
100
94
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 ) {
108
96
this . _wrap (
109
97
moduleExports . AgentExecutor . prototype ,
110
98
"_call" ,
@@ -117,13 +105,7 @@ export class LangChainInstrumentation extends InstrumentationBase<any> {
117
105
return moduleExports ;
118
106
}
119
107
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 ) {
127
109
this . _wrap (
128
110
moduleExports . Tool . prototype ,
129
111
"call" ,
@@ -132,30 +114,18 @@ export class LangChainInstrumentation extends InstrumentationBase<any> {
132
114
return moduleExports ;
133
115
}
134
116
135
- private unpatchChainModule (
136
- moduleExports : any & { openLLMetryPatched ?: boolean } ,
137
- ) {
138
- moduleExports . openLLMetryPatched = false ;
139
-
117
+ private unpatchChainModule ( moduleExports : any ) {
140
118
this . _unwrap ( moduleExports . RetrievalQAChain . prototype , "_call" ) ;
141
119
this . _unwrap ( moduleExports . BaseChain . prototype , "call" ) ;
142
120
return moduleExports ;
143
121
}
144
122
145
- private unpatchAgentModule (
146
- moduleExports : any & { openLLMetryPatched ?: boolean } ,
147
- ) {
148
- moduleExports . openLLMetryPatched = false ;
149
-
123
+ private unpatchAgentModule ( moduleExports : any ) {
150
124
this . _unwrap ( moduleExports . AgentExecutor . prototype , "_call" ) ;
151
125
return moduleExports ;
152
126
}
153
127
154
- private unpatchToolsModule (
155
- moduleExports : any & { openLLMetryPatched ?: boolean } ,
156
- ) {
157
- moduleExports . openLLMetryPatched = false ;
158
-
128
+ private unpatchToolsModule ( moduleExports : any ) {
159
129
this . _unwrap ( moduleExports . AgentExecutor . prototype , "_call" ) ;
160
130
return moduleExports ;
161
131
}
0 commit comments