枚举结果处理
This commit is contained in:
		| @@ -1,6 +1,7 @@ | ||||
| from email.policy import default | ||||
| import logging | ||||
|  | ||||
| import util.utils | ||||
| from logging_config import LOGGING_CONFIG | ||||
| from service.cus_vanna_srevice import CustomVanna, QdrantClient | ||||
| from decouple import config | ||||
| @@ -97,18 +98,20 @@ def generate_sql_2(): | ||||
|         return jsonify({"type": "error", "error": "No question provided"}) | ||||
|     try: | ||||
|         id = cache.generate_id(question=question) | ||||
|         logger.info(f"Generate sql for {question}") | ||||
|         data = vn.generate_sql_2(question=question) | ||||
|         logger.info("Generate sql result is {0}".format(data)) | ||||
|         data['id'] = id | ||||
|         sql = data["resp"]["sql"] | ||||
|         print("sql:", sql) | ||||
|         cache.set(id=id, field="question", value=question) | ||||
|         cache.set(id=id, field="sql", value=sql) | ||||
|         print("data---------------------------", data) | ||||
|         data["type"]="success" | ||||
|         return jsonify(data) | ||||
|     except Exception as e: | ||||
|         return jsonify({"type": "error", "error": str(e)}) | ||||
|  | ||||
|  | ||||
|  | ||||
| @app.flask_app.route("/api/v0/run_sql_2", methods=["GET"]) | ||||
| @app.requires_cache(["sql"]) | ||||
| def run_sql_2(id: str, sql: str): | ||||
| @@ -150,13 +153,15 @@ def run_sql_2(id: str, sql: str): | ||||
|         df = vn.run_sql(sql=sql) | ||||
|         logger.info("") | ||||
|         app.cache.set(id=id, field="df", value=df) | ||||
|         x = df.head(10).to_dict(orient='records') | ||||
|         x = df.to_dict(orient='records') | ||||
|         logger.info("df ---------------{0}   {1}".format(x,type(x))) | ||||
|         result = util.utils.deal_result(data=x) | ||||
|  | ||||
|         return jsonify( | ||||
|             { | ||||
|                 "type": "df", | ||||
|                 "type": "success", | ||||
|                 "id": id, | ||||
|                 "df": df.head(10).to_dict(orient='records'), | ||||
|                 "df": result, | ||||
|             } | ||||
|         ) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 yujj128
					yujj128