Spaces:
Sleeping
Sleeping
Toan2004-ai commited on
Commit ·
d9a8842
1
Parent(s): b2b8dae
add readme config
Browse files
engine.py
CHANGED
|
@@ -165,21 +165,23 @@ def final_process_eme_technical_guided(input_text):
|
|
| 165 |
final_discounts.append(fallback_disc)
|
| 166 |
|
| 167 |
# INCENTIVES
|
| 168 |
-
model_incentives = parsed_json.get("incentives", [])
|
| 169 |
-
if not isinstance(model_incentives, list):
|
| 170 |
-
model_incentives = [model_incentives] if isinstance(model_incentives, dict) else []
|
| 171 |
-
|
| 172 |
final_incentives = []
|
| 173 |
|
| 174 |
-
|
| 175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
if not isinstance(item, dict): continue
|
| 177 |
-
desc = item.get("description") or item.get("displayName", "")
|
| 178 |
|
| 179 |
-
|
| 180 |
amount_match = re.search(r'\$(\d+(?:\.\d+)?)', desc)
|
| 181 |
amount = float(amount_match.group(1)) if amount_match else None
|
| 182 |
|
|
|
|
| 183 |
final_incentives.append({
|
| 184 |
"incentive_type": "WELCOME_CREDIT" if "Once Off" in desc else "OTHER",
|
| 185 |
"raw_category": item.get("category", "OTHER"),
|
|
@@ -193,7 +195,6 @@ def final_process_eme_technical_guided(input_text):
|
|
| 193 |
"trigger": "FIRST_BILL" if "Once Off" in desc else None
|
| 194 |
})
|
| 195 |
|
| 196 |
-
# 2. Luôn kiểm tra và bổ sung Solar FIT (không dùng "if not model_incentives")
|
| 197 |
if "solarFeedInTariff" in electricity_contract:
|
| 198 |
for s_fit in electricity_contract["solarFeedInTariff"]:
|
| 199 |
rates = s_fit.get("singleTariff", {}).get("rates", [])
|
|
|
|
| 165 |
final_discounts.append(fallback_disc)
|
| 166 |
|
| 167 |
# INCENTIVES
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
final_incentives = []
|
| 169 |
|
| 170 |
+
model_incentives = parsed_json.get("incentives", [])
|
| 171 |
+
if isinstance(model_incentives, list):
|
| 172 |
+
for item in model_incentives:
|
| 173 |
+
if isinstance(item, dict):
|
| 174 |
+
final_incentives.append(item)
|
| 175 |
+
|
| 176 |
+
contract_incentives = electricity_contract.get("incentives", [])
|
| 177 |
+
for item in contract_incentives:
|
| 178 |
if not isinstance(item, dict): continue
|
|
|
|
| 179 |
|
| 180 |
+
desc = item.get("description") or item.get("displayName", "")
|
| 181 |
amount_match = re.search(r'\$(\d+(?:\.\d+)?)', desc)
|
| 182 |
amount = float(amount_match.group(1)) if amount_match else None
|
| 183 |
|
| 184 |
+
# Thêm vào nếu chưa tồn tại (tránh trùng lặp)
|
| 185 |
final_incentives.append({
|
| 186 |
"incentive_type": "WELCOME_CREDIT" if "Once Off" in desc else "OTHER",
|
| 187 |
"raw_category": item.get("category", "OTHER"),
|
|
|
|
| 195 |
"trigger": "FIRST_BILL" if "Once Off" in desc else None
|
| 196 |
})
|
| 197 |
|
|
|
|
| 198 |
if "solarFeedInTariff" in electricity_contract:
|
| 199 |
for s_fit in electricity_contract["solarFeedInTariff"]:
|
| 200 |
rates = s_fit.get("singleTariff", {}).get("rates", [])
|