summaryrefslogtreecommitdiff
path: root/src/generic.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/generic.ts')
-rw-r--r--src/generic.ts7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/generic.ts b/src/generic.ts
index e8dfa13..c27f9f0 100644
--- a/src/generic.ts
+++ b/src/generic.ts
@@ -14,6 +14,7 @@ type Props = {
model?: string;
maxTokens?: number;
tokenizer?: (text: string) => number;
+ allowBrowser?: boolean;
};
export default class OpenAIAPI implements AIModelAPI {
private apiKey;
@@ -26,7 +27,11 @@ export default class OpenAIAPI implements AIModelAPI {
constructor(props: Props) {
this.apiKey = props.apiKey;
this.baseURL = props.baseURL;
- this.api = new OpenAI({ baseURL: this.baseURL, apiKey: this.apiKey });
+ this.api = new OpenAI({
+ baseURL: this.baseURL,
+ apiKey: this.apiKey,
+ dangerouslyAllowBrowser: props.allowBrowser || false,
+ });
this.model = props.model || "";
if (props.maxTokens) this.maxTokens = props.maxTokens;
if (props.tokenizer) this.tokenizer = props.tokenizer;