浏览代码

智能选址agent修改

liutao 3 月之前
父节点
当前提交
f86d4aae19

+ 5 - 0
aiAgent_gd/qwen_agent/memory/data/plans/plan_examples_智能选址.jsonl

@@ -13,5 +13,10 @@
     "query_type": "land_site_selection",
     "query": "帮我在杭州市滨江区正泰大厦附近推荐一宗50亩左右的标准厂房",
     "plan": "Question: 帮我在杭州市滨江区正泰大厦附近推荐一宗50亩左右的标准厂房 \nThought: 用户问题中想查询城市为‘杭州市’,区县为‘滨江区’,详细地点为‘杭州市滨江区正泰大厦’,数量为‘1’宗,面积为‘50’亩左右,土地用途为‘标准厂房’的地块,所以需要先通过[GisGeocoderAgent]将详细的地址转换为坐标点,再通过[LandSiteSelectionSqlAgent]查询图层信息,最后使用summary的Action来总结并输出。Plan: ```json\n    [{\"action_name\": \"GisGeocoderAgent\", \"instruction\": \"你需要调用 [GisGeocoderAgent],来将‘杭州市滨江区正泰大厦’ 转换为坐标wkt\"},\n {\"action_name\": \"LandSiteSelectionSqlAgent\", \"instruction\": \"你需要调用 [LandSiteSelectionSqlAgent],来查询行政区为‘滨江区’,面积为‘50’亩左右,土地用途为‘标准厂房’的地块\"},   {\"action_name\": \"summary\", \"instruction\": \"你需要根据用户的Question和查询的结果,回答用户问题。\"}]"
+  },
+  {
+    "query_type": "land_site_selection",
+    "query": "请在萧山机场附近选出30-100亩之间适用来做物流仓储的地块",
+    "plan": "Question: 帮我在萧山机场附近推荐一宗50亩左右的标准厂房 \nThought: 用户问题中想查询详细地点为‘萧山机场’,面积为‘30-100’亩左右,土地用途为‘物流仓储’的地块,再通过[LandSiteSelectionSqlAgent]查询图层信息,最后使用summary的Action来总结并输出。Plan: ```json\n    [\n {\"action_name\": \"LandSiteSelectionSqlAgent\", \"instruction\": \"你需要调用 [LandSiteSelectionSqlAgent],来查询行政区为‘萧山区’,面积为‘30-100’亩左右,土地用途为‘物流仓储’的地块\"},   {\"action_name\": \"summary\", \"instruction\": \"你需要根据用户的Question和查询的结果,回答用户问题。\"}]"
   }
 ]

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

@@ -1,17 +1,22 @@
 [
- {
-  "query_type": "land_site_selection",
-  "query": "帮我在萧山区推荐几块50亩左右的工业用地",
-  "sql_code": "select id, dkid, xzqmc, dkmc, address, dkmj, tdyt, st_astext(st_centroid(shape)) as center_wkt from sde.ecgap_klyzy where xzqmc = '萧山区' and tdyt in ('工业用地','通用仓储类','标准厂房','工业用地(新业态用地M0)','工矿仓储用地','其他工业用地') and abs(dkmj - 50) <= 5 and sfsj=1 order by dkmj nulls last limit 10"
- },
- {
-  "query_type": "land_site_selection",
-  "query": "帮我在萧山区推荐一宗50亩左右的标准厂房",
-  "sql_code": "select id, dkid, xzqmc, dkmc, address, dkmj, tdyt, st_astext(st_centroid(shape)) as center_wkt from sde.ecgap_klyzy where xzqmc = '萧山区' and tdyt ='标准厂房' and abs(dkmj - 50) <= 5 and sfsj=1 order by dkmj nulls last limit 1"
- },
- {
- "query_type": "land_site_selection",
- "query": "帮我在杭州市滨江区正泰大厦附近推荐一宗50亩左右的标准厂房",
- "sql_code": "select t.* from (select id, dkid, xzqmc, dkmc, address, dkmj, tdyt, round(st_distance(st_geometryfromtext('POINT (40520795.286336236 3343271.716593298)', 4528), st_transform(shape, 4528))::numeric,0) as distance, st_astext(st_centroid(shape)) as center_wkt from sde.ecgap_klyzy where xzqmc = '萧山区' and tdyt ='标准厂房' and sfsj=1 and abs(dkmj - 50) <= 5) as t where t.distance <= 5000  order by t.dkmj nulls last limit 1"
-}
+  {
+    "query_type": "land_site_selection",
+    "query": "帮我在萧山区推荐几块50亩左右的工业用地",
+    "sql_code": "select id, dkid, xzqmc, dkmc, address, dkmj, tdyt, st_astext(st_centroid(shape)) as center_wkt from sde.ecgap_klyzy where xzqmc = '萧山区' and tdyt in ('工业用地','通用仓储类','标准厂房','工业用地(新业态用地M0)','工矿仓储用地','其他工业用地') and abs(dkmj - 50) <= 5 and sfsj=1 order by dkmj nulls last limit 10"
+  },
+  {
+    "query_type": "land_site_selection",
+    "query": "帮我在萧山区推荐一宗50亩左右的标准厂房",
+    "sql_code": "select id, dkid, xzqmc, dkmc, address, dkmj, tdyt, st_astext(st_centroid(shape)) as center_wkt from sde.ecgap_klyzy where xzqmc = '萧山区' and tdyt ='标准厂房' and abs(dkmj - 50) <= 5 and sfsj=1 order by dkmj nulls last limit 1"
+  },
+  {
+    "query_type": "land_site_selection",
+    "query": "帮我在杭州市滨江区正泰大厦附近推荐一宗50亩左右的标准厂房",
+    "sql_code": "select t.* from (select id, dkid, xzqmc, dkmc, address, dkmj, tdyt, round(st_distance(st_geometryfromtext('POINT (120.42827489304307 30.23751646603668)', 4490)::geography,shape::geography)::numeric,0) as distance, st_astext(st_centroid(shape)) as center_wkt from sde.ecgap_klyzy where tdyt ='工业用地' and sfsj=1 and dkmj BETWEEN 30 and 100) as t where t.distance <= 5000  order by t.dkmj nulls last limit 10"
+  },
+  {
+    "query_type": "land_site_selection",
+    "query": "请在萧山机场附近选出30-100亩之间适用来做物流仓储的地块",
+    "sql_code": "select t.* from (select id, dkid, xzqmc, dkmc, address, dkmj, tdyt, round(st_distance(st_geometryfromtext('POINT (120.42827489304307 30.23751646603668)', 4490)::geography,shape::geography)::numeric,0) as distance, st_astext(st_centroid(shape)) as center_wkt from sde.ecgap_klyzy where dkmc like '%仓储%' and sfsj=1 and dkmj BETWEEN 30 and 100) as t where t.distance <= 5000  order by t.dkmj nulls last limit 10"
+  }
 ]

