add router

This commit is contained in:
2025-08-08 02:25:08 +08:00
parent f21372ae95
commit a8c6d59762
6 changed files with 4604 additions and 31 deletions

View File

@@ -34,8 +34,8 @@ export type BaseChatOptions<T = Record<string, any>> = {
} & T;
export const getIsBrowser = () => {
try {
// @ts-ignore
return IS_BROWSER;
// 检查是否存在window对象
return typeof window !== 'undefined' && typeof window.document !== 'undefined';
} catch (e) {
return false;
}
@@ -76,7 +76,7 @@ export class BaseChat implements BaseChatInterface, BaseChatUsageInterface {
this.openai = new OpenAI({
apiKey: this.apiKey,
baseURL: this.baseURL,
dangerouslyAllowBrowser: this.isBrowser,
dangerouslyAllowBrowser: options?.dangerouslyAllowBrowser ?? this.isBrowser,
});
}
/**