jin2li commited on
Commit
2a90dae
ยท
verified ยท
1 Parent(s): 19a8ef5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +206 -25
app.py CHANGED
@@ -60,6 +60,7 @@ BASE_DIR = Path.cwd().resolve()
60
  OUTPUT_DIR = BASE_DIR / "outputs"
61
  OUTPUT_DIR.mkdir(exist_ok=True)
62
  FAISS_CACHE_DIR = ".faiss_cache"
 
63
  NO_EVIDENCE_TEXT = "ํ•ด๋‹น ์ž๋ฃŒ ๋‚ด ์ œํ•œ ๊ทผ๊ฑฐ ์—†์Œ"
64
  NEED_CHECK_TEXT = "ํ™•์ธ ํ•„์š”"
65
  LIMIT_CHECK_TEXT = "๋ฐฐํ•ฉํ•œ๋„ ํ™•์ธ ํ•„์š”"
@@ -68,6 +69,7 @@ EVAL_CACHE = {}
68
  EMBEDDINGS_CACHE = None
69
  RAW_SEARCH_LOGS = []
70
  REG_TEXT_CACHE = {}
 
71
 
72
  COUNTRY_ORDER = ["ASEAN","CALIFORNIA","CHINA","EU (FUTURE)","EU","FDA","JAPAN","KOREA","MEXICO","SEPHORA","TARGET","UK","ULTA"]
73
  COUNTRY_DISPLAY = {"EU":"EU","์œ ๋Ÿฝ":"EU","FDA":"FDA","๋ฏธ๊ตญ":"FDA","USA":"FDA","US":"FDA","KOREA":"Korea","ํ•œ๊ตญ":"Korea","KR":"Korea","JAPAN":"์ผ๋ณธ","์ผ๋ณธ":"์ผ๋ณธ","JP":"์ผ๋ณธ","CHINA":"์ค‘๊ตญ","์ค‘๊ตญ":"์ค‘๊ตญ","CN":"์ค‘๊ตญ","ASEAN":"ASEAN","์•„์„ธ์•ˆ":"ASEAN","UK":"UK","์˜๊ตญ":"UK","EU (FUTURE)":"EU (FUTURE)","EU_FUTURE":"EU (FUTURE)","CALIFORNIA":"CALIFORNIA","MEXICO":"MEXICO","SEPHORA":"SEPHORA","TARGET":"TARGET","ULTA":"ULTA"}
@@ -971,6 +973,201 @@ def split_regulatory_text_into_sections(raw_text):
971
  return sections
972
 
973
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
974
  def find_matching_regulatory_sections(raw_text, ingredient_names, max_sections=20):
