Skip to content

Commit 5cea844

Browse files
committed
fix: auto patch for api_provider_clients
1 parent 0fa5e34 commit 5cea844

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/api/providers/base-provider.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { countTokens } from "../../utils/countTokens"
1010
* Base class for API providers that implements common functionality.
1111
*/
1212
export abstract class BaseProvider implements ApiHandler {
13-
protected client: any // Added protected client field
13+
// constructor remains empty, no new properties added here
1414

1515
abstract createMessage(
1616
systemPrompt: string,
@@ -40,17 +40,19 @@ export abstract class BaseProvider implements ApiHandler {
4040
* Attempts common disposal methods on the client if it exists.
4141
*/
4242
public dispose(): void {
43-
if (this.client) {
43+
// Use reflection to find any property named 'client' on the instance
44+
const clientProperty = (this as any).client
45+
if (clientProperty) {
4446
// Try common disposal methods that SDKs might have
45-
if (typeof (this.client as any).close === "function") {
46-
;(this.client as any).close()
47-
} else if (typeof (this.client as any).destroy === "function") {
48-
;(this.client as any).destroy()
49-
} else if (typeof (this.client as any).dispose === "function") {
50-
;(this.client as any).dispose()
47+
if (typeof clientProperty.close === "function") {
48+
clientProperty.close()
49+
} else if (typeof clientProperty.destroy === "function") {
50+
clientProperty.destroy()
51+
} else if (typeof clientProperty.dispose === "function") {
52+
clientProperty.dispose()
5153
}
52-
// Clear the reference
53-
this.client = undefined
54+
// Clear the reference on the instance
55+
;(this as any).client = undefined
5456
}
5557
}
5658
}

0 commit comments

Comments
 (0)