File tree 2 files changed +21
-1
lines changed
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -328,6 +328,10 @@ export abstract class BaseCallbackHandler
328
328
return undefined ;
329
329
}
330
330
331
+ get lc_serializable_keys ( ) : string [ ] | undefined {
332
+ return undefined ;
333
+ }
334
+
331
335
/**
332
336
* The name of the serializable. Override to provide an alias or
333
337
* to preserve the serialized module name in minified environments.
Original file line number Diff line number Diff line change @@ -140,8 +140,24 @@ export abstract class Serializable implements SerializableInterface {
140
140
return undefined ;
141
141
}
142
142
143
+ /**
144
+ * A manual list of keys that should be serialized.
145
+ * If not overridden, all fields passed into the constructor will be serialized.
146
+ */
147
+ get lc_serializable_keys ( ) : string [ ] | undefined {
148
+ return undefined ;
149
+ }
150
+
143
151
constructor ( kwargs ?: SerializedFields , ..._args : never [ ] ) {
144
- this . lc_kwargs = kwargs || { } ;
152
+ if ( this . lc_serializable_keys !== undefined ) {
153
+ this . lc_kwargs = Object . fromEntries (
154
+ Object . entries ( kwargs || { } ) . filter ( ( [ key ] ) =>
155
+ this . lc_serializable_keys ?. includes ( key )
156
+ )
157
+ ) ;
158
+ } else {
159
+ this . lc_kwargs = kwargs ?? { } ;
160
+ }
145
161
}
146
162
147
163
toJSON ( ) : Serialized {
You can’t perform that action at this time.
0 commit comments