summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/generic.ts7
-rw-r--r--src/types/index.ts9
2 files changed, 14 insertions, 2 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;
diff --git a/src/types/index.ts b/src/types/index.ts
index 1e4d57d..f6df6bf 100644
--- a/src/types/index.ts
+++ b/src/types/index.ts
@@ -40,4 +40,11 @@ export type LLMChoice =
| { grok: string }
| { deepseek: string }
| { kimi: string }
- | { openai: { url: string; apiKey: string; model: string } };
+ | {
+ openai: {
+ url: string;
+ apiKey: string;
+ model: string;
+ allowBrowser?: boolean;
+ };
+ };