mirror of
https://github.com/LLM-Red-Team/kimi-free-api.git
synced 2024-12-22 10:09:20 +08:00
移除配置
This commit is contained in:
parent
cc0ea384a7
commit
3dbabb0d47
@ -1,8 +0,0 @@
|
||||
chatCompletion:
|
||||
provider: zhipuai
|
||||
model: glm-4
|
||||
apiKey: 99b6167d7f421fc2187785503d2ffe9f.WncREpjXE26ediTw
|
||||
contextLength: 131072
|
||||
maxToken: 8192
|
||||
concurrencyLimit: 5
|
||||
waitReponseTimeout: 30000
|
@ -1,6 +1,5 @@
|
||||
import serviceConfig from "./configs/service-config.ts";
|
||||
import systemConfig from "./configs/system-config.ts";
|
||||
import apiConfig from "./configs/api-config.ts";
|
||||
|
||||
class Config {
|
||||
|
||||
@ -10,9 +9,6 @@ class Config {
|
||||
/** 系统配置 */
|
||||
system = systemConfig;
|
||||
|
||||
/** API配置 */
|
||||
api = apiConfig;
|
||||
|
||||
}
|
||||
|
||||
export default new Config();
|
@ -1,85 +0,0 @@
|
||||
import path from 'path';
|
||||
|
||||
import fs from 'fs-extra';
|
||||
import yaml from 'yaml';
|
||||
import _ from 'lodash';
|
||||
|
||||
import environment from '@/lib/environment.ts';
|
||||
|
||||
const CONFIG_PATH = path.join(path.resolve(), 'configs/', environment.env, "/api.yml");
|
||||
|
||||
export interface ProxyAgent {
|
||||
enable?: boolean;
|
||||
protocol?: string;
|
||||
host?: string;
|
||||
port?: number;
|
||||
}
|
||||
|
||||
export class ChatCompletionConfig {
|
||||
|
||||
/** 服务提供商 */
|
||||
provider: string;
|
||||
/** 调用地址 */
|
||||
url: string;
|
||||
/** API密钥 */
|
||||
apiKey: string;
|
||||
/** API版本号 */
|
||||
apiVersion: string;
|
||||
/** 模型名称 */
|
||||
model: string;
|
||||
/** 上下文长度 */
|
||||
contextLength: number;
|
||||
/** 单次最大token数 */
|
||||
maxToken: number;
|
||||
/** 并行请求数 */
|
||||
concurrencyLimit: number;
|
||||
/** 等待响应超时时间(毫秒) */
|
||||
waitReponseTimeout: number;
|
||||
/** 网络代理 */
|
||||
proxyAgent: ProxyAgent | null;
|
||||
|
||||
constructor(options?: any) {
|
||||
const { provider, url, apiKey, apiVersion, model, contextLength, concurrencyLimit, waitReponseTimeout, proxyAgent } = options || {};
|
||||
this.provider = _.defaultTo(provider, 'zhipuai');
|
||||
this.url = _.defaultTo(url, 'https://open.bigmodel.cn/api/paas/v4/chat/completions');
|
||||
this.apiKey = _.defaultTo(apiKey, '');
|
||||
this.apiVersion = _.defaultTo(apiVersion, '');
|
||||
this.model = _.defaultTo(model, 'glm-4');
|
||||
this.contextLength = _.defaultTo(contextLength, 131072);
|
||||
this.concurrencyLimit = _.defaultTo(concurrencyLimit, 100);
|
||||
this.waitReponseTimeout = _.defaultTo(waitReponseTimeout, 30000);
|
||||
this.proxyAgent = _.defaultTo(proxyAgent, null);
|
||||
}
|
||||
|
||||
static create(value) {
|
||||
return ChatCompletionConfig.isInstance(value) ? value : new ChatCompletionConfig(value);
|
||||
}
|
||||
|
||||
static isInstance(value) {
|
||||
return value instanceof ChatCompletionConfig;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* API配置
|
||||
*/
|
||||
export class APIConfig {
|
||||
|
||||
/** 聊天补全配置 */
|
||||
chatCompletion: ChatCompletionConfig;
|
||||
|
||||
constructor(options?: any) {
|
||||
const { chatCompletion } = options || {};
|
||||
this.chatCompletion = ChatCompletionConfig.create(chatCompletion);
|
||||
}
|
||||
|
||||
static load() {
|
||||
if(!fs.pathExistsSync(CONFIG_PATH)) return new APIConfig();
|
||||
const data = yaml.parse(fs.readFileSync(CONFIG_PATH).toString());
|
||||
return new APIConfig(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default APIConfig.load();
|
Loading…
Reference in New Issue
Block a user