add router
This commit is contained in:
parent
f21372ae95
commit
a8c6d59762
34
package.json
34
package.json
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@kevisual/ai",
|
||||
"version": "0.0.8",
|
||||
"description": "后面需要把ai-center的provider模块提取出去",
|
||||
"version": "0.0.9",
|
||||
"description": "AI Center Services",
|
||||
"main": "index.js",
|
||||
"basename": "/root/ai-center-services",
|
||||
"app": {
|
||||
@ -28,7 +28,7 @@
|
||||
],
|
||||
"author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)",
|
||||
"license": "MIT",
|
||||
"packageManager": "pnpm@10.11.0",
|
||||
"packageManager": "pnpm@10.14.0",
|
||||
"type": "module",
|
||||
"publishConfig": {
|
||||
"registry": "https://registry.npmjs.org/",
|
||||
@ -54,36 +54,36 @@
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kevisual/code-center-module": "0.0.20",
|
||||
"@kevisual/code-center-module": "0.0.24",
|
||||
"@kevisual/mark": "0.0.7",
|
||||
"@kevisual/router": "0.0.21",
|
||||
"@kevisual/router": "0.0.23",
|
||||
"@kevisual/types": "^0.0.10",
|
||||
"@kevisual/use-config": "^1.0.17",
|
||||
"@types/bun": "^1.2.14",
|
||||
"@kevisual/use-config": "^1.0.19",
|
||||
"@types/bun": "^1.2.19",
|
||||
"@types/crypto-js": "^4.2.2",
|
||||
"@types/formidable": "^3.4.5",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/node": "^22.15.21",
|
||||
"@vitejs/plugin-basic-ssl": "^2.0.0",
|
||||
"@types/node": "^24.2.0",
|
||||
"@vitejs/plugin-basic-ssl": "^2.1.0",
|
||||
"cookie": "^1.0.2",
|
||||
"cross-env": "^7.0.3",
|
||||
"cross-env": "^10.0.0",
|
||||
"crypto-js": "^4.2.0",
|
||||
"dayjs": "^1.11.13",
|
||||
"dotenv": "^16.5.0",
|
||||
"dotenv": "^17.2.1",
|
||||
"formidable": "^3.5.4",
|
||||
"ioredis": "^5.6.1",
|
||||
"ioredis": "^5.7.0",
|
||||
"json5": "^2.2.3",
|
||||
"lodash-es": "^4.17.21",
|
||||
"openai": "4.103.0",
|
||||
"pm2": "^6.0.6",
|
||||
"openai": "5.12.0",
|
||||
"pm2": "^6.0.8",
|
||||
"rimraf": "^6.0.1",
|
||||
"rollup": "^4.41.1",
|
||||
"rollup": "^4.46.2",
|
||||
"rollup-plugin-dts": "^6.2.1",
|
||||
"sequelize": "^6.37.7",
|
||||
"tape": "^5.9.0",
|
||||
"tiktoken": "^1.0.21",
|
||||
"typescript": "^5.8.3",
|
||||
"vite": "^6.3.5"
|
||||
"typescript": "^5.9.2",
|
||||
"vite": "^7.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@kevisual/logger": "^0.0.4"
|
||||
|
4573
pnpm-lock.yaml
generated
Normal file
4573
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
10
src/provider/chat-adapter/open-router.ts
Normal file
10
src/provider/chat-adapter/open-router.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { BaseChat, BaseChatOptions } from '../core/chat.ts';
|
||||
|
||||
export type OpenRouterOptions = Partial<BaseChatOptions>;
|
||||
export class OpenRouterChat extends BaseChat {
|
||||
static BASE_URL = 'https://openrouter.ai/api/v1';
|
||||
constructor(options: OpenRouterOptions) {
|
||||
const baseURL = options.baseURL || OpenRouterChat.BASE_URL;
|
||||
super({ ...(options as BaseChatOptions), baseURL: baseURL });
|
||||
}
|
||||
}
|
@ -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,
|
||||
});
|
||||
}
|
||||
/**
|
||||
|
@ -1,9 +0,0 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import basicSsl from '@vitejs/plugin-basic-ssl';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [basicSsl()],
|
||||
server: {
|
||||
port: 3000,
|
||||
},
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user