feat: LangGraph工作流核心 — Agent状态/节点/图 + 验证服务 + 知识库
agent/ state.py: AgentState TypedDict(20字段含意图/压缩/会话/撤销) nodes.py: 17个节点函数(生成/修改/验证/纠错/意图分类/压缩/撤销/重置) graph.py: 17节点状态图,8意图路由分发 验证服务 validation_service/ main.py: FastAPI服务,lxml XSD验证 + 结构化检查(字段引用/SQL/尺寸) 数据 data/ sample_templates/: 4个JRXML示例模板 corrections/: 3个错误修正案例 脚本 scripts/ init_kb.py: Chroma知识库初始化
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
# Error case: queryString is empty or missing
|
||||
# Correction: add SQL query in CDATA
|
||||
|
||||
ERROR: <queryString></queryString> is empty.
|
||||
|
||||
FIX: Add a SQL query inside CDATA: <queryString><![CDATA[SELECT col1, col2 FROM table_name]]></queryString>
|
||||
@@ -0,0 +1,6 @@
|
||||
# Error case: field used in expression but not declared
|
||||
# Correction: add field declaration
|
||||
|
||||
ERROR: textFieldExpression uses $F{total_amount} but no <field name="total_amount"> declared.
|
||||
|
||||
FIX: Add <field name="total_amount" class="java.math.BigDecimal"/> to the field declarations section.
|
||||
@@ -0,0 +1,6 @@
|
||||
# Error case: jasperReport missing pageWidth and pageHeight
|
||||
# Correction: add page dimensions
|
||||
|
||||
ERROR: <jasperReport name="Report" ...> has no pageWidth/pageHeight attributes.
|
||||
|
||||
FIX: Add pageWidth="595" pageHeight="842" to the <jasperReport> root element.
|
||||
@@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
|
||||
name="EmployeeRoster" pageWidth="595" pageHeight="842" columnWidth="555"
|
||||
leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
|
||||
<queryString>
|
||||
<![CDATA[SELECT emp_id, emp_name, department, hire_date FROM employees ORDER BY department, emp_name]]>
|
||||
</queryString>
|
||||
<field name="emp_id" class="java.lang.Integer"/>
|
||||
<field name="emp_name" class="java.lang.String"/>
|
||||
<field name="department" class="java.lang.String"/>
|
||||
<field name="hire_date" class="java.sql.Date"/>
|
||||
<title>
|
||||
<band height="50">
|
||||
<staticText>
|
||||
<reportElement x="0" y="10" width="555" height="30"/>
|
||||
<textElement textAlignment="Center">
|
||||
<font size="16" isBold="true"/>
|
||||
</textElement>
|
||||
<text><![CDATA[Employee Roster]]></text>
|
||||
</staticText>
|
||||
</band>
|
||||
</title>
|
||||
<columnHeader>
|
||||
<band height="25">
|
||||
<staticText>
|
||||
<reportElement x="0" y="0" width="80" height="20"/>
|
||||
<textElement><font isBold="true"/></textElement>
|
||||
<text><![CDATA[ID]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement x="90" y="0" width="180" height="20"/>
|
||||
<textElement><font isBold="true"/></textElement>
|
||||
<text><![CDATA[Name]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement x="280" y="0" width="150" height="20"/>
|
||||
<textElement><font isBold="true"/></textElement>
|
||||
<text><![CDATA[Department]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement x="440" y="0" width="115" height="20"/>
|
||||
<textElement><font isBold="true"/></textElement>
|
||||
<text><![CDATA[Hire Date]]></text>
|
||||
</staticText>
|
||||
</band>
|
||||
</columnHeader>
|
||||
<detail>
|
||||
<band height="20">
|
||||
<textField>
|
||||
<reportElement x="0" y="0" width="80" height="20"/>
|
||||
<textFieldExpression><![CDATA[$F{emp_id}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField>
|
||||
<reportElement x="90" y="0" width="180" height="20"/>
|
||||
<textFieldExpression><![CDATA[$F{emp_name}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField>
|
||||
<reportElement x="280" y="0" width="150" height="20"/>
|
||||
<textFieldExpression><![CDATA[$F{department}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField>
|
||||
<reportElement x="440" y="0" width="115" height="20"/>
|
||||
<textFieldExpression><![CDATA[$F{hire_date}]]></textFieldExpression>
|
||||
</textField>
|
||||
</band>
|
||||
</detail>
|
||||
</jasperReport>
|
||||
@@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
|
||||
name="InventoryList" pageWidth="595" pageHeight="842" columnWidth="555"
|
||||
leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
|
||||
<queryString>
|
||||
<![CDATA[SELECT item_code, item_name, category, quantity, unit_price FROM inventory ORDER BY category, item_name]]>
|
||||
</queryString>
|
||||
<field name="item_code" class="java.lang.String"/>
|
||||
<field name="item_name" class="java.lang.String"/>
|
||||
<field name="category" class="java.lang.String"/>
|
||||
<field name="quantity" class="java.lang.Integer"/>
|
||||
<field name="unit_price" class="java.math.BigDecimal"/>
|
||||
<title>
|
||||
<band height="50">
|
||||
<staticText>
|
||||
<reportElement x="0" y="10" width="555" height="30"/>
|
||||
<textElement textAlignment="Center">
|
||||
<font size="16" isBold="true"/>
|
||||
</textElement>
|
||||
<text><![CDATA[Inventory List]]></text>
|
||||
</staticText>
|
||||
</band>
|
||||
</title>
|
||||
<columnHeader>
|
||||
<band height="25">
|
||||
<staticText>
|
||||
<reportElement x="0" y="0" width="100" height="20"/>
|
||||
<textElement><font isBold="true"/></textElement>
|
||||
<text><![CDATA[Code]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement x="110" y="0" width="180" height="20"/>
|
||||
<textElement><font isBold="true"/></textElement>
|
||||
<text><![CDATA[Item Name]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement x="300" y="0" width="100" height="20"/>
|
||||
<textElement><font isBold="true"/></textElement>
|
||||
<text><![CDATA[Category]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement x="410" y="0" width="70" height="20"/>
|
||||
<textElement><font isBold="true"/></textElement>
|
||||
<text><![CDATA[Qty]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement x="485" y="0" width="70" height="20"/>
|
||||
<textElement><font isBold="true"/></textElement>
|
||||
<text><![CDATA[Price]]></text>
|
||||
</staticText>
|
||||
</band>
|
||||
</columnHeader>
|
||||
<detail>
|
||||
<band height="20">
|
||||
<textField>
|
||||
<reportElement x="0" y="0" width="100" height="20"/>
|
||||
<textFieldExpression><![CDATA[$F{item_code}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField>
|
||||
<reportElement x="110" y="0" width="180" height="20"/>
|
||||
<textFieldExpression><![CDATA[$F{item_name}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField>
|
||||
<reportElement x="300" y="0" width="100" height="20"/>
|
||||
<textFieldExpression><![CDATA[$F{category}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField>
|
||||
<reportElement x="410" y="0" width="70" height="20"/>
|
||||
<textFieldExpression><![CDATA[$F{quantity}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField>
|
||||
<reportElement x="485" y="0" width="70" height="20"/>
|
||||
<textFieldExpression><![CDATA[$F{unit_price}]]></textFieldExpression>
|
||||
</textField>
|
||||
</band>
|
||||
</detail>
|
||||
</jasperReport>
|
||||
@@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
|
||||
name="SalesSummary" pageWidth="595" pageHeight="842" columnWidth="555"
|
||||
leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
|
||||
<queryString>
|
||||
<![CDATA[SELECT department, total_sales, employee_count FROM dept_summary ORDER BY total_sales DESC]]>
|
||||
</queryString>
|
||||
<field name="department" class="java.lang.String"/>
|
||||
<field name="total_sales" class="java.math.BigDecimal"/>
|
||||
<field name="employee_count" class="java.lang.Integer"/>
|
||||
<variable name="grand_total" class="java.math.BigDecimal" calculation="Sum">
|
||||
<variableExpression><![CDATA[$F{total_sales}]]></variableExpression>
|
||||
</variable>
|
||||
<variable name="total_employees" class="java.lang.Integer" calculation="Sum">
|
||||
<variableExpression><![CDATA[$F{employee_count}]]></variableExpression>
|
||||
</variable>
|
||||
<title>
|
||||
<band height="60">
|
||||
<staticText>
|
||||
<reportElement x="0" y="10" width="555" height="30"/>
|
||||
<textElement textAlignment="Center">
|
||||
<font size="16" isBold="true"/>
|
||||
</textElement>
|
||||
<text><![CDATA[Department Sales Summary]]></text>
|
||||
</staticText>
|
||||
</band>
|
||||
</title>
|
||||
<columnHeader>
|
||||
<band height="25">
|
||||
<staticText>
|
||||
<reportElement x="0" y="0" width="200" height="20"/>
|
||||
<textElement><font isBold="true"/></textElement>
|
||||
<text><![CDATA[Department]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement x="210" y="0" width="170" height="20"/>
|
||||
<textElement textAlignment="Right"><font isBold="true"/></textElement>
|
||||
<text><![CDATA[Total Sales]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement x="390" y="0" width="165" height="20"/>
|
||||
<textElement textAlignment="Right"><font isBold="true"/></textElement>
|
||||
<text><![CDATA[Employee Count]]></text>
|
||||
</staticText>
|
||||
</band>
|
||||
</columnHeader>
|
||||
<detail>
|
||||
<band height="20">
|
||||
<textField>
|
||||
<reportElement x="0" y="0" width="200" height="20"/>
|
||||
<textFieldExpression><![CDATA[$F{department}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField>
|
||||
<reportElement x="210" y="0" width="170" height="20"/>
|
||||
<textElement textAlignment="Right"/>
|
||||
<textFieldExpression><![CDATA[$F{total_sales}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField>
|
||||
<reportElement x="390" y="0" width="165" height="20"/>
|
||||
<textElement textAlignment="Right"/>
|
||||
<textFieldExpression><![CDATA[$F{employee_count}]]></textFieldExpression>
|
||||
</textField>
|
||||
</band>
|
||||
</detail>
|
||||
<summary>
|
||||
<band height="40">
|
||||
<line>
|
||||
<reportElement x="0" y="0" width="555" height="1"/>
|
||||
</line>
|
||||
<staticText>
|
||||
<reportElement x="0" y="5" width="200" height="20"/>
|
||||
<textElement><font isBold="true"/></textElement>
|
||||
<text><![CDATA[Grand Total]]></text>
|
||||
</staticText>
|
||||
<textField>
|
||||
<reportElement x="210" y="5" width="170" height="20"/>
|
||||
<textElement textAlignment="Right"><font isBold="true"/></textElement>
|
||||
<textFieldExpression><![CDATA[$V{grand_total}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField>
|
||||
<reportElement x="390" y="5" width="165" height="20"/>
|
||||
<textElement textAlignment="Right"><font isBold="true"/></textElement>
|
||||
<textFieldExpression><![CDATA[$V{total_employees}]]></textFieldExpression>
|
||||
</textField>
|
||||
</band>
|
||||
</summary>
|
||||
</jasperReport>
|
||||
@@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
|
||||
name="SalesOrder" pageWidth="595" pageHeight="842" columnWidth="555"
|
||||
leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
|
||||
<queryString>
|
||||
<![CDATA[SELECT order_id, customer_name, amount, order_date FROM sales_orders ORDER BY order_date DESC]]>
|
||||
</queryString>
|
||||
<field name="order_id" class="java.lang.String"/>
|
||||
<field name="customer_name" class="java.lang.String"/>
|
||||
<field name="amount" class="java.math.BigDecimal"/>
|
||||
<field name="order_date" class="java.sql.Date"/>
|
||||
<title>
|
||||
<band height="50">
|
||||
<staticText>
|
||||
<reportElement x="0" y="10" width="555" height="30"/>
|
||||
<textElement textAlignment="Center">
|
||||
<font size="16" isBold="true"/>
|
||||
</textElement>
|
||||
<text><![CDATA[Sales Orders Report]]></text>
|
||||
</staticText>
|
||||
</band>
|
||||
</title>
|
||||
<columnHeader>
|
||||
<band height="25">
|
||||
<staticText>
|
||||
<reportElement x="0" y="0" width="120" height="20"/>
|
||||
<textElement><font isBold="true"/></textElement>
|
||||
<text><![CDATA[Order ID]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement x="130" y="0" width="180" height="20"/>
|
||||
<textElement><font isBold="true"/></textElement>
|
||||
<text><![CDATA[Customer]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement x="320" y="0" width="120" height="20"/>
|
||||
<textElement><font isBold="true"/></textElement>
|
||||
<text><![CDATA[Amount]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement x="450" y="0" width="105" height="20"/>
|
||||
<textElement><font isBold="true"/></textElement>
|
||||
<text><![CDATA[Order Date]]></text>
|
||||
</staticText>
|
||||
</band>
|
||||
</columnHeader>
|
||||
<detail>
|
||||
<band height="20">
|
||||
<textField>
|
||||
<reportElement x="0" y="0" width="120" height="20"/>
|
||||
<textFieldExpression><![CDATA[$F{order_id}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField>
|
||||
<reportElement x="130" y="0" width="180" height="20"/>
|
||||
<textFieldExpression><![CDATA[$F{customer_name}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField>
|
||||
<reportElement x="320" y="0" width="120" height="20"/>
|
||||
<textFieldExpression><![CDATA[$F{amount}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField>
|
||||
<reportElement x="450" y="0" width="105" height="20"/>
|
||||
<textFieldExpression><![CDATA[$F{order_date}]]></textFieldExpression>
|
||||
</textField>
|
||||
</band>
|
||||
</detail>
|
||||
</jasperReport>
|
||||
Reference in New Issue
Block a user