Files
gzth/yuthon_ai_agent/views/ai_rule_views.xml
T
2026-07-02 11:29:18 +08:00

194 lines
10 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<!-- ============================================ -->
<!-- AI 规则 - 列表视图 -->
<!-- ============================================ -->
<record id="view_ai_rule_tree" model="ir.ui.view">
<field name="name">ai.rule.tree</field>
<field name="model">ai.rule</field>
<field name="arch" type="xml">
<tree string="AI 规则">
<field name="priority" widget="handle"/>
<field name="name"/>
<field name="rule_type" widget="badge"
decoration-info="rule_type == 'instruction'"
decoration-warning="rule_type == 'restriction'"
decoration-success="rule_type == 'skill'"
decoration-danger="rule_type == 'method'"
decoration-primary="rule_type == 'active_guide'"/>
<field name="provider_ids" widget="many2many_tags"/>
<field name="group_ids" widget="many2many_tags"/>
<field name="active" widget="boolean_toggle"/>
</tree>
</field>
</record>
<!-- ============================================ -->
<!-- AI 规则 - 表单视图 -->
<!-- ============================================ -->
<record id="view_ai_rule_form" model="ir.ui.view">
<field name="name">ai.rule.form</field>
<field name="model">ai.rule</field>
<field name="arch" type="xml">
<form string="AI 规则">
<sheet>
<widget name="web_ribbon" title="已停用"
bg_color="text-bg-danger" invisible="active"/>
<div class="oe_title">
<h1>
<field name="name" placeholder="输入规则名称"/>
</h1>
</div>
<group>
<group string="基本设置">
<field name="rule_type"/>
<field name="priority"/>
<field name="active"/>
<field name="can_write" widget="boolean_toggle"
help="勾选后匹配此规则时 AI 可修改数据(create/write/unlink),适用于需要 AI 辅助录入或修改数据的场景"/>
</group>
<group string="适用范围">
<field name="provider_ids" widget="many2many_tags"
options="{'no_create': True}"
placeholder="留空 = 所有服务商"/>
<field name="group_ids" widget="many2many_tags"
options="{'no_create': True}"
placeholder="留空 = 所有用户"/>
</group>
</group>
<notebook>
<!-- 回复指令 / 限制规则 -->
<page string="规则内容" name="content"
invisible="rule_type in ('skill', 'method', 'active_guide')">
<field name="content" placeholder="写给 AI 的指令内容,如:所有回复不超过 200 字 / 不得回答薪资相关问题" nolabel="1"/>
</page>
<!-- 主动感知配置 -->
<page string="主动感知配置" name="active_guide"
invisible="rule_type != 'active_guide'">
<div class="oe_button_box" style="margin-bottom: 12px;">
<button name="action_test_guide" type="object"
string="测试主动感知"
class="btn btn-primary o_test_active_guide_btn"
help="模拟触发此规则,查看引导内容和按钮效果"/>
</div>
<group>
<group string="引导内容">
<field name="guide_message"
placeholder="主动弹出时显示的文字,支持 {record_name} / {user_name}" />
<field name="guide_button_label" />
</group>
<group string="按钮执行配置">
<field name="guide_method_name"
placeholder="后台方法名,如 notice_send_to_all" />
<field name="guide_method_desc"
placeholder="方法功能说明,方便维护" />
</group>
</group>
</page>
<!-- 技能接口配置 -->
<page string="技能接口配置" name="skill"
invisible="rule_type != 'skill'">
<group>
<group string="技能定义">
<field name="skill_name"
placeholder="如:query_weather"/>
<field name="skill_description"
placeholder="当用户询问天气时调用此技能"/>
</group>
<group string="接口配置">
<field name="skill_endpoint"
placeholder="https://api.example.com/weather"/>
<field name="skill_method"/>
<field name="skill_timeout"/>
</group>
</group>
<group string="参数定义">
<field name="skill_parameters" nolabel="1"
placeholder='{"type": "object", "properties": {"city": {"type": "string", "description": "城市名"}}, "required": ["city"]}'/>
</group>
<group string="请求头">
<field name="skill_headers" nolabel="1"
placeholder='{"Authorization": "Bearer xxx"}'/>
</group>
</page>
<!-- 调用模型方法配置 -->
<page string="方法配置" name="method"
invisible="rule_type != 'method'">
<group>
<group string="方法定义">
<field name="skill_name"
placeholder="如:recall_wecom_message"/>
<field name="skill_description"
placeholder="当用户要撤回企微消息时调用"/>
</group>
<group string="模型配置">
<field name="skill_model"
placeholder="如:attendance.message.log"/>
<field name="skill_method_name"
placeholder="如:action_recall_message"/>
</group>
</group>
<group string="参数定义">
<field name="skill_parameters" nolabel="1"
placeholder='{"type": "object", "properties": {"domain": {"type": "array", "description": "筛选条件"}, "ids": {"type": "array", "items": {"type": "integer"}, "description": "记录ID列表"}}, "required": []}'/>
</group>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<!-- ============================================ -->
<!-- AI 规则 - 搜索视图 -->
<!-- ============================================ -->
<record id="view_ai_rule_search" model="ir.ui.view">
<field name="name">ai.rule.search</field>
<field name="model">ai.rule</field>
<field name="arch" type="xml">
<search string="搜索规则">
<field name="name"/>
<field name="rule_type"/>
<filter name="filter_instruction" string="回复指令"
domain="[('rule_type','=','instruction')]"/>
<filter name="filter_restriction" string="限制规则"
domain="[('rule_type','=','restriction')]"/>
<filter name="filter_skill" string="技能接口"
domain="[('rule_type','=','skill')]"/>
<filter name="filter_method" string="模型方法"
domain="[('rule_type','=','method')]"/>
<filter name="filter_active_guide" string="主动感知"
domain="[('rule_type','=','active_guide')]"/>
<separator/>
<filter name="filter_active" string="已启用"
domain="[('active','=',True)]"/>
<filter name="filter_inactive" string="已停用"
domain="[('active','=',False)]"/>
<group expand="0" string="分组">
<filter name="group_type" string="规则类型"
context="{'group_by': 'rule_type'}"/>
</group>
</search>
</field>
</record>
<!-- Action -->
<record id="action_ai_rule" model="ir.actions.act_window">
<field name="name">规则配置</field>
<field name="res_model">ai.rule</field>
<field name="view_mode">tree,form</field>
<field name="context">{'search_default_filter_active': 1}</field>
</record>
<!-- 菜单 → 基础配置 -->
<menuitem id="menu_ai_rule" name="规则配置"
parent="menu_sys_base" action="action_ai_rule" sequence="2"
groups="yuthon_ai_agent.group_ai_agent_admin"/>
</odoo>