From e6ec5a2b33a2da09aa6dc155aeabe6d134e77294 Mon Sep 17 00:00:00 2001 From: Drol Date: Wed, 10 Jun 2026 11:07:15 +0800 Subject: [PATCH] fix(ai): load data-query skill before querying data (#9725) --- .../plugin-ai/src/client/ai-employees/context/flow-models.tsx | 3 ++- .../src/ai/skills/data-query/SKILLS.md | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-ai/src/client/ai-employees/context/flow-models.tsx b/packages/plugins/@nocobase/plugin-ai/src/client/ai-employees/context/flow-models.tsx index 3564f99a9c2..fc9f671c43a 100644 --- a/packages/plugins/@nocobase/plugin-ai/src/client/ai-employees/context/flow-models.tsx +++ b/packages/plugins/@nocobase/plugin-ai/src/client/ai-employees/context/flow-models.tsx @@ -114,7 +114,8 @@ const toCollection = async (model: CollectionBlockModel) => { collection: { ...collection, }, - prompt: `You can use the tools dataSourceQuery to query data from a data source and dataSourceCounting to get record counts. + prompt: `Before querying, first call getSkill with skillName="data-query" to load the data-query skill and make dataSourceQuery and dataSourceCounting available. +After the skill is loaded, use dataSourceQuery to query data from a data source and dataSourceCounting to get record counts. When analyzing user messages, if any words or phrases are related or similar to a known collectionName, prioritize retrieving relevant data before responding. When the user asks about quantities, totals, or record counts, you must first call dataSourceCounting to obtain accurate numbers before answering. Always apply dataScope.filter when calling dataSourceQuery or dataSourceCounting. Ensure that the filter structure is properly transformed to match the tools’ input format. diff --git a/packages/plugins/@nocobase/plugin-data-source-manager/src/ai/skills/data-query/SKILLS.md b/packages/plugins/@nocobase/plugin-data-source-manager/src/ai/skills/data-query/SKILLS.md index cb368c5a679..56aaa591672 100644 --- a/packages/plugins/@nocobase/plugin-data-source-manager/src/ai/skills/data-query/SKILLS.md +++ b/packages/plugins/@nocobase/plugin-data-source-manager/src/ai/skills/data-query/SKILLS.md @@ -3,7 +3,6 @@ scope: GENERAL name: data-query description: Inspect schemas, retrieve records, and run aggregate queries on specified datasources tools: - - getSkill - dataQuery - dataSourceQuery - dataSourceCounting