diff --git a/app.py b/app.py index 9035c65..0acc39d 100644 --- a/app.py +++ b/app.py @@ -81,13 +81,23 @@ def load_indices_from_es(key: str, index: str, buf: Dict[str, Any]) -> Any: 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): 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) + set_customer_data(customer_data) def extract_index_structure(es_client, index_name): """ @@ -288,14 +298,6 @@ def update_customers(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') def view_top_customer():