Initial commit
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
from langchain_neo4j import nl_query_to_function_call
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
input_str = "杆塔总基数"
|
||||
|
||||
import json
|
||||
|
||||
# 打开并读取 JSON 文件
|
||||
with open("./data/data.json", "r", encoding="utf-8") as f:
|
||||
json_data = json.load(f)
|
||||
|
||||
temp_result = None
|
||||
for item in json_data:
|
||||
if item["指标名称"] == input_str:
|
||||
temp_result = item
|
||||
break
|
||||
|
||||
if temp_result:
|
||||
if temp_result["code"] == "":
|
||||
question = {
|
||||
"type": "query",
|
||||
"value": temp_result["指标描述"],
|
||||
}
|
||||
result = nl_query_to_function_call(question)
|
||||
|
||||
if result["message"] == "成功":
|
||||
code_result = result["data"]["code"]
|
||||
temp_result["code"] = code_result
|
||||
with open("./data/data.json", "w", encoding="utf-8") as f:
|
||||
json.dump(json_data, f, ensure_ascii=False, indent=4)
|
||||
print(f"已更新 code 字段")
|
||||
else:
|
||||
question = {
|
||||
"type": "code",
|
||||
"value": temp_result["code"],
|
||||
}
|
||||
result = nl_query_to_function_call(question)
|
||||
else:
|
||||
pass
|
||||
|
||||
|
||||
# 示例使用
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user