Skip to content

Commit 5078ab6

Browse files
committed
fix: Removed unused params from ctor
1 parent 8ddaff6 commit 5078ab6

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/Client.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export class AI21 extends Core.APIClient {
3333
super({
3434
baseURL,
3535
timeout,
36-
apiKey,
3736
maxRetries,
3837
options: {}
3938
});

src/Core.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import fetch from 'node-fetch';
55
import { HeadersInit } from "node-fetch";
66
import { RequestOptions, FinalRequestOptions, APIResponseProps, HTTPMethod, PromiseOrValue, DefaultQuery } from "./models";
77
import { APIPromise } from "./APIPromise";
8+
import { AI21EnvConfig } from "./EnvConfig.js";
89

910
export type Headers = Record<string, string | null | undefined>;
1011

@@ -40,15 +41,13 @@ export abstract class APIClient {
4041

4142
constructor({
4243
baseURL,
43-
maxRetries = 3,
44-
timeout = 300000,
45-
apiKey,
44+
maxRetries = AI21EnvConfig.MAX_RETRIES,
45+
timeout = AI21EnvConfig.TIMEOUT_SECONDS,
4646
options,
4747
}: {
4848
baseURL: string;
4949
maxRetries?: number | undefined;
5050
timeout: number | undefined;
51-
apiKey: string;
5251
options: ClientOptions;
5352
}) {
5453
this.baseURL = baseURL;
@@ -74,10 +73,13 @@ export abstract class APIClient {
7473
}
7574

7675
protected getUserAgent(): string {
77-
return`AI21 Typescript SDK ${VERSION}`;
78-
}
76+
const platform = this.isRunningInBrowser()
77+
? `browser/${typeof window !== 'undefined' ? window.navigator.userAgent : 'unknown'}`
78+
: `node/${process.version}`;
79+
return `AI21 Typescript SDK ${VERSION} ${platform}`;
80+
}
7981

80-
protected defaultHeaders(opts: FinalRequestOptions): Headers {
82+
protected defaultHeaders(opts: FinalRequestOptions): Headers {
8183
return {
8284
Accept: 'application/json',
8385
'Content-Type': 'application/json',
@@ -141,7 +143,7 @@ export abstract class APIClient {
141143
return { response, options, controller };
142144
}
143145

144-
protected static isRunningInBrowser(): boolean {
146+
protected isRunningInBrowser(): boolean {
145147
return (
146148
typeof window !== 'undefined' &&
147149
typeof window.document !== 'undefined' &&

0 commit comments

Comments
 (0)