egg_server/cache.ts

33 lines
828 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { z } from "zod"
const groupAgentConfig = z
.object({
isGroupChat: z.boolean().describe("是否是群聊问答"),
startTime: z
.string()
.optional()
.describe("开始时间,格式为 YYYY-MM-DD HH:mm:ss"),
endTime: z
.string()
.optional()
.describe("结束时间,格式为 YYYY-MM-DD HH:mm:ss"),
userQueryResponse: z
.string()
.optional()
.describe("如果不是群聊问答的对用户Query的回复"),
})
.refine(
(data) => {
if (data.isGroupChat) {
return data.startTime && data.endTime
} else {
return data.userQueryResponse
}
},
{
message:
"isGroupChat 为 true 时需要 startTime 和 endTime为 false 时需要 userQueryResponse",
path: ["isGroupChat"],
}
)