feat: 更新聊天接口,添加当前时间到系统助手消息中;修改生效日期描述格式
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import { schema, app, cnb, models } from '@/app.ts'
|
||||
import z from 'zod';
|
||||
import { runAgent } from '@kevisual/ai/agent'
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
app.route({
|
||||
path: 'flowme-life',
|
||||
@@ -22,10 +23,11 @@ app.route({
|
||||
ctx.throw(400, '缺少参数 question 或 messages');
|
||||
}
|
||||
const routes = ctx.app.getList().filter(r => r.path.startsWith('flowme-life') && r.key !== 'chat');
|
||||
const currentTime = dayjs().toISOString();
|
||||
const messages = _messages || [
|
||||
{
|
||||
"role": "system" as const,
|
||||
"content": `你是我的智能助手,协助我操作我的数据, 请根据我的提问选择合适的接口进行调用。`
|
||||
"content": `你是我的智能助手,协助我操作我的数据, 请根据我的提问选择合适的接口进行调用。当前时间是 ${currentTime}。`
|
||||
},
|
||||
{
|
||||
"role": "user" as const,
|
||||
|
||||
@@ -72,7 +72,7 @@ app.route({
|
||||
tags: z.array(z.string()).describe('标签').optional(),
|
||||
link: z.string().describe('链接').optional(),
|
||||
data: z.record(z.string(), z.any()).describe('数据').optional(),
|
||||
effectiveAt: z.string().describe('生效日期').optional(),
|
||||
effectiveAt: z.string().describe('生效日期, 格式为 YYYY-MM-DD HH:mm:ss').optional(),
|
||||
type: z.string().describe('类型: 智能, 每年农历, 备忘, 归档等.默认智能').optional(),
|
||||
prompt: z.string().describe('提示词').optional(),
|
||||
taskType: z.string().describe('任务类型').optional(),
|
||||
@@ -86,7 +86,7 @@ app.route({
|
||||
if (rest.effectiveAt && isNaN(Date.parse(rest.effectiveAt))) {
|
||||
rest.effectiveAt = null;
|
||||
} else if (rest.effectiveAt) {
|
||||
rest.effectiveAt = dayjs(rest.effectiveAt).toISOString();
|
||||
rest.effectiveAt = dayjs(rest.effectiveAt)
|
||||
}
|
||||
const lifeItem = await db.insert(schema.life).values({
|
||||
title: rest.title || '',
|
||||
@@ -144,7 +144,7 @@ app.route({
|
||||
if (rest.effectiveAt && isNaN(Date.parse(rest.effectiveAt))) {
|
||||
rest.effectiveAt = null;
|
||||
} else if (rest.effectiveAt) {
|
||||
rest.effectiveAt = dayjs(rest.effectiveAt).toISOString();
|
||||
rest.effectiveAt = dayjs(rest.effectiveAt)
|
||||
}
|
||||
const lifeItem = await db.update(schema.life).set({
|
||||
title: rest.title,
|
||||
|
||||
Reference in New Issue
Block a user