975
  """
976
  ๊ตญ๊ฐ€๋ณ„ ํŒŒ์ผ ์›๋ฌธ์—์„œ ํ˜„์žฌ ์„ฑ๋ถ„๋ช…/INCI/CAS๊ฐ€ ์ง์ ‘ ํฌํ•จ๋œ ์„น์…˜์„ ์ฐพ๋Š”๋‹ค.
@@ -1131,27 +1328,8 @@ def evaluate_component_from_country_files_only(country, material, component, tar
1131
  )
1132
  return result
1133
 
1134
- raw_text, cache_status = get_country_regulatory_text_cached(country)
1135
-
1136
- if not raw_text:
1137
- result = {
1138
- "๋Œ€ํ‘œ INCI": representative,
1139
- "๊ฒฐ๊ณผ": NO_EVIDENCE_TEXT,
1140
- "ํ‘œ์‹œ๋ฌธ๊ตฌ": "Pass",
1141
- "๋น„๊ณ ": cache_status or "ํ•ด๋‹น ๊ตญ๊ฐ€/์ฑ„๋„ ๊ทœ์ œ ํŒŒ์ผ ์—†์Œ",
1142
- }
1143
- log_search_context(
1144
- target_id,
1145
- country,
1146
- component,
1147
- result["๊ฒฐ๊ณผ"],
1148
- "COUNTRY_FILE_DIRECT_NO_DB",
1149
- result["๋น„๊ณ "],
1150
- )
1151
- return result
1152
-
1153
- matches = find_matching_regulatory_sections(
1154
- raw_text=raw_text,
1155
  ingredient_names=[inci_name, korean_name, cas_no],
1156
  max_sections=30,
1157
  )
@@ -1168,7 +1346,7 @@ def evaluate_component_from_country_files_only(country, material, component, tar
1168
  country,
1169
  component,
1170
  result["๊ฒฐ๊ณผ"],
1171
- "COUNTRY_FILE_DIRECT_NO_HIT",
1172
  f"cache_status={cache_status}",
1173
  )
1174
  return result
@@ -1602,7 +1780,7 @@ def process_single_ingredient(
1602
 
1603
  if file_result is not None:
1604
  final_result = file_result
1605
- source = "COUNTRY_FILE_ONLY"
1606
 
1607
  if final_result is None:
1608
  local_result = evaluate_local_rules(
@@ -1667,7 +1845,7 @@ def process_single_ingredient(
1667
  f"- ์„ ํƒ ๊ตญ๊ฐ€ ์ˆ˜: {len(countries)}๊ฐœ\n"
1668
  f"- MFDS ์ƒํƒœ: {mfds_live_msg}\n"
1669
  f"- MFDS ์กฐํšŒ ๋Œ€์ƒ: {', '.join(terms) if terms else '์—†์Œ'}\n"
1670
- "- ํŒ์ • ๋ฐฉ์‹: GPT ํŒ์ • ์—†์Œ, Annex/Negative/Positive List ๊ธฐ๋ฐ˜ ์ง์ ‘๊ฒ€์ƒ‰ + ์‹์•ฝ์ฒ˜ ์ฒดํฌ ON ์‹œ ์‹ค์‹œ๊ฐ„ ๊ฒฐ๊ณผ ์‚ฌ์šฉ\n"
1671
  "- ๊ธˆ์ง€ ์„ฑ๋ถ„: ํ•จ๋Ÿ‰ ์œ ๋ฌด์™€ ๋ฌด๊ด€ํ•˜๊ฒŒ ๋ฐฐํ•ฉ๊ธˆ์ง€ ์šฐ์„  ํ‘œ์‹œ\n"
1672
  )
1673
  return result_df, msg
@@ -1702,15 +1880,18 @@ with gr.Blocks(css=custom_css) as demo:
1702
  with gr.Tab("๐Ÿ”Ž ๋‹จ์ผ ์„ฑ๋ถ„ ๊ฒ€์ƒ‰"):
1703
  single_country=gr.CheckboxGroup(choices=get_country_folders(),value=[],label="๐ŸŒ ๊ฒ€์ƒ‰ ๊ตญ๊ฐ€ / ์ฑ„๋„ ์„ ํƒ",elem_id="single_country_checks")
1704
  single_refresh=gr.Button("๐Ÿ”„ ๊ตญ๊ฐ€/๊ทœ์ œํŒŒ์ผ ์ƒˆ๋กœ๊ณ ์นจ")
 
1705
  single_query=gr.Textbox(label="๊ฒ€์ƒ‰์–ด",placeholder="์˜ˆ: ํ˜ธ๋ชจ์‚ด๋ ˆ์ดํŠธ / Homosalate / 118-56-9 / ํŠธ๋ผ๋„ฅ์‚ฌ๋ฏน์• ์”จ๋“œ")
1706
  with gr.Row():
1707
  single_amount=gr.Textbox(label="ํ•จ๋Ÿ‰ %(w/w) ์„ ํƒ ์ž…๋ ฅ",placeholder="์˜ˆ: 7.2")
1708
  single_function=gr.Textbox(label="FUNCTION ์„ ํƒ ์ž…๋ ฅ",placeholder="์˜ˆ: Sunscreen Agent")
 
1709
  single_btn=gr.Button("๐Ÿ”Ž ๋‹จ์ผ ์„ฑ๋ถ„ ๊ฒ€์ƒ‰ ์‹œ์ž‘",variant="primary")
1710
  single_df_out=gr.Dataframe(label="๋‹จ์ผ ์„ฑ๋ถ„ ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ",wrap=True,interactive=False)
1711
  single_msg_out=gr.Textbox(label="๊ฒ€์ƒ‰ ์ƒํƒœ / ๋ฉ”์‹œ์ง€",interactive=False,lines=8)
 
1712
  single_refresh.click(refresh_country_choices_and_clear_cache,inputs=single_country,outputs=single_country)
1713
- single_btn.click(process_single_ingredient,inputs=[single_country,single_query,single_amount,single_function],outputs=[single_df_out,single_msg_out])
1714
 
1715
  USER_DB={"jin2li@rebom.kr":"qwer0515!","jkh@rebom.kr":"rebom123!","member2":"1111"}
1716
  def auth_fn(username,password): return str(username).strip() in USER_DB and USER_DB[str(username).strip()]==str(password).strip()
 
60
  OUTPUT_DIR = BASE_DIR / "outputs"
61
  OUTPUT_DIR.mkdir(exist_ok=True)
62
  FAISS_CACHE_DIR = ".faiss_cache"
63
+ REG_INDEX_CACHE_DIR = ".reg_index_cache"
64
  NO_EVIDENCE_TEXT = "ํ•ด๋‹น ์ž๋ฃŒ ๋‚ด ์ œํ•œ ๊ทผ๊ฑฐ ์—†์Œ"
65
  NEED_CHECK_TEXT = "ํ™•์ธ ํ•„์š”"
66
  LIMIT_CHECK_TEXT = "๋ฐฐํ•ฉํ•œ๋„ ํ™•์ธ ํ•„์š”"
 
69
  EMBEDDINGS_CACHE = None
70
  RAW_SEARCH_LOGS = []
71
  REG_TEXT_CACHE = {}
72
+ REG_SECTION_INDEX_CACHE = {}
73
 
74
  COUNTRY_ORDER = ["ASEAN","CALIFORNIA","CHINA","EU (FUTURE)","EU","FDA","JAPAN","KOREA","MEXICO","SEPHORA","TARGET","UK","ULTA"]
75
  COUNTRY_DISPLAY = {"EU":"EU","์œ ๋Ÿฝ":"EU","FDA":"FDA","๋ฏธ๊ตญ":"FDA","USA":"FDA","US":"FDA","KOREA":"Korea","ํ•œ๊ตญ":"Korea","KR":"Korea","JAPAN":"์ผ๋ณธ","์ผ๋ณธ":"์ผ๋ณธ","JP":"์ผ๋ณธ","CHINA":"์ค‘๊ตญ","์ค‘๊ตญ":"์ค‘๊ตญ","CN":"์ค‘๊ตญ","ASEAN":"ASEAN","์•„์„ธ์•ˆ":"ASEAN","UK":"UK","์˜๊ตญ":"UK","EU (FUTURE)":"EU (FUTURE)","EU_FUTURE":"EU (FUTURE)","CALIFORNIA":"CALIFORNIA","MEXICO":"MEXICO","SEPHORA":"SEPHORA","TARGET":"TARGET","ULTA":"ULTA"}
 
973
  return sections
974
 
975
 
976
+
977
+ def get_country_section_index_cached(country):
978
+ """
979
+ ๋‹จ์ผ ์„ฑ๋ถ„ ๊ฒ€์ƒ‰ ๊ณ ์†ํ™”์šฉ ์„น์…˜ ์ธ๋ฑ์Šค.
980
+ ๊ตญ๊ฐ€๋ณ„ ํŒŒ์ผ์„ ๋งค๋ฒˆ PDF/Excel ์ „์ฒด ์ฝ๊ธฐํ•˜์ง€ ์•Š๊ณ ,
981
+ ํŒŒ์ผ/์‹œํŠธ/ํŽ˜์ด์ง€ ์„น์…˜ ๋‹จ์œ„๋กœ ์บ์‹œํ•œ๋‹ค.
982
+
983
+ ์ตœ์ดˆ 1ํšŒ:
984
+ - ํ•ด๋‹น ๊ตญ๊ฐ€ ํŒŒ์ผ์„ ์ฝ์–ด ์„น์…˜ ์ธ๋ฑ์Šค ์ƒ์„ฑ
985
+ - .reg_index_cache ํด๋”์— json ์ €์žฅ
986
+
987
+ ์ดํ›„:
988
+ - ํŒŒ์ผ ๋ณ€๊ฒฝ์ด ์—†์œผ๋ฉด json ์บ์‹œ๋ฅผ ๋ฐ”๋กœ ๋กœ๋“œ
989
+ - ๋‹จ์ผ ์„ฑ๋ถ„ ๊ฒ€์ƒ‰์€ ๋ฌธ์ž์—ด contains๋งŒ ์ˆ˜ํ–‰ํ•˜๋ฏ€๋กœ ๋งค์šฐ ๋น ๋ฆ„
990
+ """
991
+ global REG_SECTION_INDEX_CACHE
992
+
993
+ folder = resolve_country_folder(country)
994
+
995
+ if not folder or not os.path.isdir(folder):
996
+ return [], "ํ•ด๋‹น ๊ตญ๊ฐ€/์ฑ„๋„ ํด๋” ์—†์Œ"
997
+
998
+ files = get_regulatory_file_list(folder)
999
+
1000
+ if not files:
1001
+ return [], "ํ•ด๋‹น ๊ตญ๊ฐ€/์ฑ„๋„ ๊ทœ์ œ ํŒŒ์ผ ์—†์Œ"
1002
+
1003
+ signature = tuple((f["relative_path"], f["size"], f["mtime_ns"]) for f in files)
1004
+ sig_hash = stable_hash(signature)
1005
+ memory_key = f"{folder}|{sig_hash}"
1006
+
1007
+ if memory_key in REG_SECTION_INDEX_CACHE:
1008
+ return REG_SECTION_INDEX_CACHE[memory_key], "MEMORY_CACHE"
1009
+
1010
+ os.makedirs(REG_INDEX_CACHE_DIR, exist_ok=True)
1011
+ cache_file = os.path.join(
1012
+ REG_INDEX_CACHE_DIR,
1013
+ f"{safe_filename(folder)}_{sig_hash[:16]}_sections.json",
1014
+ )
1015
+
1016
+ if os.path.exists(cache_file):
1017
+ try:
1018
+ with open(cache_file, "r", encoding="utf-8") as f:
1019
+ payload = json.load(f)
1020
+
1021
+ if payload.get("signature_hash") == sig_hash:
1022
+ sections = payload.get("sections", [])
1023
+ REG_SECTION_INDEX_CACHE[memory_key] = sections
1024
+ return sections, "DISK_CACHE"
1025
+ except Exception as e:
1026
+ print(f"์„น์…˜ ์ธ๋ฑ์Šค ์บ์‹œ ๋กœ๋“œ ์‹คํŒจ: {cache_file} / {e}")
1027
+
1028
+ sections = []
1029
+
1030
+ for item in files:
1031
+ try:
1032
+ raw = extract_text_from_regulatory_file(item)
1033
+
1034
+ if not raw:
1035
+ continue
1036
+
1037
+ rel = item.get("relative_path", "")
1038
+ ext = item.get("ext", "")
1039
+
1040
+ # ํŒŒ์ผ๋ช…/๊ฒฝ๋กœ ์ž์ฒด๋กœ Annex II/III/IV/V/VI๋ฅผ ํŒ๋‹จํ•  ์ˆ˜ ์žˆ๋„๋ก header์— ๋ช…ํ™•ํžˆ ๋„ฃ๋Š”๋‹ค.
1041
+ source_header = f"[๊ตญ๊ฐ€/์ฑ„๋„: {folder}] [์ถœ์ฒ˜ํŒŒ์ผ: {rel}] [ํ™•์žฅ์ž: {ext}]"
1042
+ reg_type = infer_regulation_type_from_source_text(source_header + "\n" + raw[:1500])
1043
+
1044
+ # ๋„ˆ๋ฌด ํฐ ํŒŒ์ผ๋„ ์ค„ ๋‹จ์œ„ ๊ฒ€์ƒ‰๋งŒ ํ•˜๋„๋ก ์„น์…˜ 1๊ฐœ๋กœ ์ €์žฅํ•œ๋‹ค.
1045
+ # ๊ฒ€์ƒ‰ ์‹œ matching line ์ฃผ๋ณ€๋งŒ ์ž˜๋ผ ์“ฐ๋ฏ€๋กœ ์ „์ฒด ํ…์ŠคํŠธ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ์–ด๋„ ๋น ๋ฅด๋‹ค.
1046
+ sections.append({
1047
+ "folder": folder,
1048
+ "source_file": rel,
1049
+ "header": source_header,
1050
+ "regulation_type": reg_type,
1051
+ "text": raw,
1052
+ "text_norm": normalize_compact(raw),
1053
+ })
1054
+
1055
+ except Exception as e:
1056
+ print(f"์„น์…˜ ์ธ๋ฑ์Šค ์ƒ์„ฑ ์‹คํŒจ: {item.get('path', '')} / {e}")
1057
+
1058
+ REG_SECTION_INDEX_CACHE[memory_key] = sections
1059
+
1060
+ try:
1061
+ with open(cache_file, "w", encoding="utf-8") as f:
1062
+ json.dump(
1063
+ {
1064
+ "country": str(country),
1065
+ "folder": folder,
1066
+ "signature_hash": sig_hash,
1067
+ "sections": sections,
1068
+ },
1069
+ f,
1070
+ ensure_ascii=False,
1071
+ )
1072
+ except Exception as e:
1073
+ print(f"์„น์…˜ ์ธ๋ฑ์Šค ์บ์‹œ ์ €์žฅ ์‹คํŒจ: {cache_file} / {e}")
1074
+
1075
+ return sections, "BUILT_INDEX"
1076
+
1077
+
1078
+ def find_matching_regulatory_sections_fast(country, ingredient_names, max_sections=30):
1079
+ """
1080
+ ๊ณ ์† ๋‹จ์ผ ๊ฒ€์ƒ‰.
1081
+ get_country_section_index_cached()๊ฐ€ ๋งŒ๋“  ์„น์…˜ ์ธ๋ฑ์Šค์—์„œ ์„ฑ๋ถ„๋ช…/INCI/CAS๋ฅผ ์ง์ ‘ ๊ฒ€์ƒ‰ํ•œ๋‹ค.
1082
+ PDF/Excel ์žฌ์ฝ๊ธฐ์™€ FAISS/์ž„๋ฒ ๋”ฉ์„ ํ•˜์ง€ ์•Š๋Š”๋‹ค.
1083
+ """
1084
+ sections, status = get_country_section_index_cached(country)
1085
+
1086
+ names_norm = [
1087
+ normalize_compact(x)
1088
+ for x in ingredient_names
1089
+ if safe_str(x) and len(normalize_compact(x)) >= 3
1090
+ ]
1091
+
1092
+ if not names_norm:
1093
+ return [], status
1094
+
1095
+ matches = []
1096
+
1097
+ for section in sections:
1098
+ text_norm = section.get("text_norm", "")
1099
+
1100
+ if not any(name in text_norm for name in names_norm):
1101
+ continue
1102
+
1103
+ text = safe_str(section.get("text", ""))
1104
+ header = safe_str(section.get("header", ""))
1105
+ lines = [safe_str(x) for x in text.splitlines() if safe_str(x)]
1106
+
1107
+ hit_indices = []
1108
+
1109
+ for idx, line in enumerate(lines):
1110
+ line_norm = normalize_compact(line)
1111
+
1112
+ if any(name in line_norm for name in names_norm):
1113
+ hit_indices.append(idx)
1114
+
1115
+ if len(hit_indices) >= 10:
1116
+ break
1117
+
1118
+ context_lines = []
1119
+ seen = set()
1120
+
1121
+ for idx in hit_indices:
1122
+ start = max(0, idx - 4)
1123
+ end = min(len(lines), idx + 5)
1124
+
1125
+ for j in range(start, end):
1126
+ if j in seen:
1127
+ continue
1128
+
1129
+ seen.add(j)
1130
+ context_lines.append(lines[j])
1131
+
1132
+ if context_lines:
1133
+ context = header + "\n" + "\n".join(context_lines)
1134
+ else:
1135
+ context = header + "\n" + text[:2000]
1136
+
1137
+ matches.append({
1138
+ "header": header,
1139
+ "context": context[:8000],
1140
+ "regulation_type": section.get("regulation_type", {
1141
+ "type": "unknown",
1142
+ "label": "๊ทœ์ œ ์œ ํ˜• ๋ฏธ๋ถ„๋ฅ˜",
1143
+ "display": NEED_CHECK_TEXT,
1144
+ }),
1145
+ })
1146
+
1147
+ if len(matches) >= max_sections:
1148
+ break
1149
+
1150
+ return matches, status
1151
+
1152
+
1153
+ def warmup_country_indexes(countries):
1154
+ """
1155
+ ์„ ํƒ ๊ตญ๊ฐ€์˜ ๋‹จ์ผ ๊ฒ€์ƒ‰ ์ธ๋ฑ์Šค๋ฅผ ๋ฏธ๋ฆฌ ๋งŒ๋“ ๋‹ค.
1156
+ ์‚ฌ์šฉ์ž๊ฐ€ '๊ตญ๊ฐ€/๊ทœ์ œํŒŒ์ผ ์ƒˆ๋กœ๊ณ ์นจ'์„ ๋ˆŒ๋ €์„ ๋•Œ ์บ์‹œ๊นŒ์ง€ ๊ฐ™์ด ์ค€๋น„ํ•  ์ˆ˜ ์žˆ๋‹ค.
1157
+ """
1158
+ messages = []
1159
+
1160
+ for country in countries or []:
1161
+ try:
1162
+ sections, status = get_country_section_index_cached(country)
1163
+ messages.append(f"{display_country(country)}: {status}, sections={len(sections)}")
1164
+ except Exception as e:
1165
+ messages.append(f"{display_country(country)}: ์ธ๋ฑ์Šค ์ƒ์„ฑ ์‹คํŒจ - {e}")
1166
+
1167
+ return "\n".join(messages) if messages else "์„ ํƒ๋œ ๊ตญ๊ฐ€ ์—†์Œ"
1168
+
1169
+
1170
+
1171
  def find_matching_regulatory_sections(raw_text, ingredient_names, max_sections=20):
1172
  """
