feat: add百炼
This commit is contained in:
@@ -14,7 +14,7 @@ export type BaseChatOptions<T = Record<string, any>> = {
|
||||
/**
|
||||
* 默认baseURL
|
||||
*/
|
||||
baseURL: string;
|
||||
baseURL?: string;
|
||||
/**
|
||||
* 默认模型
|
||||
*/
|
||||
@@ -32,7 +32,14 @@ export type BaseChatOptions<T = Record<string, any>> = {
|
||||
*/
|
||||
stream?: boolean;
|
||||
} & T;
|
||||
|
||||
export const getIsBrowser = () => {
|
||||
try {
|
||||
// @ts-ignore
|
||||
return IS_BROWSER;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
export class BaseChat implements BaseChatInterface, BaseChatUsageInterface {
|
||||
/**
|
||||
* 默认baseURL
|
||||
@@ -63,7 +70,9 @@ export class BaseChat implements BaseChatInterface, BaseChatUsageInterface {
|
||||
this.baseURL = options.baseURL;
|
||||
this.model = options.model;
|
||||
this.apiKey = options.apiKey;
|
||||
this.isBrowser = options.isBrowser ?? false;
|
||||
// @ts-ignore
|
||||
const DEFAULT_IS_BROWSER = getIsBrowser();
|
||||
this.isBrowser = options.isBrowser ?? DEFAULT_IS_BROWSER;
|
||||
this.openai = new OpenAI({
|
||||
apiKey: this.apiKey,
|
||||
baseURL: this.baseURL,
|
||||
|
||||
Reference in New Issue
Block a user