This commit is contained in:
2025-12-07 12:12:48 +08:00
parent 0b0482a217
commit df385f00ed

View File

@@ -16,8 +16,8 @@ app.route({
ctx.throw(400, '缺少参数 question');
}
const token = ctx.query.token || '';
if (question.startsWith('配置多维表格')) {
const slicedQuestion = question.slice(0, 10);
if (slicedQuestion.startsWith('配置多维表格')) {
const res = await ctx.call({
path: 'noco-life',
key: 'config-update',
@@ -29,7 +29,7 @@ app.route({
}
const nocoLifeService = new NocoLifeService({ token });
await nocoLifeService.initConfig()
const routes = ctx.queryRouter.getList().filter(r => r.path.startsWith('noco-life') && r.key !== 'chat');
const routes = ctx.app.getList().filter(r => r.path.startsWith('noco-life') && r.key !== 'chat');
const v = `${routes.map((r, index) => `${index + 1}工具名称: ${r.id}\n描述: ${r.description}\n`).join('\n')}\n\n当用户询问时如果拥有工具请返回 JSON 数据不存在工具则返回分析判断数据JSON数据类型是{id,payload}外面的id是工具的id。如果工具有参数在 payload 当中默认不需要参数如果工具内部需要id在payload当中。`
const ai: BaseChat = useContextKey('ai');
const answer = await ai.chat([
@@ -83,7 +83,7 @@ app.route({
ctx.body = {
list,
content: list.map(item => {
return `任务: ${item['标题']}[${item['Id']}], 启动时间: ${dayjs(item['启动时间']).format('YYYY-MM-DD HH:mm:ss')}, 标签: ${item['标签'] || '无'} \n总结: ${item['总结'] || '无'}`;
return `任务[${item['Id']}]: ${item['标题']}\n启动时间: ${dayjs(item['启动时间']).format('YYYY-MM-DD HH:mm:ss')}标签: ${item['标签'] || '无'} \n总结: ${item['总结'] || '无'}`;
}).join('\n')
};
if (list.length === 0) {
@@ -186,3 +186,18 @@ ${prompt ? `这是我给你的提示词,帮你更好地理解我的需求:${
}).addTo(app);
app.route({
path: 'noco-life',
key: 'how-to-use',
description: `多维表格使用指南,如何配置和使用多维表格`,
middleware: ['auth']
}).define(async (ctx) => {
const message = `多维表格使用指南:
1. 发送 "配置多维表格" 来设置和更新多维表格的配置。
2. 配置包含的内容是 baseURL, baseId, token, tableId 其中 tableId是可选的如果不配置会自动创建一个新的多维表格。
`
ctx.body = {
content: message
}
}).addTo(app);