feat: 添加模型代理请求处理功能,更新相关依赖
This commit is contained in:
parent
fc8d2f9f32
commit
4abeb0a0f0
3
index.ts
3
index.ts
@ -4,6 +4,7 @@ import initAppConfig from "./constant/config"
|
|||||||
import { manageBotReq } from "./routes/bot"
|
import { manageBotReq } from "./routes/bot"
|
||||||
import { manageMessageReq } from "./routes/message"
|
import { manageMessageReq } from "./routes/message"
|
||||||
import { manageMicroAppReq } from "./routes/microApp"
|
import { manageMicroAppReq } from "./routes/microApp"
|
||||||
|
import { manageModelProxyReq } from "./routes/modelProxy"
|
||||||
import { manageSheetReq } from "./routes/sheet"
|
import { manageSheetReq } from "./routes/sheet"
|
||||||
import { initSchedule } from "./schedule"
|
import { initSchedule } from "./schedule"
|
||||||
import genContext from "./utils/genContext"
|
import genContext from "./utils/genContext"
|
||||||
@ -39,6 +40,8 @@ const bunServer = Bun.serve({
|
|||||||
if (path.exact("/sheet")) return await manageSheetReq(ctx)
|
if (path.exact("/sheet")) return await manageSheetReq(ctx)
|
||||||
// 小程序
|
// 小程序
|
||||||
if (path.startsWith("/micro_app")) return await manageMicroAppReq(ctx)
|
if (path.startsWith("/micro_app")) return await manageMicroAppReq(ctx)
|
||||||
|
// 转发到模型代理服务
|
||||||
|
if (path.startsWith("/v1")) return manageModelProxyReq(ctx)
|
||||||
// 健康检查
|
// 健康检查
|
||||||
if (path.full("/health")) return genResp.healthCheck()
|
if (path.full("/health")) return genResp.healthCheck()
|
||||||
// 其他
|
// 其他
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
"@types/jsdom": "^21.1.7",
|
"@types/jsdom": "^21.1.7",
|
||||||
"@types/node-schedule": "^2.1.7",
|
"@types/node-schedule": "^2.1.7",
|
||||||
"@types/uuid": "^10.0.0",
|
"@types/uuid": "^10.0.0",
|
||||||
"bun-types": "^1.2.2",
|
"bun-types": "^1.2.4",
|
||||||
"eslint": "^9.19.0",
|
"eslint": "^9.19.0",
|
||||||
"eslint-plugin-simple-import-sort": "^12.1.1",
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
||||||
"eslint-plugin-unused-imports": "^4.1.4",
|
"eslint-plugin-unused-imports": "^4.1.4",
|
||||||
|
17
routes/modelProxy/index.ts
Normal file
17
routes/modelProxy/index.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import { Context } from "../../types"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理模型代理请求
|
||||||
|
* @param req
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export const manageModelProxyReq = async (ctx: Context) => {
|
||||||
|
const { req, logger } = ctx
|
||||||
|
logger.info("model proxy")
|
||||||
|
const PROXY_URL =
|
||||||
|
"http://ms-13871-nstruct-lmdeploy-2-0109140455.kscn-tj5-prod2-cloudml.xiaomi.srv"
|
||||||
|
return fetch(PROXY_URL + new URL(req.url).pathname, {
|
||||||
|
method: req.method,
|
||||||
|
body: req.body,
|
||||||
|
})
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user