feat(event-proxy): 更正event判断方式,michat的Event转发给任浩
This commit is contained in:
parent
bd67a36c17
commit
4054693602
18
package.json
18
package.json
@ -19,31 +19,31 @@
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^19.5.0",
|
||||
"@commitlint/config-conventional": "^19.5.0",
|
||||
"@eslint/js": "^9.12.0",
|
||||
"@eslint/js": "^9.13.0",
|
||||
"@types/node-schedule": "^2.1.7",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"bun-types": "^1.1.30",
|
||||
"eslint": "^9.12.0",
|
||||
"bun-types": "^1.1.33",
|
||||
"eslint": "^9.13.0",
|
||||
"eslint-plugin-simple-import-sort": "^12.1.1",
|
||||
"husky": "^9.1.6",
|
||||
"lint-staged": "^15.2.10",
|
||||
"prettier": "^3.3.3",
|
||||
"typescript-eslint": "^8.9.0"
|
||||
"typescript-eslint": "^8.12.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.5.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"@dotenvx/dotenvx": "^1.19.3",
|
||||
"@dotenvx/dotenvx": "^1.21.0",
|
||||
"@egg/hooks": "^1.2.0",
|
||||
"@egg/lark-msg-tool": "^1.13.2",
|
||||
"@egg/lark-msg-tool": "^1.14.0",
|
||||
"@egg/logger": "^1.4.4",
|
||||
"@egg/net-tool": "^1.9.2",
|
||||
"@egg/path-tool": "^1.4.1",
|
||||
"@langchain/core": "^0.3.12",
|
||||
"@langchain/openai": "^0.3.7",
|
||||
"@langchain/core": "^0.3.15",
|
||||
"@langchain/openai": "^0.3.11",
|
||||
"joi": "^17.13.3",
|
||||
"langfuse-langchain": "^3.27.0",
|
||||
"langfuse-langchain": "^3.28.0",
|
||||
"node-schedule": "^2.1.1",
|
||||
"p-limit": "^6.1.0",
|
||||
"pocketbase": "^0.21.5",
|
||||
|
@ -395,12 +395,12 @@ const manageActionMsg = async (ctx: Context.Data) => {
|
||||
*/
|
||||
const groupAgent = async (ctx: Context.Data) => {
|
||||
const {
|
||||
larkBody: { isEventMsg, isActionMsg },
|
||||
larkBody: { isEvent, isAction },
|
||||
} = ctx
|
||||
// 如果是Event,则解析自然语言并发送对应的卡片
|
||||
if (isEventMsg) return manageEventMsg(ctx)
|
||||
if (isEvent) return manageEventMsg(ctx)
|
||||
// 如果是Action,则取出用户选的值并判断是否需要继续发送表单卡片或者开始大模型推理
|
||||
if (isActionMsg) return manageActionMsg(ctx)
|
||||
if (isAction) return manageActionMsg(ctx)
|
||||
}
|
||||
|
||||
export default groupAgent
|
||||
|
@ -8,7 +8,7 @@ import { manageEventMsg } from "./eventMsg"
|
||||
* @returns {Promise<Response>} 返回响应对象
|
||||
*/
|
||||
export const manageBotReq = async (ctx: Context.Data): Promise<Response> => {
|
||||
const { body, larkBody } = ctx
|
||||
const { body, larkBody, app, attachService } = ctx
|
||||
|
||||
// 检查请求体是否为空
|
||||
if (!body) {
|
||||
@ -21,10 +21,15 @@ export const manageBotReq = async (ctx: Context.Data): Promise<Response> => {
|
||||
return Response.json({ challenge: body.challenge })
|
||||
}
|
||||
|
||||
// 处理Event消息
|
||||
if (larkBody.isEventMsg) manageEventMsg(ctx)
|
||||
// 如果是michat的Event转发给MiChatServer
|
||||
if (app === "michat" && larkBody.isEvent) {
|
||||
attachService.proxyMiChatEvent(body)
|
||||
}
|
||||
|
||||
// 处理消息事件
|
||||
if (larkBody.isMessageEvent) manageEventMsg(ctx)
|
||||
// 处理Action消息
|
||||
if (larkBody.isActionMsg) return await manageActionMsg(ctx)
|
||||
if (larkBody.isAction) return await manageActionMsg(ctx)
|
||||
|
||||
// 返回成功响应
|
||||
return ctx.genResp.ok()
|
||||
|
@ -21,6 +21,20 @@ class AttachService extends NetToolBase {
|
||||
const URL = "https://report.imoaix.cn/report"
|
||||
return this.post(URL, body).catch(() => "")
|
||||
}
|
||||
|
||||
/**
|
||||
* 代理MiChat事件
|
||||
* @param {LarkEvent.Data} body - 事件数据。
|
||||
* @returns {Promise<void>} 返回空。
|
||||
*/
|
||||
async proxyMiChatEvent(body: LarkEvent.Data) {
|
||||
const hostList = ["michat-staging.ai.srv", "michat.ai.srv"]
|
||||
const path = "/api/v1/bypass/robot_event_callback"
|
||||
for (const host of hostList) {
|
||||
const URL = `http://${host}${path}`
|
||||
await this.post(URL, body).catch(() => "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default AttachService
|
||||
|
@ -22,6 +22,6 @@ export namespace Context {
|
||||
attachService: AttachService
|
||||
path: PathCheckTool
|
||||
searchParams: URLSearchParams
|
||||
app: string
|
||||
app: "michat" | "egg" | string
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user