add router
This commit is contained in:
parent
f21372ae95
commit
a8c6d59762
34
package.json
34
package.json
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@kevisual/ai",
|
"name": "@kevisual/ai",
|
||||||
"version": "0.0.8",
|
"version": "0.0.9",
|
||||||
"description": "后面需要把ai-center的provider模块提取出去",
|
"description": "AI Center Services",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"basename": "/root/ai-center-services",
|
"basename": "/root/ai-center-services",
|
||||||
"app": {
|
"app": {
|
||||||
@ -28,7 +28,7 @@
|
|||||||
],
|
],
|
||||||
"author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)",
|
"author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"packageManager": "pnpm@10.11.0",
|
"packageManager": "pnpm@10.14.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"registry": "https://registry.npmjs.org/",
|
"registry": "https://registry.npmjs.org/",
|
||||||
@ -54,36 +54,36 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@kevisual/code-center-module": "0.0.20",
|
"@kevisual/code-center-module": "0.0.24",
|
||||||
"@kevisual/mark": "0.0.7",
|
"@kevisual/mark": "0.0.7",
|
||||||
"@kevisual/router": "0.0.21",
|
"@kevisual/router": "0.0.23",
|
||||||
"@kevisual/types": "^0.0.10",
|
"@kevisual/types": "^0.0.10",
|
||||||
"@kevisual/use-config": "^1.0.17",
|
"@kevisual/use-config": "^1.0.19",
|
||||||
"@types/bun": "^1.2.14",
|
"@types/bun": "^1.2.19",
|
||||||
"@types/crypto-js": "^4.2.2",
|
"@types/crypto-js": "^4.2.2",
|
||||||
"@types/formidable": "^3.4.5",
|
"@types/formidable": "^3.4.5",
|
||||||
"@types/lodash-es": "^4.17.12",
|
"@types/lodash-es": "^4.17.12",
|
||||||
"@types/node": "^22.15.21",
|
"@types/node": "^24.2.0",
|
||||||
"@vitejs/plugin-basic-ssl": "^2.0.0",
|
"@vitejs/plugin-basic-ssl": "^2.1.0",
|
||||||
"cookie": "^1.0.2",
|
"cookie": "^1.0.2",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^10.0.0",
|
||||||
"crypto-js": "^4.2.0",
|
"crypto-js": "^4.2.0",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"dotenv": "^16.5.0",
|
"dotenv": "^17.2.1",
|
||||||
"formidable": "^3.5.4",
|
"formidable": "^3.5.4",
|
||||||
"ioredis": "^5.6.1",
|
"ioredis": "^5.7.0",
|
||||||
"json5": "^2.2.3",
|
"json5": "^2.2.3",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"openai": "4.103.0",
|
"openai": "5.12.0",
|
||||||
"pm2": "^6.0.6",
|
"pm2": "^6.0.8",
|
||||||
"rimraf": "^6.0.1",
|
"rimraf": "^6.0.1",
|
||||||
"rollup": "^4.41.1",
|
"rollup": "^4.46.2",
|
||||||
"rollup-plugin-dts": "^6.2.1",
|
"rollup-plugin-dts": "^6.2.1",
|
||||||
"sequelize": "^6.37.7",
|
"sequelize": "^6.37.7",
|
||||||
"tape": "^5.9.0",
|
"tape": "^5.9.0",
|
||||||
"tiktoken": "^1.0.21",
|
"tiktoken": "^1.0.21",
|
||||||
"typescript": "^5.8.3",
|
"typescript": "^5.9.2",
|
||||||
"vite": "^6.3.5"
|
"vite": "^7.1.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@kevisual/logger": "^0.0.4"
|
"@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;
|
} & T;
|
||||||
export const getIsBrowser = () => {
|
export const getIsBrowser = () => {
|
||||||
try {
|
try {
|
||||||
// @ts-ignore
|
// 检查是否存在window对象
|
||||||
return IS_BROWSER;
|
return typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ export class BaseChat implements BaseChatInterface, BaseChatUsageInterface {
|
|||||||
this.openai = new OpenAI({
|
this.openai = new OpenAI({
|
||||||
apiKey: this.apiKey,
|
apiKey: this.apiKey,
|
||||||
baseURL: this.baseURL,
|
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