1173
  ๊ตญ๊ฐ€๋ณ„ ํŒŒ์ผ ์›๋ฌธ์—์„œ ํ˜„์žฌ ์„ฑ๋ถ„๋ช…/INCI/CAS๊ฐ€ ์ง์ ‘ ํฌํ•จ๋œ ์„น์…˜์„ ์ฐพ๋Š”๋‹ค.
 
1328
  )
1329
  return result
1330
 
1331
+ matches, cache_status = find_matching_regulatory_sections_fast(
1332
+ country=country,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1333
  ingredient_names=[inci_name, korean_name, cas_no],
1334
  max_sections=30,
1335
  )
 
1346
  country,
1347
  component,
1348
  result["๊ฒฐ๊ณผ"],
1349
+ "COUNTRY_FILE_FAST_NO_HIT",
1350
  f"cache_status={cache_status}",
1351
  )
1352
  return result
 
1780
 
1781
  if file_result is not None:
1782
  final_result = file_result
1783
+ source = "COUNTRY_FILE_FAST"
1784
 
1785
  if final_result is None:
1786
  local_result = evaluate_local_rules(
 
1845
  f"- ์„ ํƒ ๊ตญ๊ฐ€ ์ˆ˜: {len(countries)}๊ฐœ\n"
1846
  f"- MFDS ์ƒํƒœ: {mfds_live_msg}\n"
1847
  f"- MFDS ์กฐํšŒ ๋Œ€์ƒ: {', '.join(terms) if terms else '์—†์Œ'}\n"
1848
+ "- ํŒ์ • ๋ฐฉ์‹: GPT ํŒ์ • ์—†์Œ, Annex/Negative/Positive List ๊ธฐ๋ฐ˜ ๊ณ ์† ์ธ๋ฑ์Šค ๊ฒ€์ƒ‰ + ์‹์•ฝ์ฒ˜ ์ฒดํฌ ON ์‹œ ์‹ค์‹œ๊ฐ„ ๊ฒฐ๊ณผ ์‚ฌ์šฉ\n"
1849
  "- ๊ธˆ์ง€ ์„ฑ๋ถ„: ํ•จ๋Ÿ‰ ์œ ๋ฌด์™€ ๋ฌด๊ด€ํ•˜๊ฒŒ ๋ฐฐํ•ฉ๊ธˆ์ง€ ์šฐ์„  ํ‘œ์‹œ\n"
1850
  )