+ 2 - 7
aiAgent_gd/qwen_agent/planning/plans/land_site_selection_plan.py

@@ -28,16 +28,11 @@ Plan: 生成的计划,包含函数名和执行的目标。以JSON格式返回
 
 注意0:如果用户需要生成图表,那么最后一步请调用[generate_chart]这个action,针对用户Question和查询数据库结果生成options;
 注意1:最后一步必须调用[summary]这个action,针对用户Question和查询数据库结果进行总结摘要,提取用户关注信息;
-注意2:这里是一个土地市场交易分析模块,通常用户Question中会包含需要了解的目标区域的名称、分析时间、分析目标等,而[LandSupplySqlAgent]这个接口只能每次一个区域的特地的交易信息。请你在生成执行计划时,调用多次[LandSupplySqlAgent],每次查询不通区域的交易情况。
-注意3:如果出现SUM函数,必须使用:: FLOAT将返回结果转换为float类型
-
+注意2:如果出现SUM函数,必须使用:: FLOAT将返回结果转换为float类型
+注意3:如果详细坐标点是‘萧山机场’,‘萧山国际机场’,‘杭州萧山机场’,使用固定的坐标数据POINT(120.42827489304307 30.23751646603668),不使用[GisGeocoderAgent]接口进行查询
 """
 
 examples = """
-Examples #1:
-Question: “杭州市”近五年土地交易情况,并生成折线图
-Thought: Thought: 用户问题中想要查询“杭州市”“近五年”“居住用地” 土地交易情况,所以需要通过[SumSqlAgent]查询土地拍卖信息,最后使用summary的Action来表杭州市近五年土地居住用地交易情况。
-Plan: ```json\n    [{\"action_name\": \"SumSqlAgent\", \"instruction\": \"你需要调用 [SumSqlAgent],来查询交易地区为“杭州市”居住用地拍卖宗数、面积、金额情况\"},\n    {\"action_name\": \"summary\", \"instruction\": \"你需要根据用户的Question和数据库查询的结果,回答用户问题。\"}\nPlan: [{\"action_name\": \"SumSqlAgent\", \"instruction\": \"你需要从数据库查询土地交易表,统计Question中需要的信息\"}, {\"action_name\": \"summary\",\"instruction\": \"根据以上的结果,你需要对结果进行总结分析,回答用户Question\"}]
 
 
 ```

+ 1 - 0
aiAgent_gd/qwen_agent/sub_agent/sql/land_site_selection_sql_agent.py

@@ -75,6 +75,7 @@ class LandSiteSelectionSqlAgent(BaseSubAgent):
                     水工建筑用地:包含以下几种土地用途小类 水域及水利设施用地
                     特殊用地:包含以下几种土地用途小类 特殊用地
                     住宅用地:包含以下几种土地用途小类 居住用地,城镇住宅-用于安置的商品住房用地,住宅用地,农村宅基地,城镇住宅-保障性租赁住房,城镇住宅-租赁型商品住房,城镇住宅-公共租赁住房,城镇住宅-普通商品住房,城镇住宅-经济适用住房,城镇住宅用地
+        注意17: 如果土地用途是‘物流仓储’,不使用tdyt进行查询,使用dkmc进行模糊查询,比如:dkmc like '%仓储%'
         ```
         以下是可供参考的SQL写法(仅供参考,也可自由发挥):
         ```

+ 1 - 1
aiAgent_gd/qwen_agent/tools/gis/geocoder/geocoder_tdt.py

@@ -28,7 +28,7 @@ class GeocoderTDT:
             lon = location["lon"]
             lat = location["lat"]
             # 查询出来的是4326坐标系
-            x, y = proj_transform(lon, lat, 4326, 4528)
+            x, y = proj_transform(lon, lat, 4326, 4490)
             return Point(y, x).wkt
         except Exception as e:
             print(f"地理编码发生错误:{e}")