diff --git a/mis-database/SKILL.md b/mis-database/SKILL.md index f499fb1..e1b5d91 100644 --- a/mis-database/SKILL.md +++ b/mis-database/SKILL.md @@ -1,130 +1,23 @@ --- -name: mis-database -description: 在访问数据库服务的时候需要参考的文档 +name: mis-database-ops +description: 生成SQL的参考文档。 --- -# mis-database +# 能力索引 -请根据下文内容生成sql。 +- [查询智能体对话日志](./references/query-agent-chat-log.md) +- [查询智能体信息](./references/query-agent-info.md) +- [查询智能体使用数据](./references/query-agent-usage.md) +- [查询项目统计数据](./references/query-project-stats.md) -## 查询智能体对话日志 - -### 输入要求 - -必须要求用户提供**会话ID**。 - -### 查询步骤 - -1. 查询所有切片号,假设查询出来的`part`是[1,2] - -```sql -select part from log_agent_chat where del_flag = '0'; -``` - -2. 根据切片号查询并合并各个切片表的数据 - -```sql -select * from log_agent_chat_1 where chat_window_id = <会话ID> -UNION ALL -select * from log_agent_chat_2 where chat_window_id = <会话ID> -``` - -## 查询智能体信息 - -### 输入要求 - -必须提供**智能体ID**,在不明确用户查询的是单智能体还是多智能体时,友好的询问要查询哪种智能体。 - -### 执行查询单智能体信息 - -```sql -with agent_info AS ( - select - agent_id, - agent_name, - system_prompt, - `description`, - max_messages, - max_tokens, - kb_uuids, - kb_configs, - kb_similarity_threshold, - kb_top_k, - kb_max_recall_toekn, - llm_name, - long_term_memory, - case kb_mode when '1' then '直接检索' when '2' then 'tool检索' else '' end AS kb_mode, - case kb_search_type when '0' then '向量检索' when '1' then '混合检索' when '2' then '智能检索' else '' end AS kb_search_type - from mis-agent.agent - where agent_id = <智能体ID> -), -agent_skill AS ( - select - <智能体ID> AS agent_id, - GROUP_CONCAT(skill_name) AS skill_names - from mis-mcp.skill - where skill_id in ( - select skill_id from mis-agent.agent_skill_mapping - where agent_id = <智能体ID> - ) -), -agent_mcp_tool AS ( - select - <智能体ID> AS agent_id, - GROUP_CONCAT(tool_name) AS tool_names - from mis-mcp.map_tools - where mcp_server_uuid in ( - select mcp_server_uuid from mis-agent.agent_tool_mapping - where relate_agent_id = <智能体ID> - ) -) - -select * from agent_info AS a -left join agent_skill AS b on a.agent_id = b.agent_id -left join agent_mcp_tool AS c on a.agent_id = c.agent_id -``` - -### 执行查询多智能体信息 - -```sql -select * from mis-agent.agent_release_info where release_id in ( - select - release_id - from mis-agent.multi_agent_sub - where main_agent_id = <智能体ID> -) -``` - -## 查询智能体使用数据 - -### 输入要求 - -必须提供**智能体ID**。 - - -### 执行查询 - -```sql -select * from mis-agent.agent_usage_stats_daily where agent_id = <智能体ID> order by daily desc -``` - -## 查询项目统计数据 - -### 输入要求 - -必须提供**项目名称**。 - -### 查询步骤 - -1. 查询项目注册表,判断是否包含该项目。用户提供的项目名称大概率是模糊的,比如"认证"、"ebiz",要根据语义判断究竟是哪一个,如果猜不准就询问一下用户是哪个。重要:`project_stats_registry`里的`id`字段,称为项目ID,或者叫project\_id,后面的步骤需要用到。 - -```sql -select * from mis-agent.project_stats_registry -``` - -2. 查询项目统计数据 - -```sql -select * from mis-agent.project_data_stats_daily where project_id = -``` +## 工作流程 +```mermaid +flowchart TD + A[开始] --> B[意图识别] + B --> C{请求是否被能力索引覆盖?} + C -->|是| D[参考文档执行相关操作] + C -->|否| E[利用相关工具想办法解决] + D --> F[结束] + E --> F +``` \ No newline at end of file diff --git a/mis-database/references/query-agent-chat-log.md b/mis-database/references/query-agent-chat-log.md new file mode 100644 index 0000000..b4ee93c --- /dev/null +++ b/mis-database/references/query-agent-chat-log.md @@ -0,0 +1,19 @@ +# 输入要求 + +必须要求用户提供**会话ID**。 + +## 工作流程 + +1. 查询所有切片号,假设查询出来的`part`是[1,2] + +```sql +select part from log_agent_chat where del_flag = '0'; +``` + +2. 根据切片号查询并合并各个切片表的数据 + +```sql +select * from log_agent_chat_1 where chat_window_id = <会话ID> +UNION ALL +select * from log_agent_chat_2 where chat_window_id = <会话ID> +``` \ No newline at end of file diff --git a/mis-database/references/query-agent-info.md b/mis-database/references/query-agent-info.md new file mode 100644 index 0000000..ef6928c --- /dev/null +++ b/mis-database/references/query-agent-info.md @@ -0,0 +1,63 @@ +# 输入要求 + +必须提供**智能体ID**,在不明确用户查询的是单智能体还是多智能体时,友好的询问要查询哪种智能体。 + +## 查询单智能体信息 + +```sql +with agent_info AS ( + select + agent_id, + agent_name, + system_prompt, + `description`, + max_messages, + max_tokens, + kb_uuids, + kb_configs, + kb_similarity_threshold, + kb_top_k, + kb_max_recall_toekn, + llm_name, + long_term_memory, + case kb_mode when '1' then '直接检索' when '2' then 'tool检索' else '' end AS kb_mode, + case kb_search_type when '0' then '向量检索' when '1' then '混合检索' when '2' then '智能检索' else '' end AS kb_search_type + from mis-agent.agent + where agent_id = <智能体ID> +), +agent_skill AS ( + select + <智能体ID> AS agent_id, + GROUP_CONCAT(skill_name) AS skill_names + from mis-mcp.skill + where skill_id in ( + select skill_id from mis-agent.agent_skill_mapping + where agent_id = <智能体ID> + ) +), +agent_mcp_tool AS ( + select + <智能体ID> AS agent_id, + GROUP_CONCAT(tool_name) AS tool_names + from mis-mcp.map_tools + where mcp_server_uuid in ( + select mcp_server_uuid from mis-agent.agent_tool_mapping + where relate_agent_id = <智能体ID> + ) +) + +select * from agent_info AS a +left join agent_skill AS b on a.agent_id = b.agent_id +left join agent_mcp_tool AS c on a.agent_id = c.agent_id +``` + +## 查询多智能体信息 + +```sql +select * from mis-agent.agent_release_info where release_id in ( + select + release_id + from mis-agent.multi_agent_sub + where main_agent_id = <智能体ID> +) +``` \ No newline at end of file diff --git a/mis-database/references/query-agent-usage.md b/mis-database/references/query-agent-usage.md new file mode 100644 index 0000000..590b082 --- /dev/null +++ b/mis-database/references/query-agent-usage.md @@ -0,0 +1,9 @@ +# 输入要求 + +必须提供**智能体ID**。 + +## 执行查询 + +```sql +select * from mis-agent.agent_usage_stats_daily where agent_id = <智能体ID> order by daily desc +``` \ No newline at end of file diff --git a/mis-database/references/query-project-stats.md b/mis-database/references/query-project-stats.md new file mode 100644 index 0000000..900902c --- /dev/null +++ b/mis-database/references/query-project-stats.md @@ -0,0 +1,17 @@ +# 输入要求 + +必须提供**项目名称**。 + +## 工作流程 + +1. 查询项目注册表,判断是否包含该项目。用户提供的项目名称大概率是模糊的,比如"认证"、"ebiz",要根据语义判断究竟是哪一个,如果猜不准就询问一下用户是哪个。重要:`project_stats_registry`里的`id`字段,称为项目ID,或者叫project_id,后面的步骤需要用到。 + +```sql +select * from mis-agent.project_stats_registry +``` + +2. 查询项目统计数据 + +```sql +select * from mis-agent.project_data_stats_daily where project_id = +``` \ No newline at end of file