1851
  return result_df, msg
 
1880
  with gr.Tab("๐Ÿ”Ž ๋‹จ์ผ ์„ฑ๋ถ„ ๊ฒ€์ƒ‰"):
1881
  single_country=gr.CheckboxGroup(choices=get_country_folders(),value=[],label="๐ŸŒ ๊ฒ€์ƒ‰ ๊ตญ๊ฐ€ / ์ฑ„๋„ ์„ ํƒ",elem_id="single_country_checks")
1882
  single_refresh=gr.Button("๐Ÿ”„ ๊ตญ๊ฐ€/๊ทœ์ œํŒŒ์ผ ์ƒˆ๋กœ๊ณ ์นจ")
1883
+ single_warmup_btn=gr.Button("โšก ๋‹จ์ผ๊ฒ€์ƒ‰ ์บ์‹œ ๋ฏธ๋ฆฌ ๋งŒ๋“ค๊ธฐ")
1884
  single_query=gr.Textbox(label="๊ฒ€์ƒ‰์–ด",placeholder="์˜ˆ: ํ˜ธ๋ชจ์‚ด๋ ˆ์ดํŠธ / Homosalate / 118-56-9 / ํŠธ๋ผ๋„ฅ์‚ฌ๋ฏน์• ์”จ๋“œ")
