Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
# APP_PATCH_NOTE_LIMIT_POSITIVE_MFDS = "Positive List ํ๋ํ์ธ + MFDS ์ ํ ํ์ฑ ๋ณด๊ฐ ์ ์ฉ๋ณธ"
|
| 2 |
# ============================================================
|
| 3 |
# reBom Regulatory Screening AI - Fast Grounded Fixed Version
|
|
@@ -37,6 +38,7 @@
|
|
| 37 |
import os, re, json, base64, hashlib, traceback, sqlite3, secrets, datetime, time, sys, subprocess, time
|
| 38 |
from pathlib import Path
|
| 39 |
from collections import defaultdict
|
|
|
|
| 40 |
import pandas as pd
|
| 41 |
import pdfplumber
|
| 42 |
import gradio as gr
|
|
@@ -74,9 +76,16 @@ NO_EVIDENCE_TEXT = "ํด๋น ์๋ฃ ๋ด ์ ํ ๊ทผ๊ฑฐ ์์"
|
|
| 74 |
NEED_CHECK_TEXT = "ํ์ธ ํ์"
|
| 75 |
LIMIT_CHECK_TEXT = "๋ฐฐํฉํ๋ ํ์ธ ํ์"
|
| 76 |
MFDS_LIVE_URL = "https://nedrug.mfds.go.kr/pbp/CCBDF01"
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
VECTOR_DB_CACHE = {}
|
| 81 |
EVAL_CACHE = {}
|
| 82 |
EMBEDDINGS_CACHE = None
|
|
@@ -188,6 +197,7 @@ def get_identity_raw(material, component):
|
|
| 188 |
def get_identity_text(material,component):
|
| 189 |
return normalize_text(get_identity_raw(material, component))
|
| 190 |
|
|
|
|
| 191 |
def normalized_tokens(text):
|
| 192 |
"""
|
| 193 |
์ฑ๋ถ๋ช
๋น๊ต์ฉ ํ ํฐํ.
|
|
@@ -196,6 +206,7 @@ def normalized_tokens(text):
|
|
| 196 |
text = safe_str(text).lower().replace("ฮฑ", "alpha").replace("ฮฒ", "beta")
|
| 197 |
return [t for t in re.split(r"[^a-z0-9๊ฐ-ํฃใ-ใใก-ใณไธ-้พฅ]+", text) if t]
|
| 198 |
|
|
|
|
| 199 |
def exact_ingredient_match(term, target_text):
|
| 200 |
"""
|
| 201 |
์ฑ๋ถ๋ช
/alias๊ฐ target_text ์์์ ๋
๋ฆฝ ํ ํฐ์ผ๋ก ์กด์ฌํ ๋๋ง True.
|
|
@@ -738,15 +749,15 @@ def registry_terms_for_component(material=None, component=None, extra_terms=None
|
|
| 738 |
material.get("Trade name(์๋ฌธ)", ""),
|
| 739 |
] + list(extra_terms or [])
|
| 740 |
|
| 741 |
-
|
| 742 |
|
| 743 |
hits = []
|
| 744 |
|
| 745 |
for entry in REGULATORY_SYNONYM_REGISTRY:
|
| 746 |
terms = entry.get("terms", [])
|
|
|
|
| 747 |
|
| 748 |
-
|
| 749 |
-
if any(exact_ingredient_match(t, identity_raw) for t in terms if safe_str(t)):
|
| 750 |
for t in terms:
|
| 751 |
if safe_str(t) and t not in hits:
|
| 752 |
hits.append(safe_str(t))
|
|
@@ -768,17 +779,17 @@ def registry_direct_regulation_fallback(country, material, component, target_id=
|
|
| 768 |
country_col = display_country(country)
|
| 769 |
representative = safe_str(component.get("INCI Name", "")) or safe_str(component.get("ํ๊ธ ์ฑ๋ถ๋ช
", "")) or registry_terms[0]
|
| 770 |
|
| 771 |
-
|
| 772 |
-
|
| 773 |
for t in registry_terms
|
| 774 |
if safe_str(t) and len(normalize_compact(t)) >= 3
|
| 775 |
]
|
| 776 |
|
| 777 |
for section in sections:
|
| 778 |
text = safe_str(section.get("text", ""))
|
|
|
|
| 779 |
|
| 780 |
-
|
| 781 |
-
if not any(exact_ingredient_match(t, text) for t in registry_terms):
|
| 782 |
continue
|
| 783 |
|
| 784 |
header = safe_str(section.get("header", ""))
|
|
@@ -791,7 +802,8 @@ def registry_direct_regulation_fallback(country, material, component, target_id=
|
|
| 791 |
seen = set()
|
| 792 |
|
| 793 |
for idx, line in enumerate(lines):
|
| 794 |
-
|
|
|
|
| 795 |
for j in range(max(0, idx - 5), min(len(lines), idx + 6)):
|
| 796 |
if j not in seen:
|
| 797 |
seen.add(j)
|
|
@@ -954,12 +966,13 @@ def find_chemical_variant_match_in_country_text(country, material, component, ta
|
|
| 954 |
|
| 955 |
for section in sections:
|
| 956 |
text = safe_str(section.get("text", ""))
|
|
|
|
| 957 |
header = safe_str(section.get("header", ""))
|
| 958 |
reg_type = infer_regulation_type_from_source_text(header + "\n" + text[:1500], country=country)
|
| 959 |
reg_kind = reg_type.get("type", "unknown")
|
| 960 |
reg_label = reg_type.get("label", "๊ท์ ์ ํ ๋ฏธ๋ถ๋ฅ")
|
| 961 |
|
| 962 |
-
hit_terms = [v for v in expanded if
|
| 963 |
if not hit_terms:
|
| 964 |
continue
|
| 965 |
|
|
@@ -968,7 +981,8 @@ def find_chemical_variant_match_in_country_text(country, material, component, ta
|
|
| 968 |
seen = set()
|
| 969 |
|
| 970 |
for idx, line in enumerate(lines):
|
| 971 |
-
|
|
|
|
| 972 |
for j in range(max(0, idx - 4), min(len(lines), idx + 5)):
|
| 973 |
if j not in seen:
|
| 974 |
seen.add(j)
|
|
@@ -1338,16 +1352,27 @@ def make_grouped_materials(df):
|
|
| 1338 |
return mats,{"cols":cols,"cleaned_df":clean,"ingredient_totals":defaultdict(float),"ingredient_amount_parts":defaultdict(list)}
|
| 1339 |
|
| 1340 |
# MFDS simplified: disabled-safe placeholder; keep UI compatibility
|
| 1341 |
-
def extract_terms_for_live_lookup(row_items):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1342 |
terms=[]
|
| 1343 |
for item in row_items:
|
| 1344 |
m=item["material"]; c=item["component"]
|
| 1345 |
-
if is_plain_fragrance_component(m,c) or is_always_pass_component(m,c):
|
|
|
|
| 1346 |
for v in [c.get("INCI Name",""),c.get("ํ๊ธ ์ฑ๋ถ๋ช
",""),c.get("CAS.No","")]:
|
| 1347 |
-
if safe_str(v):
|
|
|
|
|
|
|
| 1348 |
seen=[]
|
| 1349 |
for t in terms:
|
| 1350 |
-
if t not in seen:
|
|
|
|
|
|
|
|
|
|
| 1351 |
return seen
|
| 1352 |
|
| 1353 |
def mfds_visible_text(page):
|
|
@@ -1468,8 +1493,9 @@ def mfds_click_probable_result(page, term):
|
|
| 1468 |
except Exception:
|
| 1469 |
continue
|
| 1470 |
|
| 1471 |
-
|
| 1472 |
-
|
|
|
|
| 1473 |
row.click(timeout=3000)
|
| 1474 |
page.wait_for_timeout(1000)
|
| 1475 |
return True
|
|
@@ -1733,8 +1759,7 @@ def mfds_lookup_one_term_with_retry(page, term):
|
|
| 1733 |
return [], ""
|
| 1734 |
|
| 1735 |
# ๊ฒ์์ด๊ฐ ํ๋ฉด์ ์์ง๋ง ๊ท์ ํ๋๊ฐ ์์ผ๋ฉด ์ผ๋ฐ ์๋ฃ ์์ธ/๋ฌด๊ท์ ๊ฒฐ๊ณผ๋ก ํ๋จ
|
| 1736 |
-
|
| 1737 |
-
if exact_ingredient_match(term, body_text):
|
| 1738 |
return [], ""
|
| 1739 |
|
| 1740 |
if not clicked:
|
|
@@ -1812,12 +1837,12 @@ def mfds_try_install_chromium_once():
|
|
| 1812 |
return False, str(e)
|
| 1813 |
|
| 1814 |
|
| 1815 |
-
def mfds_live_lookup_terms(terms, max_terms=
|
| 1816 |
if not PLAYWRIGHT_AVAILABLE or sync_playwright is None:
|
| 1817 |
return pd.DataFrame(), "MFDS ์ค์๊ฐ ์กฐํ ์คํจ: playwright ํจํค์ง ๋ฏธ์ค์น"
|
| 1818 |
|
| 1819 |
terms = [safe_str(t) for t in terms if safe_str(t)]
|
| 1820 |
-
terms = terms[:int(max_terms)] if max_terms else terms[:
|
| 1821 |
|
| 1822 |
all_rows = []
|
| 1823 |
errors = []
|
|
@@ -2100,7 +2125,7 @@ def build_integrated_result(rd,country_cols):
|
|
| 2100 |
issues=[cc for cc in country_cols if is_country_result_issue(rd.get(cc,""))]
|
| 2101 |
return "PASS" if not issues else "์ฌ๊ฒํ ํ์: "+", ".join(issues)
|
| 2102 |
|
| 2103 |
-
def process(countries,file,product_name="",use_mfds_live=False,live_max_terms=
|
| 2104 |
"""
|
| 2105 |
์ ์ฑ๋ถ ์ ์ฒด ์คํฌ๋ฆฌ๋ ๊ณ ์ ๋ฒ์ .
|
| 2106 |
|
|
@@ -2108,7 +2133,7 @@ def process(countries,file,product_name="",use_mfds_live=False,live_max_terms=30
|
|
| 2108 |
- ์ ์ฒด ์คํฌ๋ฆฌ๋์์ GPT/LLM ํธ์ถ ์ ๊ฑฐ
|
| 2109 |
- ๊ตญ๊ฐ๋ณ ํ์ผ ์ง์ ๊ฒ์(COUNTRY_FILE_FAST) ์ฐ์
|
| 2110 |
- ์ ํ ๊ตญ๊ฐ๋ณ ์น์
์ธ๋ฑ์ค 1ํ ์๋ฐ์
|
| 2111 |
-
- ์์ฝ์ฒ ์ค์๊ฐ ์กฐํ
|
| 2112 |
"""
|
| 2113 |
global RAW_SEARCH_LOGS
|
| 2114 |
RAW_SEARCH_LOGS = []
|
|
@@ -2154,12 +2179,20 @@ def process(countries,file,product_name="",use_mfds_live=False,live_max_terms=30
|
|
| 2154 |
except Exception as e:
|
| 2155 |
index_messages.append(f"{display_country(country)}=index error: {e}")
|
| 2156 |
|
| 2157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2158 |
mfds_df = pd.DataFrame()
|
| 2159 |
mfds_msg = "์ฌ์ฉ ์ ํจ"
|
| 2160 |
|
|
|
|
|
|
|
|
|
|
| 2161 |
if use_mfds_live:
|
| 2162 |
-
|
|
|
|
| 2163 |
|
| 2164 |
for country in countries:
|
| 2165 |
col = display_country(country)
|
|
@@ -2694,38 +2727,37 @@ def get_country_section_index_cached(country):
|
|
| 2694 |
def find_matching_regulatory_sections_fast(country, ingredient_names, max_sections=30):
|
| 2695 |
"""
|
| 2696 |
๊ณ ์ ๋จ์ผ ๊ฒ์.
|
| 2697 |
-
|
| 2698 |
-
|
| 2699 |
-
์ค์:
|
| 2700 |
-
- normalize_compact ๊ธฐ๋ฐ ๋ถ๋ถ ๋ฌธ์์ด ๊ฒ์์ ์ฐ์ง ์๋๋ค.
|
| 2701 |
-
- Biotin ๊ฒ์ ์ MEA-Biotinate, Biotinate, Biotinyl- ๊ณ์ด์ Biotin์ผ๋ก ์ค์ธํ์ง ์๋๋ค.
|
| 2702 |
"""
|
| 2703 |
sections, status = get_country_section_index_cached(country)
|
| 2704 |
|
| 2705 |
-
|
| 2706 |
-
|
| 2707 |
for x in ingredient_names
|
| 2708 |
-
if safe_str(x) and len(normalize_compact(x)) >= 3
|
| 2709 |
]
|
| 2710 |
|
| 2711 |
-
if not
|
| 2712 |
return [], status
|
| 2713 |
|
| 2714 |
matches = []
|
| 2715 |
|
| 2716 |
for section in sections:
|
| 2717 |
-
|
| 2718 |
|
| 2719 |
-
if not any(
|
| 2720 |
continue
|
| 2721 |
|
|
|
|
| 2722 |
header = safe_str(section.get("header", ""))
|
| 2723 |
lines = [safe_str(x) for x in text.splitlines() if safe_str(x)]
|
| 2724 |
|
| 2725 |
hit_indices = []
|
| 2726 |
|
| 2727 |
for idx, line in enumerate(lines):
|
| 2728 |
-
|
|
|
|
|
|
|
| 2729 |
hit_indices.append(idx)
|
| 2730 |
|
| 2731 |
if len(hit_indices) >= 10:
|
|
@@ -2750,6 +2782,7 @@ def find_matching_regulatory_sections_fast(country, ingredient_names, max_sectio
|
|
| 2750 |
else:
|
| 2751 |
context = header + "\n" + text[:2000]
|
| 2752 |
|
|
|
|
| 2753 |
reg_type = infer_regulation_type_from_source_text(
|
| 2754 |
header + "\n" + text[:1500],
|
| 2755 |
country=country,
|
|
@@ -2766,62 +2799,65 @@ def find_matching_regulatory_sections_fast(country, ingredient_names, max_sectio
|
|
| 2766 |
|
| 2767 |
return matches, status
|
| 2768 |
|
|
|
|
| 2769 |
def find_matching_regulatory_sections(raw_text, ingredient_names, max_sections=20):
|
| 2770 |
"""
|
| 2771 |
-
๊ตฌ๋ฒ์ ํธํ์ฉ.
|
| 2772 |
"""
|
| 2773 |
-
|
| 2774 |
-
|
| 2775 |
for x in ingredient_names
|
| 2776 |
-
if safe_str(x) and len(normalize_compact(x)) >= 3
|
| 2777 |
]
|
| 2778 |
|
| 2779 |
-
if not
|
| 2780 |
return []
|
| 2781 |
|
| 2782 |
matches = []
|
| 2783 |
|
| 2784 |
for section in split_regulatory_text_into_sections(raw_text):
|
| 2785 |
text = section["text"]
|
|
|
|
| 2786 |
|
| 2787 |
-
if
|
| 2788 |
-
|
|
|
|
| 2789 |
|
| 2790 |
-
|
| 2791 |
-
|
| 2792 |
|
| 2793 |
-
|
| 2794 |
-
|
| 2795 |
-
hit_indices.append(idx)
|
| 2796 |
|
| 2797 |
-
|
| 2798 |
-
|
| 2799 |
|
| 2800 |
-
|
| 2801 |
-
|
| 2802 |
-
|
| 2803 |
|
| 2804 |
-
|
| 2805 |
-
|
| 2806 |
-
|
| 2807 |
|
| 2808 |
-
|
| 2809 |
-
|
| 2810 |
|
| 2811 |
-
|
| 2812 |
-
|
| 2813 |
|
| 2814 |
-
|
| 2815 |
-
|
| 2816 |
-
|
| 2817 |
-
|
| 2818 |
-
|
| 2819 |
|
| 2820 |
-
|
| 2821 |
-
|
| 2822 |
|
| 2823 |
return matches
|
| 2824 |
|
|
|
|
| 2825 |
def pick_best_regulatory_match(matches):
|
| 2826 |
"""
|
| 2827 |
์ฌ๋ฌ ํ์ผ์์ ๋์์ ๋งค์นญ๋ ๋ ์ฐ์ ์์๋ฅผ ์ ํ๋ค.
|
|
@@ -3136,11 +3172,8 @@ def evaluate_component_from_uploaded_source_records(country, material, component
|
|
| 3136 |
๊ตญ๊ฐ ํด๋ ํ์ผ๋ง ๋ณด๊ณ ํ์ .
|
| 3137 |
ํ์ผ record ์์ ํ์ฌ ์ฑ๋ถ๋ช
/๊ตญ๋ฌธ/CAS๊ฐ ์ง์ ์์ ๋๋ง ํ์ ํ๋ค.
|
| 3138 |
"""
|
| 3139 |
-
terms =
|
| 3140 |
-
|
| 3141 |
-
for t in source_match_terms_for_component(material, component)
|
| 3142 |
-
if safe_str(t) and len(normalize_compact(t)) >= 3 and not is_broad_lookup_term(t)
|
| 3143 |
-
]
|
| 3144 |
|
| 3145 |
representative = (
|
| 3146 |
safe_str(component.get("INCI Name", ""))
|
|
@@ -3149,17 +3182,16 @@ def evaluate_component_from_uploaded_source_records(country, material, component
|
|
| 3149 |
or "-"
|
| 3150 |
)
|
| 3151 |
|
| 3152 |
-
if not
|
| 3153 |
return None
|
| 3154 |
|
| 3155 |
records, status = build_country_source_record_index(country)
|
| 3156 |
hits = []
|
| 3157 |
|
| 3158 |
for rec in records:
|
| 3159 |
-
|
| 3160 |
|
| 3161 |
-
|
| 3162 |
-
if any(exact_ingredient_match(t, rec_text) for t in terms):
|
| 3163 |
hits.append(rec)
|
| 3164 |
|
| 3165 |
if not hits:
|
|
@@ -3589,7 +3621,7 @@ DEFAULT_ADMIN_EMAIL = os.getenv("ADMIN_EMAIL", "jin2li@rebom.kr").strip().lower(
|
|
| 3589 |
DEFAULT_ADMIN_PASSWORD = os.getenv("ADMIN_PASSWORD", "qwer0515!")
|
| 3590 |
|
| 3591 |
|
| 3592 |
-
def process_with_auth(user, countries, file, product_name="", use_mfds_live=False, live_max_terms=
|
| 3593 |
if not is_approved_user(user):
|
| 3594 |
return None, None, require_login_message()
|
| 3595 |
|
|
@@ -3623,7 +3655,7 @@ def auth_fn(username, password):
|
|
| 3623 |
# Gradio ๊ธฐ๋ณธ auth ์ฌ์ฉ ์ ๋ด๋ถ ๋ก๊ทธ์ธ ์ฒดํฌ ์ฐํ
|
| 3624 |
# ============================================================
|
| 3625 |
|
| 3626 |
-
def process_with_auth(user, countries, file, product_name="", use_mfds_live=False, live_max_terms=
|
| 3627 |
return process(countries, file, product_name, use_mfds_live, live_max_terms, live_headless)
|
| 3628 |
|
| 3629 |
|
|
@@ -3659,7 +3691,7 @@ def auth_fn(username, password):
|
|
| 3659 |
return USER_DB.get(username) == password
|
| 3660 |
|
| 3661 |
|
| 3662 |
-
def process_with_auth(user, countries, file, product_name="", use_mfds_live=False, live_max_terms=
|
| 3663 |
return process(countries, file, product_name, use_mfds_live, live_max_terms, live_headless)
|
| 3664 |
|
| 3665 |
|
|
@@ -3700,7 +3732,7 @@ def auth_fn(username, password):
|
|
| 3700 |
|
| 3701 |
|
| 3702 |
# Gradio ๊ธฐ๋ณธ auth๋ฅผ ํต๊ณผํ ์ฌ์ฉ์๋ ์ด๋ฏธ ์ธ์ฆ๋ ์ํ์ด๋ฏ๋ก ๋ด๋ถ ๋ก๊ทธ์ธ ์ฒดํฌ๋ฅผ ํ์ง ์๋๋ค.
|
| 3703 |
-
def process_with_auth(user, countries, file, product_name="", use_mfds_live=False, live_max_terms=
|
| 3704 |
return process(countries, file, product_name, use_mfds_live, live_max_terms, live_headless)
|
| 3705 |
|
| 3706 |
|
|
@@ -3736,7 +3768,7 @@ def auth_fn(username, password):
|
|
| 3736 |
return USER_DB.get(username) == password
|
| 3737 |
|
| 3738 |
|
| 3739 |
-
def process_with_auth(user, countries, file, product_name="", use_mfds_live=False, live_max_terms=
|
| 3740 |
return process(countries, file, product_name, use_mfds_live, live_max_terms, live_headless)
|
| 3741 |
|
| 3742 |
|
|
@@ -3772,7 +3804,7 @@ def auth_fn(username, password):
|
|
| 3772 |
return USER_DB.get(username) == password
|
| 3773 |
|
| 3774 |
|
| 3775 |
-
def process_with_auth(user, countries, file, product_name="", use_mfds_live=False, live_max_terms=
|
| 3776 |
return process(countries, file, product_name, use_mfds_live, live_max_terms, live_headless)
|
| 3777 |
|
| 3778 |
|
|
@@ -3820,7 +3852,7 @@ def auth_fn(username, password):
|
|
| 3820 |
return USER_DB.get(username) == password
|
| 3821 |
|
| 3822 |
|
| 3823 |
-
def process_with_auth(user, countries, file, product_name="", use_mfds_live=False, live_max_terms=
|
| 3824 |
return process(countries, file, product_name, use_mfds_live, live_max_terms, live_headless)
|
| 3825 |
|
| 3826 |
|
|
@@ -3932,8 +3964,8 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 3932 |
refresh=gr.Button("๐ ํด๋/๊ท์ ํ์ผ ์๋ก๊ณ ์นจ")
|
| 3933 |
product_name=gr.Textbox(label="์ ํ๋ช
/ PRODUCT NAME",placeholder="์: ๋ง๋ฐ์นดํฌ๋ฆผ")
|
| 3934 |
file=gr.File(label="์ ์ฑ๋ถ ํ์ผ ์
๋ก๋",file_types=[".xlsx",".xls",".pdf",".png",".jpg",".jpeg",".webp"])
|
| 3935 |
-
use_mfds_live=gr.Checkbox(label="์์ฝ์ฒ ์ฌ์ดํธ ์ค์๊ฐ ์กฐํ ์ฌ์ฉ",value=False)
|
| 3936 |
-
live_max_terms=gr.Number(label="์์ฝ์ฒ ์ค์๊ฐ ์กฐํ ์ต๋ ๊ฒ์์ด ์",value=5,precision=0)
|
| 3937 |
live_headless=gr.Checkbox(label="์์ฝ์ฒ ์กฐํ ๋ธ๋ผ์ฐ์ ์จ๊น ๋ชจ๋",value=True)
|
| 3938 |
btn=gr.Button("๐ ๋ถ์ ์์",variant="primary")
|
| 3939 |
df_out=gr.Dataframe(label="๋ฏธ๋ฆฌ๋ณด๊ธฐ - Formula Ingredients Statement",wrap=True,interactive=False)
|
|
@@ -3958,7 +3990,7 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 3958 |
with gr.Row():
|
| 3959 |
single_amount=gr.Textbox(label="ํจ๋ %(w/w) ์ ํ ์
๋ ฅ",placeholder="์: 7.2")
|
| 3960 |
single_function=gr.Textbox(label="FUNCTION ์ ํ ์
๋ ฅ",placeholder="์: Sunscreen Agent")
|
| 3961 |
-
single_use_mfds_live=gr.Checkbox(label="์์ฝ์ฒ ์ฌ์ดํธ ์ค์๊ฐ ์กฐํ ์ฌ์ฉ",value=False)
|
| 3962 |
single_btn=gr.Button("๐ ๋จ์ผ ์ฑ๋ถ ๊ฒ์ ์์",variant="primary")
|
| 3963 |
single_df_out=gr.Dataframe(label="๋จ์ผ ์ฑ๋ถ ๊ฒ์ ๊ฒฐ๊ณผ",wrap=True,interactive=False)
|
| 3964 |
single_msg_out=gr.Textbox(label="๊ฒ์ ์ํ / ๋ฉ์์ง",interactive=False,lines=8)
|
|
|
|
| 1 |
+
# APP_PATCH_NOTE_SPEED_MFDS_BATCH_OFF = "์ ์ฒด ์คํฌ๋ฆฌ๋ ์๋ ์๊ธํจ์น: MFDS ์ค์๊ฐ ์กฐํ ๋ฐฐ์น ๋นํ์ฑํ + ๋งค์นญ ์บ์"
|
| 2 |
# APP_PATCH_NOTE_LIMIT_POSITIVE_MFDS = "Positive List ํ๋ํ์ธ + MFDS ์ ํ ํ์ฑ ๋ณด๊ฐ ์ ์ฉ๋ณธ"
|
| 3 |
# ============================================================
|
| 4 |
# reBom Regulatory Screening AI - Fast Grounded Fixed Version
|
|
|
|
| 38 |
import os, re, json, base64, hashlib, traceback, sqlite3, secrets, datetime, time, sys, subprocess, time
|
| 39 |
from pathlib import Path
|
| 40 |
from collections import defaultdict
|
| 41 |
+
from functools import lru_cache
|
| 42 |
import pandas as pd
|
| 43 |
import pdfplumber
|
| 44 |
import gradio as gr
|
|
|
|
| 76 |
NEED_CHECK_TEXT = "ํ์ธ ํ์"
|
| 77 |
LIMIT_CHECK_TEXT = "๋ฐฐํฉํ๋ ํ์ธ ํ์"
|
| 78 |
MFDS_LIVE_URL = "https://nedrug.mfds.go.kr/pbp/CCBDF01"
|
| 79 |
+
# ์๋ ์๊ธํจ์น
|
| 80 |
+
# - ์ ์ฒด ์ ์ฑ๋ถ ์คํฌ๋ฆฌ๋์์๋ MFDS ์ฌ์ดํธ ์ค์๊ฐ ์กฐํ๋ฅผ ๊ธฐ๋ณธ์ ์ผ๋ก ์ฌ์ฉํ์ง ์๋๋ค.
|
| 81 |
+
# - ๋จ์ผ ์ฑ๋ถ ๊ฒ์์์๋ ํ์ ์ ์ฌ์ฉ ๊ฐ๋ฅํ๋ค.
|
| 82 |
+
ENABLE_MFDS_LIVE_FOR_BATCH = False
|
| 83 |
+
ENABLE_MFDS_LIVE_FOR_SINGLE = True
|
| 84 |
+
BATCH_MFDS_DISABLE_REASON = "์ ์ฒด ์ ์ฑ๋ถ ์คํฌ๋ฆฌ๋์์๋ ์๋ ๋ณดํธ๋ฅผ ์ํด MFDS ์ค์๊ฐ ์กฐํ๋ฅผ ์๋ ๋นํ์ฑํํจ"
|
| 85 |
+
|
| 86 |
+
MFDS_RETRY_COUNT = int(os.getenv("MFDS_RETRY_COUNT", "1"))
|
| 87 |
+
MFDS_RETRY_WAIT_SEC = float(os.getenv("MFDS_RETRY_WAIT_SEC", "0.5"))
|
| 88 |
+
MFDS_BETWEEN_TERMS_WAIT_SEC = float(os.getenv("MFDS_BETWEEN_TERMS_WAIT_SEC", "0.2"))
|
| 89 |
VECTOR_DB_CACHE = {}
|
| 90 |
EVAL_CACHE = {}
|
| 91 |
EMBEDDINGS_CACHE = None
|
|
|
|
| 197 |
def get_identity_text(material,component):
|
| 198 |
return normalize_text(get_identity_raw(material, component))
|
| 199 |
|
| 200 |
+
@lru_cache(maxsize=20000)
|
| 201 |
def normalized_tokens(text):
|
| 202 |
"""
|
| 203 |
์ฑ๋ถ๋ช
๋น๊ต์ฉ ํ ํฐํ.
|
|
|
|
| 206 |
text = safe_str(text).lower().replace("ฮฑ", "alpha").replace("ฮฒ", "beta")
|
| 207 |
return [t for t in re.split(r"[^a-z0-9๊ฐ-ํฃใ-ใใก-ใณไธ-้พฅ]+", text) if t]
|
| 208 |
|
| 209 |
+
@lru_cache(maxsize=50000)
|
| 210 |
def exact_ingredient_match(term, target_text):
|
| 211 |
"""
|
| 212 |
์ฑ๋ถ๋ช
/alias๊ฐ target_text ์์์ ๋
๋ฆฝ ํ ํฐ์ผ๋ก ์กด์ฌํ ๋๋ง True.
|
|
|
|
| 749 |
material.get("Trade name(์๋ฌธ)", ""),
|
| 750 |
] + list(extra_terms or [])
|
| 751 |
|
| 752 |
+
identity_norm = normalize_compact(" ".join(safe_str(x) for x in identity_values if safe_str(x)))
|
| 753 |
|
| 754 |
hits = []
|
| 755 |
|
| 756 |
for entry in REGULATORY_SYNONYM_REGISTRY:
|
| 757 |
terms = entry.get("terms", [])
|
| 758 |
+
term_norms = [normalize_compact(t) for t in terms if safe_str(t)]
|
| 759 |
|
| 760 |
+
if any(tn and tn in identity_norm for tn in term_norms):
|
|
|
|
| 761 |
for t in terms:
|
| 762 |
if safe_str(t) and t not in hits:
|
| 763 |
hits.append(safe_str(t))
|
|
|
|
| 779 |
country_col = display_country(country)
|
| 780 |
representative = safe_str(component.get("INCI Name", "")) or safe_str(component.get("ํ๊ธ ์ฑ๋ถ๋ช
", "")) or registry_terms[0]
|
| 781 |
|
| 782 |
+
registry_norms = [
|
| 783 |
+
normalize_compact(t)
|
| 784 |
for t in registry_terms
|
| 785 |
if safe_str(t) and len(normalize_compact(t)) >= 3
|
| 786 |
]
|
| 787 |
|
| 788 |
for section in sections:
|
| 789 |
text = safe_str(section.get("text", ""))
|
| 790 |
+
text_norm = normalize_compact(text)
|
| 791 |
|
| 792 |
+
if not any(tn in text_norm for tn in registry_norms):
|
|
|
|
| 793 |
continue
|
| 794 |
|
| 795 |
header = safe_str(section.get("header", ""))
|
|
|
|
| 802 |
seen = set()
|
| 803 |
|
| 804 |
for idx, line in enumerate(lines):
|
| 805 |
+
ln = normalize_compact(line)
|
| 806 |
+
if any(tn in ln for tn in registry_norms):
|
| 807 |
for j in range(max(0, idx - 5), min(len(lines), idx + 6)):
|
| 808 |
if j not in seen:
|
| 809 |
seen.add(j)
|
|
|
|
| 966 |
|
| 967 |
for section in sections:
|
| 968 |
text = safe_str(section.get("text", ""))
|
| 969 |
+
text_norm = normalize_compact(text)
|
| 970 |
header = safe_str(section.get("header", ""))
|
| 971 |
reg_type = infer_regulation_type_from_source_text(header + "\n" + text[:1500], country=country)
|
| 972 |
reg_kind = reg_type.get("type", "unknown")
|
| 973 |
reg_label = reg_type.get("label", "๊ท์ ์ ํ ๋ฏธ๋ถ๋ฅ")
|
| 974 |
|
| 975 |
+
hit_terms = [v for v in expanded if normalize_compact(v) in text_norm]
|
| 976 |
if not hit_terms:
|
| 977 |
continue
|
| 978 |
|
|
|
|
| 981 |
seen = set()
|
| 982 |
|
| 983 |
for idx, line in enumerate(lines):
|
| 984 |
+
line_norm = normalize_compact(line)
|
| 985 |
+
if any(normalize_compact(v) in line_norm for v in hit_terms):
|
| 986 |
for j in range(max(0, idx - 4), min(len(lines), idx + 5)):
|
| 987 |
if j not in seen:
|
| 988 |
seen.add(j)
|
|
|
|
| 1352 |
return mats,{"cols":cols,"cleaned_df":clean,"ingredient_totals":defaultdict(float),"ingredient_amount_parts":defaultdict(list)}
|
| 1353 |
|
| 1354 |
# MFDS simplified: disabled-safe placeholder; keep UI compatibility
|
| 1355 |
+
def extract_terms_for_live_lookup(row_items, max_terms=5):
|
| 1356 |
+
"""
|
| 1357 |
+
MFDS ์ค์๊ฐ ์กฐํ์ฉ ๊ฒ์์ด ์์ฑ.
|
| 1358 |
+
์ ์ฒด ์คํฌ๋ฆฌ๋์์๋ MFDS ์ค์๊ฐ ์กฐํ๋ฅผ ๋๋ ๊ฒ์ด ์์น์ด๋ฉฐ,
|
| 1359 |
+
ํน์ ์ผ์ ธ๋ ๊ฒ์์ด๊ฐ ํญ์ฆํ์ง ์๋๋ก ์ต๋ ๊ฐ์๋ฅผ ์ ํํ๋ค.
|
| 1360 |
+
"""
|
| 1361 |
terms=[]
|
| 1362 |
for item in row_items:
|
| 1363 |
m=item["material"]; c=item["component"]
|
| 1364 |
+
if is_plain_fragrance_component(m,c) or is_always_pass_component(m,c):
|
| 1365 |
+
continue
|
| 1366 |
for v in [c.get("INCI Name",""),c.get("ํ๊ธ ์ฑ๋ถ๋ช
",""),c.get("CAS.No","")]:
|
| 1367 |
+
if safe_str(v):
|
| 1368 |
+
terms.append(safe_str(v))
|
| 1369 |
+
break
|
| 1370 |
seen=[]
|
| 1371 |
for t in terms:
|
| 1372 |
+
if t not in seen:
|
| 1373 |
+
seen.append(t)
|
| 1374 |
+
if max_terms and len(seen) >= int(max_terms):
|
| 1375 |
+
break
|
| 1376 |
return seen
|
| 1377 |
|
| 1378 |
def mfds_visible_text(page):
|
|
|
|
| 1493 |
except Exception:
|
| 1494 |
continue
|
| 1495 |
|
| 1496 |
+
row_norm = normalize_compact(row_text)
|
| 1497 |
+
|
| 1498 |
+
if term_norm and term_norm in row_norm:
|
| 1499 |
row.click(timeout=3000)
|
| 1500 |
page.wait_for_timeout(1000)
|
| 1501 |
return True
|
|
|
|
| 1759 |
return [], ""
|
| 1760 |
|
| 1761 |
# ๊ฒ์์ด๊ฐ ํ๋ฉด์ ์์ง๋ง ๊ท์ ํ๋๊ฐ ์์ผ๋ฉด ์ผ๋ฐ ์๋ฃ ์์ธ/๋ฌด๊ท์ ๊ฒฐ๊ณผ๋ก ํ๋จ
|
| 1762 |
+
if term_norm and term_norm in body_norm:
|
|
|
|
| 1763 |
return [], ""
|
| 1764 |
|
| 1765 |
if not clicked:
|
|
|
|
| 1837 |
return False, str(e)
|
| 1838 |
|
| 1839 |
|
| 1840 |
+
def mfds_live_lookup_terms(terms, max_terms=5, headless=True):
|
| 1841 |
if not PLAYWRIGHT_AVAILABLE or sync_playwright is None:
|
| 1842 |
return pd.DataFrame(), "MFDS ์ค์๊ฐ ์กฐํ ์คํจ: playwright ํจํค์ง ๋ฏธ์ค์น"
|
| 1843 |
|
| 1844 |
terms = [safe_str(t) for t in terms if safe_str(t)]
|
| 1845 |
+
terms = terms[:min(int(max_terms), 5)] if max_terms else terms[:5]
|
| 1846 |
|
| 1847 |
all_rows = []
|
| 1848 |
errors = []
|
|
|
|
| 2125 |
issues=[cc for cc in country_cols if is_country_result_issue(rd.get(cc,""))]
|
| 2126 |
return "PASS" if not issues else "์ฌ๊ฒํ ํ์: "+", ".join(issues)
|
| 2127 |
|
| 2128 |
+
def process(countries,file,product_name="",use_mfds_live=False,live_max_terms=5,live_headless=True):
|
| 2129 |
"""
|
| 2130 |
์ ์ฑ๋ถ ์ ์ฒด ์คํฌ๋ฆฌ๋ ๊ณ ์ ๋ฒ์ .
|
| 2131 |
|
|
|
|
| 2133 |
- ์ ์ฒด ์คํฌ๋ฆฌ๋์์ GPT/LLM ํธ์ถ ์ ๊ฑฐ
|
| 2134 |
- ๊ตญ๊ฐ๋ณ ํ์ผ ์ง์ ๊ฒ์(COUNTRY_FILE_FAST) ์ฐ์
|
| 2135 |
- ์ ํ ๊ตญ๊ฐ๋ณ ์น์
์ธ๋ฑ์ค 1ํ ์๋ฐ์
|
| 2136 |
+
- ์ ์ฒด ์คํฌ๋ฆฌ๋์์๋ ์๋ ๋ณดํธ๋ฅผ ์ํด ์์ฝ์ฒ ์ค์๊ฐ ์กฐํ ์๋ ๋นํ์ฑํ
|
| 2137 |
"""
|
| 2138 |
global RAW_SEARCH_LOGS
|
| 2139 |
RAW_SEARCH_LOGS = []
|
|
|
|
| 2179 |
except Exception as e:
|
| 2180 |
index_messages.append(f"{display_country(country)}=index error: {e}")
|
| 2181 |
|
| 2182 |
+
# ์ ์ฒด ์ ์ฑ๋ถ ์คํฌ๋ฆฌ๋์์๋ MFDS ์ฌ์ดํธ ์ค์๊ฐ ์กฐํ๋ฅผ ๋๋ฆฌ์ง ์๋๋ค.
|
| 2183 |
+
# ์ฑ๋ถ ์๊ฐ ๋ง์ ๋ Playwright ์ ์/๋๊ธฐ ์๊ฐ์ด ์ฑ๋ถ ์๋งํผ ๋์ ๋์ด 1์๊ฐ ์ด์ ๊ฑธ๋ฆด ์ ์๊ธฐ ๋๋ฌธ.
|
| 2184 |
+
batch_live_requested = bool(use_mfds_live)
|
| 2185 |
+
use_mfds_live = False if not ENABLE_MFDS_LIVE_FOR_BATCH else bool(use_mfds_live)
|
| 2186 |
+
terms = []
|
| 2187 |
mfds_df = pd.DataFrame()
|
| 2188 |
mfds_msg = "์ฌ์ฉ ์ ํจ"
|
| 2189 |
|
| 2190 |
+
if batch_live_requested and not ENABLE_MFDS_LIVE_FOR_BATCH:
|
| 2191 |
+
mfds_msg = BATCH_MFDS_DISABLE_REASON
|
| 2192 |
+
|
| 2193 |
if use_mfds_live:
|
| 2194 |
+
terms = extract_terms_for_live_lookup(row_items, max_terms=min(int(live_max_terms or 5), 5))
|
| 2195 |
+
mfds_df, mfds_msg = mfds_live_lookup_terms(terms, min(int(live_max_terms or 5), 5), True)
|
| 2196 |
|
| 2197 |
for country in countries:
|
| 2198 |
col = display_country(country)
|
|
|
|
| 2727 |
def find_matching_regulatory_sections_fast(country, ingredient_names, max_sections=30):
|
| 2728 |
"""
|
| 2729 |
๊ณ ์ ๋จ์ผ ๊ฒ์.
|
| 2730 |
+
get_country_section_index_cached()๊ฐ ๋ง๋ ์น์
์ธ๋ฑ์ค์์ ์ฑ๋ถ๋ช
/INCI/CAS๋ฅผ ์ง์ ๊ฒ์ํ๋ค.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2731 |
"""
|
| 2732 |
sections, status = get_country_section_index_cached(country)
|
| 2733 |
|
| 2734 |
+
names_norm = [
|
| 2735 |
+
normalize_compact(x)
|
| 2736 |
for x in ingredient_names
|
| 2737 |
+
if safe_str(x) and len(normalize_compact(x)) >= 3
|
| 2738 |
]
|
| 2739 |
|
| 2740 |
+
if not names_norm:
|
| 2741 |
return [], status
|
| 2742 |
|
| 2743 |
matches = []
|
| 2744 |
|
| 2745 |
for section in sections:
|
| 2746 |
+
text_norm = section.get("text_norm", "")
|
| 2747 |
|
| 2748 |
+
if not any(name in text_norm for name in names_norm):
|
| 2749 |
continue
|
| 2750 |
|
| 2751 |
+
text = safe_str(section.get("text", ""))
|
| 2752 |
header = safe_str(section.get("header", ""))
|
| 2753 |
lines = [safe_str(x) for x in text.splitlines() if safe_str(x)]
|
| 2754 |
|
| 2755 |
hit_indices = []
|
| 2756 |
|
| 2757 |
for idx, line in enumerate(lines):
|
| 2758 |
+
line_norm = normalize_compact(line)
|
| 2759 |
+
|
| 2760 |
+
if any(name in line_norm for name in names_norm):
|
| 2761 |
hit_indices.append(idx)
|
| 2762 |
|
| 2763 |
if len(hit_indices) >= 10:
|
|
|
|
| 2782 |
else:
|
| 2783 |
context = header + "\n" + text[:2000]
|
| 2784 |
|
| 2785 |
+
# ๋์คํฌ ์บ์๊ฐ ์ค๋๋ label์ ๊ฐ์ง ์ ์์ผ๋ฏ๋ก header ๊ธฐ์ค์ผ๋ก ํ๋ฒ ๋ ๋ณด์
|
| 2786 |
reg_type = infer_regulation_type_from_source_text(
|
| 2787 |
header + "\n" + text[:1500],
|
| 2788 |
country=country,
|
|
|
|
| 2799 |
|
| 2800 |
return matches, status
|
| 2801 |
|
| 2802 |
+
|
| 2803 |
def find_matching_regulatory_sections(raw_text, ingredient_names, max_sections=20):
|
| 2804 |
"""
|
| 2805 |
+
๊ตฌ๋ฒ์ ํธํ์ฉ. ์ ๊ท ๋จ์ผ ๊ฒ์์ find_matching_regulatory_sections_fast()๋ฅผ ์ฌ์ฉํ๋ค.
|
| 2806 |
"""
|
| 2807 |
+
names_norm = [
|
| 2808 |
+
normalize_compact(x)
|
| 2809 |
for x in ingredient_names
|
| 2810 |
+
if safe_str(x) and len(normalize_compact(x)) >= 3
|
| 2811 |
]
|
| 2812 |
|
| 2813 |
+
if not names_norm:
|
| 2814 |
return []
|
| 2815 |
|
| 2816 |
matches = []
|
| 2817 |
|
| 2818 |
for section in split_regulatory_text_into_sections(raw_text):
|
| 2819 |
text = section["text"]
|
| 2820 |
+
text_norm = normalize_compact(text)
|
| 2821 |
|
| 2822 |
+
if any(name in text_norm for name in names_norm):
|
| 2823 |
+
lines = [safe_str(x) for x in text.splitlines() if safe_str(x)]
|
| 2824 |
+
hit_indices = []
|
| 2825 |
|
| 2826 |
+
for idx, line in enumerate(lines):
|
| 2827 |
+
line_norm = normalize_compact(line)
|
| 2828 |
|
| 2829 |
+
if any(name in line_norm for name in names_norm):
|
| 2830 |
+
hit_indices.append(idx)
|
|
|
|
| 2831 |
|
| 2832 |
+
context_lines = []
|
| 2833 |
+
seen = set()
|
| 2834 |
|
| 2835 |
+
for idx in hit_indices[:8]:
|
| 2836 |
+
start = max(0, idx - 4)
|
| 2837 |
+
end = min(len(lines), idx + 5)
|
| 2838 |
|
| 2839 |
+
for j in range(start, end):
|
| 2840 |
+
if j in seen:
|
| 2841 |
+
continue
|
| 2842 |
|
| 2843 |
+
seen.add(j)
|
| 2844 |
+
context_lines.append(lines[j])
|
| 2845 |
|
| 2846 |
+
context = section["header"] + "\n" + "\n".join(context_lines)
|
| 2847 |
+
reg_type = infer_regulation_type_from_source_text(section["header"] + "\n" + text[:1200], country="")
|
| 2848 |
|
| 2849 |
+
matches.append({
|
| 2850 |
+
"header": section["header"],
|
| 2851 |
+
"context": context[:8000],
|
| 2852 |
+
"regulation_type": reg_type,
|
| 2853 |
+
})
|
| 2854 |
|
| 2855 |
+
if len(matches) >= max_sections:
|
| 2856 |
+
break
|
| 2857 |
|
| 2858 |
return matches
|
| 2859 |
|
| 2860 |
+
|
| 2861 |
def pick_best_regulatory_match(matches):
|
| 2862 |
"""
|
| 2863 |
์ฌ๋ฌ ํ์ผ์์ ๋์์ ๋งค์นญ๋ ๋ ์ฐ์ ์์๋ฅผ ์ ํ๋ค.
|
|
|
|
| 3172 |
๊ตญ๊ฐ ํด๋ ํ์ผ๋ง ๋ณด๊ณ ํ์ .
|
| 3173 |
ํ์ผ record ์์ ํ์ฌ ์ฑ๋ถ๋ช
/๊ตญ๋ฌธ/CAS๊ฐ ์ง์ ์์ ๋๋ง ํ์ ํ๋ค.
|
| 3174 |
"""
|
| 3175 |
+
terms = source_match_terms_for_component(material, component)
|
| 3176 |
+
term_norms = [normalize_compact(t) for t in terms if len(normalize_compact(t)) >= 3]
|
|
|
|
|
|
|
|
|
|
| 3177 |
|
| 3178 |
representative = (
|
| 3179 |
safe_str(component.get("INCI Name", ""))
|
|
|
|
| 3182 |
or "-"
|
| 3183 |
)
|
| 3184 |
|
| 3185 |
+
if not term_norms:
|
| 3186 |
return None
|
| 3187 |
|
| 3188 |
records, status = build_country_source_record_index(country)
|
| 3189 |
hits = []
|
| 3190 |
|
| 3191 |
for rec in records:
|
| 3192 |
+
rec_norm = rec.get("text_norm", "")
|
| 3193 |
|
| 3194 |
+
if any(tn in rec_norm for tn in term_norms):
|
|
|
|
| 3195 |
hits.append(rec)
|
| 3196 |
|
| 3197 |
if not hits:
|
|
|
|
| 3621 |
DEFAULT_ADMIN_PASSWORD = os.getenv("ADMIN_PASSWORD", "qwer0515!")
|
| 3622 |
|
| 3623 |
|
| 3624 |
+
def process_with_auth(user, countries, file, product_name="", use_mfds_live=False, live_max_terms=5, live_headless=True):
|
| 3625 |
if not is_approved_user(user):
|
| 3626 |
return None, None, require_login_message()
|
| 3627 |
|
|
|
|
| 3655 |
# Gradio ๊ธฐ๋ณธ auth ์ฌ์ฉ ์ ๋ด๋ถ ๋ก๊ทธ์ธ ์ฒดํฌ ์ฐํ
|
| 3656 |
# ============================================================
|
| 3657 |
|
| 3658 |
+
def process_with_auth(user, countries, file, product_name="", use_mfds_live=False, live_max_terms=5, live_headless=True):
|
| 3659 |
return process(countries, file, product_name, use_mfds_live, live_max_terms, live_headless)
|
| 3660 |
|
| 3661 |
|
|
|
|
| 3691 |
return USER_DB.get(username) == password
|
| 3692 |
|
| 3693 |
|
| 3694 |
+
def process_with_auth(user, countries, file, product_name="", use_mfds_live=False, live_max_terms=5, live_headless=True):
|
| 3695 |
return process(countries, file, product_name, use_mfds_live, live_max_terms, live_headless)
|
| 3696 |
|
| 3697 |
|
|
|
|
| 3732 |
|
| 3733 |
|
| 3734 |
# Gradio ๊ธฐ๋ณธ auth๋ฅผ ํต๊ณผํ ์ฌ์ฉ์๋ ์ด๋ฏธ ์ธ์ฆ๋ ์ํ์ด๋ฏ๋ก ๋ด๋ถ ๋ก๊ทธ์ธ ์ฒดํฌ๋ฅผ ํ์ง ์๋๋ค.
|
| 3735 |
+
def process_with_auth(user, countries, file, product_name="", use_mfds_live=False, live_max_terms=5, live_headless=True):
|
| 3736 |
return process(countries, file, product_name, use_mfds_live, live_max_terms, live_headless)
|
| 3737 |
|
| 3738 |
|
|
|
|
| 3768 |
return USER_DB.get(username) == password
|
| 3769 |
|
| 3770 |
|
| 3771 |
+
def process_with_auth(user, countries, file, product_name="", use_mfds_live=False, live_max_terms=5, live_headless=True):
|
| 3772 |
return process(countries, file, product_name, use_mfds_live, live_max_terms, live_headless)
|
| 3773 |
|
| 3774 |
|
|
|
|
| 3804 |
return USER_DB.get(username) == password
|
| 3805 |
|
| 3806 |
|
| 3807 |
+
def process_with_auth(user, countries, file, product_name="", use_mfds_live=False, live_max_terms=5, live_headless=True):
|
| 3808 |
return process(countries, file, product_name, use_mfds_live, live_max_terms, live_headless)
|
| 3809 |
|
| 3810 |
|
|
|
|
| 3852 |
return USER_DB.get(username) == password
|
| 3853 |
|
| 3854 |
|
| 3855 |
+
def process_with_auth(user, countries, file, product_name="", use_mfds_live=False, live_max_terms=5, live_headless=True):
|
| 3856 |
return process(countries, file, product_name, use_mfds_live, live_max_terms, live_headless)
|
| 3857 |
|
| 3858 |
|
|
|
|
| 3964 |
refresh=gr.Button("๐ ํด๋/๊ท์ ํ์ผ ์๋ก๊ณ ์นจ")
|
| 3965 |
product_name=gr.Textbox(label="์ ํ๋ช
/ PRODUCT NAME",placeholder="์: ๋ง๋ฐ์นดํฌ๋ฆผ")
|
| 3966 |
file=gr.File(label="์ ์ฑ๋ถ ํ์ผ ์
๋ก๋",file_types=[".xlsx",".xls",".pdf",".png",".jpg",".jpeg",".webp"])
|
| 3967 |
+
use_mfds_live=gr.Checkbox(label="์์ฝ์ฒ ์ฌ์ดํธ ์ค์๊ฐ ์กฐํ ์ฌ์ฉ(์ ์ฒด ์คํฌ๋ฆฌ๋์์๋ ์๋ ๋นํ์ฑํ)",value=False)
|
| 3968 |
+
live_max_terms=gr.Number(label="์์ฝ์ฒ ์ค์๊ฐ ์กฐํ ์ต๋ ๊ฒ์์ด ์(์ต๋ 5)",value=5,precision=0)
|
| 3969 |
live_headless=gr.Checkbox(label="์์ฝ์ฒ ์กฐํ ๋ธ๋ผ์ฐ์ ์จ๊น ๋ชจ๋",value=True)
|
| 3970 |
btn=gr.Button("๐ ๋ถ์ ์์",variant="primary")
|
| 3971 |
df_out=gr.Dataframe(label="๋ฏธ๋ฆฌ๋ณด๊ธฐ - Formula Ingredients Statement",wrap=True,interactive=False)
|
|
|
|
| 3990 |
with gr.Row():
|
| 3991 |
single_amount=gr.Textbox(label="ํจ๋ %(w/w) ์ ํ ์
๋ ฅ",placeholder="์: 7.2")
|
| 3992 |
single_function=gr.Textbox(label="FUNCTION ์ ํ ์
๋ ฅ",placeholder="์: Sunscreen Agent")
|
| 3993 |
+
single_use_mfds_live=gr.Checkbox(label="์์ฝ์ฒ ์ฌ์ดํธ ์ค์๊ฐ ์กฐํ ์ฌ์ฉ(์ ์ฒด ์คํฌ๋ฆฌ๋์์๋ ์๋ ๋นํ์ฑํ)",value=False)
|
| 3994 |
single_btn=gr.Button("๐ ๋จ์ผ ์ฑ๋ถ ๊ฒ์ ์์",variant="primary")
|
| 3995 |
single_df_out=gr.Dataframe(label="๋จ์ผ ์ฑ๋ถ ๊ฒ์ ๊ฒฐ๊ณผ",wrap=True,interactive=False)
|
| 3996 |
single_msg_out=gr.Textbox(label="๊ฒ์ ์ํ / ๋ฉ์์ง",interactive=False,lines=8)
|