Compare commits

...

2 Commits

Author SHA1 Message Date
3bfdc2355f bump 2025-12-08 14:54:18 +08:00
966a465fb4 perf: 优化 token 和 apikey,token 字段也可以用 2025-12-08 14:54:11 +08:00
4 changed files with 13 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "@kevisual/ai", "name": "@kevisual/ai",
"version": "0.0.17", "version": "0.0.18",
"description": "AI Center Services", "description": "AI Center Services",
"main": "index.js", "main": "index.js",
"basename": "/root/ai-center-services", "basename": "/root/ai-center-services",

View File

@@ -5,6 +5,9 @@ export class BailianChat extends BaseChat {
static BASE_URL = 'https://dashscope.aliyuncs.com/compatible-mode/v1'; static BASE_URL = 'https://dashscope.aliyuncs.com/compatible-mode/v1';
constructor(options: BailianOptions) { constructor(options: BailianOptions) {
const baseURL = options.baseURL || BailianChat.BASE_URL; const baseURL = options.baseURL || BailianChat.BASE_URL;
if (!options.model) {
options.model = 'qwen-plus'
}
super({ ...(options as BaseChatOptions), baseURL: baseURL }); super({ ...(options as BaseChatOptions), baseURL: baseURL });
} }
} }

View File

@@ -9,6 +9,9 @@ export class Kevisual extends BaseChat {
static BASE_URL = 'https://newapi.kevisual.cn/v1/'; static BASE_URL = 'https://newapi.kevisual.cn/v1/';
constructor(options: KevisualOptions) { constructor(options: KevisualOptions) {
const baseURL = options.baseURL || Kevisual.BASE_URL; const baseURL = options.baseURL || Kevisual.BASE_URL;
if (!options.model) {
options.model = 'qwen-plus'
}
super({ ...(options as BaseChatOptions), baseURL: baseURL }); super({ ...(options as BaseChatOptions), baseURL: baseURL });
} }
} }

View File

@@ -22,7 +22,11 @@ export type BaseChatOptions<T = Record<string, any>> = {
/** /**
* 默认apiKey * 默认apiKey
*/ */
apiKey: string; apiKey?: string;
/**
* token
*/
token?: string;
/** /**
* 是否在浏览器中使用 * 是否在浏览器中使用
*/ */
@@ -54,7 +58,7 @@ export class BaseChat implements BaseChatInterface, BaseChatUsageInterface {
constructor(options: BaseChatOptions) { constructor(options: BaseChatOptions) {
this.baseURL = options.baseURL; this.baseURL = options.baseURL;
this.model = options.model; this.model = options.model;
this.apiKey = options.apiKey; this.apiKey = options.token || options.apiKey;
} }
post(url = '', opts: { headers?: Record<string, string>, data?: any } = {}) { post(url = '', opts: { headers?: Record<string, string>, data?: any } = {}) {
let _url = url.startsWith('http') ? url : this.baseURL + url; let _url = url.startsWith('http') ? url : this.baseURL + url;