Browse Source

智能选址agent

liutao 2 months ago
parent
commit
8dccca357c

+ 3 - 3
aiAgent_gd/qwen_agent/memory/data/sqls/sql_examples_智能选址.jsonl

@@ -2,16 +2,16 @@
   {
     "query_type": "land_site_selection",
     "query": "帮我在萧山区推荐几块50亩左右的工业用地,数据表是控制性详细规划",
-    "sql_code": "select id from sde.kzxxxgh where xzqmc = '萧山区' and ydxz like '%工业%' and abs(ydmj - 50*0.0667) <= 1  order by ydmj nulls last limit 5"
+    "sql_code": "select id from sde.kzxxxgh where xzqmc = '萧山区' and ydxz like '%工业%' and abs(ydmj - 50*0.0667) <= 1 and shape is not null order by ydmj nulls last limit 5"
   },
   {
     "query_type": "land_site_selection",
     "query": "帮我在萧山区推荐一宗1公顷左右的学校用地,数据表是控制性详细规划",
-    "sql_code": "select id from sde.kzxxxgh where xzqmc = '萧山区' and ydxz like '%学校%' and abs(ydmj - 1) <= 1 order by ydmj nulls last limit 1"
+    "sql_code": "select id from sde.kzxxxgh where xzqmc = '萧山区' and ydxz like '%学校%' and abs(ydmj - 1) <= 1 and shape is not null order by ydmj nulls last limit 1"
   },
   {
     "query_type": "land_site_selection",
     "query": "帮我在萧山区推荐几块50亩左右的工业用地,数据表是公告地块",
-    "sql_code": "select id from sde.ecgap_klyzy where xzqmc = '萧山区' and tdyt like '%工业%' and abs(dkmj-5) <= 1  order by dkmj nulls last limit 5"
+    "sql_code": "select id from sde.ecgap_klyzy where xzqmc = '萧山区' and tdyt like '%工业%' and abs(dkmj-5) <= 1 and shape is not null order by dkmj nulls last limit 5"
   }
 ]

+ 5 - 3
aiAgent_gd/qwen_agent/sub_agent/sql/land_site_selection_sql_agent.py

@@ -63,7 +63,7 @@ class LandSiteSelectionSqlAgent(BaseSubAgent):
             `dkid` COMMENTS '地块id',
             `address` COMMENTS '土地坐落',
             `dkmj` COMMENTS '土地面积,单位亩',
-            `tdyt` COMMENTS '土地规划用途',
+            `tdyt` COMMENTS '土地用途',
             `shape` COMMENTS '地块图形wkt',
             `sfsj` COMMENTS '是否上架 1表示已上架,0表示未上架'
         )
@@ -72,14 +72,16 @@ class LandSiteSelectionSqlAgent(BaseSubAgent):
         注意1:查询的数据表有两张,分别是控制性详细规划表(sde.kzxxxgh)和公告地块表(sde.ecgap_klyzy)
         注意2: 查询地区条件时,区县为**时请使用 xzqmc 字段。省为**时请先将行政区名称转换为行政区代码,使用xzqdm字段的前2位进行模糊查询,市为**时请先将行政区名称转换为行政区代码,使用xzqdm字段的前4位进行模糊查询
         注意3: 使用 order by 进行排序时。必须使用 nulls last 确保 null值不会对排序产生影响,使用方法如下: order by xxxx desc nulls last 或者 order by xxxx nulls last
-        注意4: 当用户问题中的面积等于不是一个确定值的时候,如‘面积为xx亩左右’或‘面积为xx平方米左右’或‘面积为xx公顷左右’, 需要条件中添加 abs(ydmj - xx) <= 1, 将面积差控制在1公顷之内。使用 ‘order by abs(ydmj - xx)  nulls last’ 来进行排序
-        注意5: 当用户问题中的面积是一个确定值的时候,如‘面积为xx亩’或‘面积为xx平方米’或‘面积为xx公顷左右’, 需要条件中添加 abs(ydmj - xx) <= 1, 将面积差控制在1公顷之内。使用 ‘order by abs(ydmj - xx)  nulls last’ 来进行排序
+        注意4: 控制性详细规划表的面积字段是ydmj,单位是公顷;公告地块表的面积字段是dkmj,单位是亩
+        注意4: 当用户问题中的面积等于不是一个确定值的时候,如‘面积为xx亩左右’或‘面积为xx平方米左右’或‘面积为xx公顷左右’, 需要条件中添加 abs(面积字段 - xx) <= 1, 将面积差控制在1公顷之内。使用 ‘order by abs(面积字段 - xx)  nulls last’ 来进行排序
+        注意5: 当用户问题中的面积是一个确定值的时候,如‘面积为xx亩’或‘面积为xx平方米’或‘面积为xx公顷左右’, 需要条件中添加 abs(面积字段 - xx) <= 1, 将面积差控制在1公顷之内。使用 ‘order by abs(面积字段 - xx)  nulls last’ 来进行排序
         注意6: 查询出地块。必须要对ydmj进行desc排序。查询地块有数量限制时,比如'1宗','一宗','1块',使用limit 1语句;未限定时,只查询5宗,使用limit 5语句
         注意7: 问题中设计具体的地点时,需要使用round(st_distance(st_geometryfromtext('具体地点的wkt', 4490)::geography,shape::geography)::numeric,0)获取其distance, 如果问题未指定范围则使用 distance <= 5000 来限制在地点5公里内,并对其排序
         注意8: 查询语句select种只包含id字段
         注意9: 只准生成查询 的sql 语句,不可生成任何 修改数据的语句, 比如:update, delete, insert, truncate 等
         注意10:当用户问题中的数据源是‘控制性详细规划表’,用地性质是"工业用地"时,去掉"用地",使用ydxz进行模糊查询,比如ydxz like '%工业%',工业用地没有二级分类
         注意11:数据表的schema是sde
+        注意17:where条件种需要加上shape is not null,过滤掉所有空图形
         """
         self.retriever = SqlRetriever(query_type='land_site_selection')