1885
  with gr.Row():
1886
  single_amount=gr.Textbox(label="ํ•จ๋Ÿ‰ %(w/w) ์„ ํƒ ์ž…๋ ฅ",placeholder="์˜ˆ: 7.2")
1887
  single_function=gr.Textbox(label="FUNCTION ์„ ํƒ ์ž…๋ ฅ",placeholder="์˜ˆ: Sunscreen Agent")
1888
+ single_use_mfds_live=gr.Checkbox(label="์‹์•ฝ์ฒ˜ ์‚ฌ์ดํŠธ ์‹ค์‹œ๊ฐ„ ์กฐํšŒ ์‚ฌ์šฉ",value=False)
1889
  single_btn=gr.Button("๐Ÿ”Ž ๋‹จ์ผ ์„ฑ๋ถ„ ๊ฒ€์ƒ‰ ์‹œ์ž‘",variant="primary")
1890
  single_df_out=gr.Dataframe(label="๋‹จ์ผ ์„ฑ๋ถ„ ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ",wrap=True,interactive=False)
1891
  single_msg_out=gr.Textbox(label="๊ฒ€์ƒ‰ ์ƒํƒœ / ๋ฉ”์‹œ์ง€",interactive=False,lines=8)
1892
+ single_warmup_btn.click(warmup_country_indexes,inputs=single_country,outputs=single_msg_out)
1893
  single_refresh.click(refresh_country_choices_and_clear_cache,inputs=single_country,outputs=single_country)
1894
+ single_btn.click(process_single_ingredient,inputs=[single_country,single_query,single_amount,single_function,single_use_mfds_live],outputs=[single_df_out,single_msg_out])
1895
 
1896
  USER_DB={"jin2li@rebom.kr":"qwer0515!","jkh@rebom.kr":"rebom123!","member2":"1111"}
1897
  def auth_fn(username,password): return str(username).strip() in USER_DB and USER_DB[str(username).strip()]==str(password).strip()