|
@@ -6,6 +6,7 @@ from typing import List
|
|
from zipfile import ZipFile
|
|
from zipfile import ZipFile
|
|
import json
|
|
import json
|
|
import fiona
|
|
import fiona
|
|
|
|
+from pydantic import BaseModel
|
|
from shapely.geometry import shape
|
|
from shapely.geometry import shape
|
|
from sse_starlette.sse import EventSourceResponse
|
|
from sse_starlette.sse import EventSourceResponse
|
|
from fastapi import FastAPI, UploadFile, File, Form
|
|
from fastapi import FastAPI, UploadFile, File, Form
|
|
@@ -26,7 +27,8 @@ from qwen_agent.llm.llm_client import LLMClient, LLMAsyncClient
|
|
from agent_config import LLMDict_Qwen_72B_1211, LLMDict_GPT4_TURBO
|
|
from agent_config import LLMDict_Qwen_72B_1211, LLMDict_GPT4_TURBO
|
|
from agent_messages import BaseRequest
|
|
from agent_messages import BaseRequest
|
|
from qwen_agent.tools.tools import async_xzdb
|
|
from qwen_agent.tools.tools import async_xzdb
|
|
-from qwen_agent.tools.gis.spatial_analysis.geo_analysis import intersect_kfq,intersect_gyyd
|
|
|
|
|
|
+from qwen_agent.tools.gis.spatial_analysis.geo_analysis import intersect_kfq, intersect_gyyd
|
|
|
|
+
|
|
prompt_lan = "CN"
|
|
prompt_lan = "CN"
|
|
llm_name = "qwen-plus"
|
|
llm_name = "qwen-plus"
|
|
llm_turbo_name = "gpt-4-turbo"
|
|
llm_turbo_name = "gpt-4-turbo"
|
|
@@ -174,9 +176,18 @@ async def clarificationByTurbo(request: BaseRequest):
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
-@app.get("/queryGeometry")
|
|
|
|
-async def queryGeometry(id: int):
|
|
|
|
- sql = f'select objectid, xzqmc, xzqdm, dymc, yddm, ydxz, ydmj, rjlsx, rjlxx, jzmdsx, jzmdxx, jzgdsx, jzgdxx, ldlsx, ldlxx, pfwh, pfsj, shape, st_area(shape::geography) as pfmarea,st_astext(shape) as geom, st_astext(st_centroid(shape)) as center_wkt from dlgis.gcs330000g2007_kzxxxgh_kgdk_kgy_dsgj where objectid = {id}'
|
|
|
|
|
|
+@app.get("/kgQuery")
|
|
|
|
+async def kgQuery(id: str):
|
|
|
|
+ sql = f'select objectid, xzqmc, xzqdm, dymc, yddm, ydxz, ydmj, rjlsx, rjlxx, jzmdsx, jzmdxx, jzgdsx, jzgdxx, ldlsx, ldlxx, pfwh, pfsj, st_area(shape::geography) as pfmarea,st_astext(shape) as geom, st_astext(st_centroid(shape)) as center_wkt from sde.kzxxxgh where objectid in ({id})'
|
|
|
|
+ res_tuples = await async_xzdb.run(sql)
|
|
|
|
+ result, success = res_tuples
|
|
|
|
+ print(success, result)
|
|
|
|
+ return json.loads(result)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+@app.get("/klyzyQuery")
|
|
|
|
+async def klyzyQuery(id: str):
|
|
|
|
+ sql = f'select *, st_astext(shape) as geom, st_astext(st_centroid(shape)) as center_wkt from sde.ecgap_klyzy where id in ({id})'
|
|
res_tuples = await async_xzdb.run(sql)
|
|
res_tuples = await async_xzdb.run(sql)
|
|
result, success = res_tuples
|
|
result, success = res_tuples
|
|
print(success, result)
|
|
print(success, result)
|
|
@@ -191,6 +202,7 @@ async def queryGeometryList(items):
|
|
print(success, result)
|
|
print(success, result)
|
|
return json.loads(result)
|
|
return json.loads(result)
|
|
|
|
|
|
|
|
+
|
|
@app.get("/queryYjjbntGeometry")
|
|
@app.get("/queryYjjbntGeometry")
|
|
async def queryYjjbntGeometry(id: int):
|
|
async def queryYjjbntGeometry(id: int):
|
|
sql = f'select *,st_astext(shape) as geom from dlgis.gcs330000g2001_yjjbnt_gx_xsb where objectid = {id}'
|
|
sql = f'select *,st_astext(shape) as geom from dlgis.gcs330000g2001_yjjbnt_gx_xsb where objectid = {id}'
|
|
@@ -199,17 +211,20 @@ async def queryYjjbntGeometry(id: int):
|
|
print(success, result)
|
|
print(success, result)
|
|
return json.loads(result)
|
|
return json.loads(result)
|
|
|
|
|
|
|
|
+
|
|
@app.get("/kfqintersect")
|
|
@app.get("/kfqintersect")
|
|
-async def kfqintersect(wkt:str):
|
|
|
|
- result= await intersect_kfq(
|
|
|
|
|
|
+async def kfqintersect(wkt: str):
|
|
|
|
+ result = await intersect_kfq(
|
|
wkt)
|
|
wkt)
|
|
return result
|
|
return result
|
|
|
|
|
|
-@app.get("/intersect_gyyd")
|
|
|
|
-async def gyydintersect(wkt:str):
|
|
|
|
- result= await intersect_gyyd(wkt)
|
|
|
|
|
|
+
|
|
|
|
+@app.get("/gyydintersect")
|
|
|
|
+async def gyydintersect(wkt: str):
|
|
|
|
+ result = await intersect_gyyd(wkt)
|
|
return result
|
|
return result
|
|
|
|
|
|
|
|
+
|
|
llm_client = LLMClient(model=llm_name, model_server=model_server)
|
|
llm_client = LLMClient(model=llm_name, model_server=model_server)
|
|
llm_client_async = LLMAsyncClient(model=llm_name, model_server=model_server)
|
|
llm_client_async = LLMAsyncClient(model=llm_name, model_server=model_server)
|
|
|
|
|