gushoubang 9 months ago
parent
commit
ab5bfb6f74
1 changed files with 7 additions and 16 deletions
  1. 7 16
      app.py

+ 7 - 16
app.py

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