perf: 优化 token 和 apikey,token 字段也可以用
This commit is contained in:
@@ -5,6 +5,9 @@ export class BailianChat extends BaseChat {
|
||||
static BASE_URL = 'https://dashscope.aliyuncs.com/compatible-mode/v1';
|
||||
constructor(options: BailianOptions) {
|
||||
const baseURL = options.baseURL || BailianChat.BASE_URL;
|
||||
if (!options.model) {
|
||||
options.model = 'qwen-plus'
|
||||
}
|
||||
super({ ...(options as BaseChatOptions), baseURL: baseURL });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@ export class Kevisual extends BaseChat {
|
||||
static BASE_URL = 'https://newapi.kevisual.cn/v1/';
|
||||
constructor(options: KevisualOptions) {
|
||||
const baseURL = options.baseURL || Kevisual.BASE_URL;
|
||||
if (!options.model) {
|
||||
options.model = 'qwen-plus'
|
||||
}
|
||||
super({ ...(options as BaseChatOptions), baseURL: baseURL });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,11 @@ export type BaseChatOptions<T = Record<string, any>> = {
|
||||
/**
|
||||
* 默认apiKey
|
||||
*/
|
||||
apiKey: string;
|
||||
apiKey?: string;
|
||||
/**
|
||||
* token
|
||||
*/
|
||||
token?: string;
|
||||
/**
|
||||
* 是否在浏览器中使用
|
||||
*/
|
||||
@@ -54,7 +58,7 @@ export class BaseChat implements BaseChatInterface, BaseChatUsageInterface {
|
||||
constructor(options: BaseChatOptions) {
|
||||
this.baseURL = options.baseURL;
|
||||
this.model = options.model;
|
||||
this.apiKey = options.apiKey;
|
||||
this.apiKey = options.token || options.apiKey;
|
||||
}
|
||||
post(url = '', opts: { headers?: Record<string, string>, data?: any } = {}) {
|
||||
let _url = url.startsWith('http') ? url : this.baseURL + url;
|
||||
|
||||
Reference in New Issue
Block a user