This commit is contained in:
parent
f864b82255
commit
4d567d98f4
12
app.py
12
app.py
|
|
@ -81,6 +81,14 @@ def load_indices_from_es(key: str, index: str, buf: Dict[str, Any]) -> Any:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def reload_buf(ikey, ibuf):
|
||||||
|
ret = load_indices_from_es(ikey, 'customer', ibuf)
|
||||||
|
if not ret:
|
||||||
|
exit("客服AI员工不能拥有数据库。")
|
||||||
|
|
||||||
|
customer_data=buf[key]['customer database']
|
||||||
|
app.set_customer_data(customer_data)
|
||||||
|
|
||||||
def extract_index_structure(es_client, index_name):
|
def extract_index_structure(es_client, index_name):
|
||||||
"""
|
"""
|
||||||
扫描 Elasticsearch 索引中的一个文档,递归提取字段结构(包括嵌套字段),生成包含所有字段的层级关系和类型信息。
|
扫描 Elasticsearch 索引中的一个文档,递归提取字段结构(包括嵌套字段),生成包含所有字段的层级关系和类型信息。
|
||||||
|
|
@ -209,6 +217,8 @@ def calculate_statistics():
|
||||||
|
|
||||||
@app.route('/customer/<int:index>')
|
@app.route('/customer/<int:index>')
|
||||||
def view_customer(index):
|
def view_customer(index):
|
||||||
|
|
||||||
|
reload_buf(key, buf)
|
||||||
# 判断是否有数据
|
# 判断是否有数据
|
||||||
if not customer_data:
|
if not customer_data:
|
||||||
return "No customer data provided.", 400
|
return "No customer data provided.", 400
|
||||||
|
|
@ -309,6 +319,7 @@ def search_by_email():
|
||||||
if not email:
|
if not email:
|
||||||
return "Email address is required.", 400
|
return "Email address is required.", 400
|
||||||
|
|
||||||
|
reload_buf(key, buf)
|
||||||
# 遍历 customer_data 查找匹配的邮件地址
|
# 遍历 customer_data 查找匹配的邮件地址
|
||||||
for index, customer in enumerate(customer_data):
|
for index, customer in enumerate(customer_data):
|
||||||
for domain, info in customer.items():
|
for domain, info in customer.items():
|
||||||
|
|
@ -329,6 +340,7 @@ def search_by_domain():
|
||||||
if not domain:
|
if not domain:
|
||||||
return "Domain is required.", 400
|
return "Domain is required.", 400
|
||||||
|
|
||||||
|
reload_buf(key, buf)
|
||||||
# 遍历 customer_data 查找匹配的域名
|
# 遍历 customer_data 查找匹配的域名
|
||||||
for index, customer in enumerate(customer_data):
|
for index, customer in enumerate(customer_data):
|
||||||
if domain in customer:
|
if domain in customer:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue