This commit is contained in:
hailin 2024-10-29 18:14:35 +08:00
parent 4d567d98f4
commit fba57ff22d
1 changed files with 11 additions and 9 deletions

20
app.py
View File

@ -81,13 +81,23 @@ def load_indices_from_es(key: str, index: str, buf: Dict[str, Any]) -> Any:
return None return None
def set_customer_data(data):
global customer_data
# 确保数据为嵌套字典格式
if isinstance(data, list) and all(isinstance(customer, dict) for customer in data):
customer_data = data
else:
raise ValueError("Data must be a list of dictionaries.")
def reload_buf(ikey, ibuf): def reload_buf(ikey, ibuf):
ret = load_indices_from_es(ikey, 'customer', ibuf) ret = load_indices_from_es(ikey, 'customer', ibuf)
if not ret: if not ret:
exit("客服AI员工不能拥有数据库。") exit("客服AI员工不能拥有数据库。")
customer_data=buf[key]['customer database'] customer_data=buf[key]['customer database']
app.set_customer_data(customer_data) set_customer_data(customer_data)
def extract_index_structure(es_client, index_name): def extract_index_structure(es_client, index_name):
""" """
@ -288,14 +298,6 @@ def update_customers(index):
return redirect(url_for('view_customer', index=index)) return redirect(url_for('view_customer', index=index))
def set_customer_data(data):
global customer_data
# 确保数据为嵌套字典格式
if isinstance(data, list) and all(isinstance(customer, dict) for customer in data):
customer_data = data
else:
raise ValueError("Data must be a list of dictionaries.")
@app.route('/customer/top') @app.route('/customer/top')
def view_top_customer(): def view_top_customer():