Spaces:
Sleeping
Sleeping
Toan2004-ai commited on
Commit ·
b2b8dae
1
Parent(s): d77520c
add readme config
Browse files
engine.py
CHANGED
|
@@ -171,16 +171,15 @@ def final_process_eme_technical_guided(input_text):
|
|
| 171 |
|
| 172 |
final_incentives = []
|
| 173 |
|
| 174 |
-
# 1.
|
| 175 |
for item in model_incentives:
|
| 176 |
if not isinstance(item, dict): continue
|
| 177 |
desc = item.get("description") or item.get("displayName", "")
|
| 178 |
|
| 179 |
-
# Trích xuất số tiền
|
| 180 |
amount_match = re.search(r'\$(\d+(?:\.\d+)?)', desc)
|
| 181 |
amount = float(amount_match.group(1)) if amount_match else None
|
| 182 |
|
| 183 |
-
# Mapping trực tiếp vào cấu trúc 21 trường
|
| 184 |
final_incentives.append({
|
| 185 |
"incentive_type": "WELCOME_CREDIT" if "Once Off" in desc else "OTHER",
|
| 186 |
"raw_category": item.get("category", "OTHER"),
|
|
@@ -194,7 +193,7 @@ def final_process_eme_technical_guided(input_text):
|
|
| 194 |
"trigger": "FIRST_BILL" if "Once Off" in desc else None
|
| 195 |
})
|
| 196 |
|
| 197 |
-
# 2.
|
| 198 |
if "solarFeedInTariff" in electricity_contract:
|
| 199 |
for s_fit in electricity_contract["solarFeedInTariff"]:
|
| 200 |
rates = s_fit.get("singleTariff", {}).get("rates", [])
|
|
|
|
| 171 |
|
| 172 |
final_incentives = []
|
| 173 |
|
| 174 |
+
# 1. Lấy tất cả Incentive từ model/parsed_json trước
|
| 175 |
for item in model_incentives:
|
| 176 |
if not isinstance(item, dict): continue
|
| 177 |
desc = item.get("description") or item.get("displayName", "")
|
| 178 |
|
| 179 |
+
# Trích xuất số tiền $125
|
| 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 |
"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", [])
|