|
@@ -1,5 +1,4 @@
|
|
from flask import Flask, render_template, request, jsonify
|
|
from flask import Flask, render_template, request, jsonify
|
|
-from flask_cors import CORS
|
|
|
|
import psycopg2
|
|
import psycopg2
|
|
from psycopg2.extras import DictCursor
|
|
from psycopg2.extras import DictCursor
|
|
import logging
|
|
import logging
|
|
@@ -9,7 +8,6 @@ import datetime
|
|
import uuid
|
|
import uuid
|
|
|
|
|
|
app = Flask(__name__)
|
|
app = Flask(__name__)
|
|
-CORS(app)
|
|
|
|
|
|
|
|
|
|
|
|
# 配置日志
|
|
# 配置日志
|
|
@@ -60,7 +58,7 @@ def inputMsg():
|
|
|
|
|
|
# 生成提示信息
|
|
# 生成提示信息
|
|
prompt = f"""请扮演文本提取工具,把这句话:"{msg}",基于以下因子选择、选址范围和用地类型提取其对应的相关数据,提取结果请严格将json格式字符串输出并保障寄送格式正确无误,
|
|
prompt = f"""请扮演文本提取工具,把这句话:"{msg}",基于以下因子选择、选址范围和用地类型提取其对应的相关数据,提取结果请严格将json格式字符串输出并保障寄送格式正确无误,
|
|
- 选址范围 = ['抱坡区','天涯区','崖州区','海棠区','吉阳区'],
|
|
|
|
|
|
+ 选址范围 = ['抱坡区','天涯区','崖州区','海棠区','吉阳区',"青浦区","静安区","浦东新区","松江区','海淀区', '昌平区', '朝阳区' ],
|
|
因子选择 = [
|
|
因子选择 = [
|
|
"高程",
|
|
"高程",
|
|
"坡度",
|
|
"坡度",
|
|
@@ -103,7 +101,7 @@ def inputMsg():
|
|
area是用地大小,单位统一转换为亩
|
|
area是用地大小,单位统一转换为亩
|
|
factors.type是因子选择
|
|
factors.type是因子选择
|
|
其他公里、千米的单位转换为米
|
|
其他公里、千米的单位转换为米
|
|
- 默认输出的json格式数据如下:
|
|
|
|
|
|
+ 输出的json格式数据如下:
|
|
{{
|
|
{{
|
|
"districtName": "抱坡区",
|
|
"districtName": "抱坡区",
|
|
"landType": "耕地",
|
|
"landType": "耕地",
|
|
@@ -119,13 +117,11 @@ def inputMsg():
|
|
}},
|
|
}},
|
|
{{
|
|
{{
|
|
"type": "永久基本农田",
|
|
"type": "永久基本农田",
|
|
- "condition": "不相交",
|
|
|
|
- "value": "0"
|
|
|
|
|
|
+ "condition": "不相交"
|
|
}},
|
|
}},
|
|
{{
|
|
{{
|
|
"type": "城镇开发边界内",
|
|
"type": "城镇开发边界内",
|
|
- "condition": "包含",
|
|
|
|
- "value": "0"
|
|
|
|
|
|
+ "condition": "包含"
|
|
}},
|
|
}},
|
|
{{
|
|
{{
|
|
"type": "医疗卫生设施",
|
|
"type": "医疗卫生设施",
|
|
@@ -140,7 +136,6 @@ def inputMsg():
|
|
try:
|
|
try:
|
|
res = ollama.generate(
|
|
res = ollama.generate(
|
|
model="qwen2:7b",
|
|
model="qwen2:7b",
|
|
- # model="gemma2:27b",
|
|
|
|
stream=False,
|
|
stream=False,
|
|
prompt=prompt,
|
|
prompt=prompt,
|
|
options={"temperature": 0},
|
|
options={"temperature": 0},
|
|
@@ -180,7 +175,7 @@ def jsonResToDict(json_res):
|
|
formatted_time = now.strftime("%Y%m%d%H%M%S")
|
|
formatted_time = now.strftime("%Y%m%d%H%M%S")
|
|
res = {
|
|
res = {
|
|
"xzmj": 1500,
|
|
"xzmj": 1500,
|
|
- "xmmc": "聊天选址项目_"+formatted_time,
|
|
|
|
|
|
+ "xmmc": "规划选址项目_"+formatted_time,
|
|
"jsdw": "建设单位",
|
|
"jsdw": "建设单位",
|
|
"ydxz_bsm": landType,
|
|
"ydxz_bsm": landType,
|
|
"ydmjbegin": json_res["area"]["min"],
|
|
"ydmjbegin": json_res["area"]["min"],
|
|
@@ -227,7 +222,7 @@ def jsonResToDict(json_res):
|
|
"spatial_type": conditionObj["spatial_type"],
|
|
"spatial_type": conditionObj["spatial_type"],
|
|
"default": factor["condition"],
|
|
"default": factor["condition"],
|
|
"hasValue": conditionObj["hasValue"],
|
|
"hasValue": conditionObj["hasValue"],
|
|
- "defaultValue": str(factor["value"]),
|
|
|
|
|
|
+ "defaultValue": factor["value"],
|
|
"unit": conditionObj["unit"],
|
|
"unit": conditionObj["unit"],
|
|
"clip": conditionObj["clip"]
|
|
"clip": conditionObj["clip"]
|
|
}
|
|
}
|
|
@@ -241,11 +236,7 @@ def jsonResToDict(json_res):
|
|
else:
|
|
else:
|
|
factorTemplate["conditionInfo"]=json.loads(factorTemplate["conditionInfo"])
|
|
factorTemplate["conditionInfo"]=json.loads(factorTemplate["conditionInfo"])
|
|
res["yxyz"].append(factorTemplate)
|
|
res["yxyz"].append(factorTemplate)
|
|
- resObj={}
|
|
|
|
- resObj["data"]=res
|
|
|
|
- resObj["code"]=200
|
|
|
|
- resObj["type"]="selectLand"
|
|
|
|
- return resObj
|
|
|
|
|
|
+ return res
|
|
|
|
|
|
# 获取因子信息
|
|
# 获取因子信息
|
|
|
|
|