Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -706,7 +706,6 @@ def extract_terms_for_mfds_live(row_items):
|
|
| 706 |
value = safe_str(value)
|
| 707 |
if value and len(normalize_compact(value)) >= 3:
|
| 708 |
terms.append(value)
|
| 709 |
-
|
| 710 |
seen = set()
|
| 711 |
unique = []
|
| 712 |
for term in terms:
|
|
@@ -723,7 +722,7 @@ def mfds_live_visible_text(page):
|
|
| 723 |
soup = BeautifulSoup(html, "html.parser")
|
| 724 |
for tag in soup(["script", "style", "nav", "footer", "header"]):
|
| 725 |
tag.decompose()
|
| 726 |
-
return soup.get_text(separator="
|
| 727 |
except Exception:
|
| 728 |
try:
|
| 729 |
return page.locator("body").inner_text(timeout=5000)
|
|
@@ -758,9 +757,144 @@ def mfds_live_click_search(page):
|
|
| 758 |
return True
|
| 759 |
except Exception:
|
| 760 |
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 761 |
|
| 762 |
-
|
| 763 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 764 |
|
| 765 |
|
| 766 |
# ============================================================
|
|
@@ -1920,7 +2054,7 @@ def style_output_workbook(path):
|
|
| 1920 |
# 12. ๋ฉ์ธ ์ฒ๋ฆฌ
|
| 1921 |
# ============================================================
|
| 1922 |
|
| 1923 |
-
def process(countries, file, product_name="",
|
| 1924 |
global RAW_SEARCH_LOGS
|
| 1925 |
RAW_SEARCH_LOGS = []
|
| 1926 |
|
|
@@ -1937,7 +2071,8 @@ def process(countries, file, product_name="", use_mfds_db=True):
|
|
| 1937 |
|
| 1938 |
ingredient_totals = meta["ingredient_totals"]
|
| 1939 |
ingredient_amount_parts = meta["ingredient_amount_parts"]
|
| 1940 |
-
mfds_df =
|
|
|
|
| 1941 |
|
| 1942 |
llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)
|
| 1943 |
|
|
@@ -1959,6 +2094,18 @@ def process(countries, file, product_name="", use_mfds_db=True):
|
|
| 1959 |
}
|
| 1960 |
row_items.append({"target_id": target_id, "material": material, "component": comp, "row_data": row_data, "notes": []})
|
| 1961 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1962 |
for country in countries:
|
| 1963 |
col_name = display_country(country)
|
| 1964 |
gpt_targets = []
|
|
@@ -1974,7 +2121,7 @@ def process(countries, file, product_name="", use_mfds_db=True):
|
|
| 1974 |
continue
|
| 1975 |
|
| 1976 |
mfds_result = None
|
| 1977 |
-
if
|
| 1978 |
mfds_result = evaluate_mfds_detail_rule(country, item["material"], item["component"], mfds_df)
|
| 1979 |
|
| 1980 |
if mfds_result is not None:
|
|
@@ -2035,12 +2182,13 @@ def process(countries, file, product_name="", use_mfds_db=True):
|
|
| 2035 |
f"- ์ ์ฑ๋ถ ํ ์: {len(formula_df)}๊ฐ\n"
|
| 2036 |
f"- In formula ํฉ๊ณ: {format_amount(formula_total)}%\n"
|
| 2037 |
f"- ์ฌ๊ฒํ ํ์ ์ฑ๋ถ: {issue_count}๊ฐ\n"
|
| 2038 |
-
f"- MFDS
|
| 2039 |
"- ๊ฒฐ๊ณผ ํ์ผ์ 3๊ฐ ์ํธ๋ก ์ ์ฅํ์ต๋๋ค.\n"
|
| 2040 |
" 1) Formula Ingredients Statement: ์๋ณธ ์์ ์ ์ฑ๋ถํ + ๊ตญ๊ฐ๋ณ ์งง์ ํ์ \n"
|
| 2041 |
" 2) Regulatory Screening Summary: ๋ฌธ์ ์๋ ์ฑ๋ถ๋ง ๊ตญ๊ฐ๋ณ ์์ฝ\n"
|
| 2042 |
" 3) Raw Search Log: ๋ก์ปฌ ๊ท์น/MFDS/GPT ๊ฒ์ ๊ทผ๊ฑฐ ๋ก๊ทธ\n"
|
| 2043 |
-
"- ํ์ ์ฐ์ ์์: ๋ก์ปฌ ๊ณ ์ ๊ท์น โ MFDS
|
|
|
|
| 2044 |
"- GPT ํธ์ถ ์ ๊ฒ์ ์๋ฌธ์ ์ค์ ์ฑ๋ถ๋ช
์ด ์์ผ๋ฉด GPT๋ฅผ ํธ์ถํ์ง ์๊ณ 'ํด๋น ์๋ฃ ๋ด ์ ํ ๊ทผ๊ฑฐ ์์'์ผ๋ก ์ฒ๋ฆฌํฉ๋๋ค.\n"
|
| 2045 |
"- MergedCell column_letter ์ค๋ฅ ์์ ์๋ฃ ๋ฒ์ ์
๋๋ค.\n"
|
| 2046 |
"- public share link๊ฐ ์์ฑ๋๋๋ก share=True๋ก ์คํํฉ๋๋ค."
|
|
@@ -2079,7 +2227,18 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 2079 |
|
| 2080 |
file = gr.File(label="์ ์ฑ๋ถ ์์
์
๋ก๋", file_types=[".xlsx"])
|
| 2081 |
|
| 2082 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2083 |
|
| 2084 |
btn = gr.Button("๐ ๋ถ์ ์์", variant="primary")
|
| 2085 |
|
|
@@ -2096,44 +2255,10 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 2096 |
print(f"์๋ ๊ตญ๊ฐ ๋ชฉ๋ก ๊ฐฑ์ ํ์ด๋จธ ๋นํ์ฑํ: {e}")
|
| 2097 |
|
| 2098 |
file.change(fn=preview_excel, inputs=file, outputs=df_out)
|
| 2099 |
-
btn.click(process, inputs=[country, file, product_name,
|
| 2100 |
-
|
| 2101 |
-
with gr.Tab("๐ฐ๐ท MFDS ์์ธ DB ๊ด๋ฆฌ"):
|
| 2102 |
-
gr.Markdown(
|
| 2103 |
-
"""
|
| 2104 |
-
### MFDS ์์ธ DB ์ฌ์ฉ ๋ฐฉ์
|
| 2105 |
-
|
| 2106 |
-
์์ฝํ์์ ๋๋ผ ์ฌ์ดํธ๋ ์๋ ์ ์์ด ๋งํ๊ฑฐ๋ ๋์ ํ์ด์ง ๋ฌธ์ ๋ก ๋ถ์์ ํ ์ ์์ด์,
|
| 2107 |
-
์ด ์ฑ์์๋ **์ฌ์ดํธ ์ค์๊ฐ ํฌ๋กค๋ง ๋์ ์์ธ์ ๋ณด ์์
DB ๋ฐฉ์**์ผ๋ก ์ฐ๋ํฉ๋๋ค.
|
| 2108 |
-
|
| 2109 |
-
์์
ํ์ผ๋ช
์ ์๋์ผ๋ก ์๋ ์ด๋ฆ์ผ๋ก ์ ์ฅ๋ฉ๋๋ค.
|
| 2110 |
-
|
| 2111 |
-
`MFDS_๊ตญ๊ฐ๋ณ_๊ธ์ง์ ํ_์์ธ.xlsx`
|
| 2112 |
-
|
| 2113 |
-
ํ์ ์ปฌ๋ผ:
|
| 2114 |
-
- ์๋ฃ๋ช
|
| 2115 |
-
- INCI
|
| 2116 |
-
- CAS.No
|
| 2117 |
-
- ๊ตฌ๋ถ
|
| 2118 |
-
- ๊ตญ๊ฐ
|
| 2119 |
-
- ๊ท์ ๋ด์ฉ
|
| 2120 |
-
- ํ๋
|
| 2121 |
-
- ์กฐ๊ฑด
|
| 2122 |
-
- ์ถ์ฒ
|
| 2123 |
-
- ์์ธ์๋ฌธ
|
| 2124 |
-
"""
|
| 2125 |
-
)
|
| 2126 |
-
|
| 2127 |
-
template_btn = gr.Button("๐ MFDS ์์ธ DB ํ
ํ๋ฆฟ ๋ค์ด๋ก๋")
|
| 2128 |
-
template_file = gr.File(label="ํ
ํ๋ฆฟ ๋ค์ด๋ก๋")
|
| 2129 |
-
template_msg = gr.Textbox(label="ํ
ํ๋ฆฟ ์ํ", interactive=False, lines=3)
|
| 2130 |
-
template_btn.click(download_mfds_template, inputs=[], outputs=[template_file, template_msg])
|
| 2131 |
|
| 2132 |
-
|
| 2133 |
-
|
| 2134 |
-
mfds_db_file = gr.File(label="ํ์ฌ MFDS ์์ธ DB ๋ค์ด๋ก๋")
|
| 2135 |
-
mfds_db_msg = gr.Textbox(label="MFDS DB ์ํ", lines=8, interactive=False)
|
| 2136 |
-
mfds_save_btn.click(upload_mfds_db, inputs=mfds_upload, outputs=[mfds_db_file, mfds_db_msg])
|
| 2137 |
|
| 2138 |
|
| 2139 |
# ============================================================
|
|
|
|
| 706 |
value = safe_str(value)
|
| 707 |
if value and len(normalize_compact(value)) >= 3:
|
| 708 |
terms.append(value)
|
|
|
|
| 709 |
seen = set()
|
| 710 |
unique = []
|
| 711 |
for term in terms:
|
|
|
|
| 722 |
soup = BeautifulSoup(html, "html.parser")
|
| 723 |
for tag in soup(["script", "style", "nav", "footer", "header"]):
|
| 724 |
tag.decompose()
|
| 725 |
+
return soup.get_text(separator=" ")
|
| 726 |
except Exception:
|
| 727 |
try:
|
| 728 |
return page.locator("body").inner_text(timeout=5000)
|
|
|
|
| 757 |
return True
|
| 758 |
except Exception:
|
| 759 |
pass
|
| 760 |
+
for selector in ["button", "input[type='submit']", "a"]:
|
| 761 |
+
try:
|
| 762 |
+
loc = page.locator(selector)
|
| 763 |
+
for i in range(min(loc.count(), 20)):
|
| 764 |
+
item = loc.nth(i)
|
| 765 |
+
try:
|
| 766 |
+
text = item.inner_text(timeout=500) if selector != "input[type='submit']" else "๊ฒ์"
|
| 767 |
+
if "๊ฒ์" in text or selector == "input[type='submit']":
|
| 768 |
+
item.click(timeout=3000)
|
| 769 |
+
return True
|
| 770 |
+
except Exception:
|
| 771 |
+
continue
|
| 772 |
+
except Exception:
|
| 773 |
+
continue
|
| 774 |
+
return False
|
| 775 |
|
| 776 |
+
|
| 777 |
+
def mfds_live_click_result_row(page, term):
|
| 778 |
+
term_norm = normalize_compact(term)
|
| 779 |
+
for selector in ["table tbody tr", "tbody tr", "tr"]:
|
| 780 |
+
try:
|
| 781 |
+
rows = page.locator(selector)
|
| 782 |
+
for i in range(min(rows.count(), 30)):
|
| 783 |
+
row = rows.nth(i)
|
| 784 |
+
try:
|
| 785 |
+
row_text = row.inner_text(timeout=1000)
|
| 786 |
+
except Exception:
|
| 787 |
+
continue
|
| 788 |
+
if term_norm and term_norm in normalize_compact(row_text):
|
| 789 |
+
row.click(timeout=3000)
|
| 790 |
+
page.wait_for_timeout(1500)
|
| 791 |
+
return True
|
| 792 |
+
except Exception:
|
| 793 |
+
continue
|
| 794 |
+
try:
|
| 795 |
+
loc = page.get_by_text(term, exact=False)
|
| 796 |
+
if loc.count() > 0:
|
| 797 |
+
loc.first.click(timeout=3000)
|
| 798 |
+
page.wait_for_timeout(1500)
|
| 799 |
+
return True
|
| 800 |
+
except Exception:
|
| 801 |
+
pass
|
| 802 |
+
return False
|
| 803 |
+
|
| 804 |
+
|
| 805 |
+
def parse_mfds_live_text(term, text):
|
| 806 |
+
clean = " ".join(safe_str(text).split())
|
| 807 |
+
if not clean:
|
| 808 |
+
return []
|
| 809 |
+
lower_clean = clean.lower()
|
| 810 |
+
country_patterns = {
|
| 811 |
+
"EU": ["eu", "์ ๋ฝ", "์ ๋ฝ์ฐํฉ", "european union", "europe"],
|
| 812 |
+
"๋ฏธ๊ตญ": ["๋ฏธ๊ตญ", "usa", "fda", "united states"],
|
| 813 |
+
"์ผ๋ณธ": ["์ผ๋ณธ", "japan"],
|
| 814 |
+
"์ค๊ตญ": ["์ค๊ตญ", "china"],
|
| 815 |
+
"ASEAN": ["asean", "์์ธ์"],
|
| 816 |
+
"ํ๊ตญ": ["ํ๊ตญ", "๋ํ๋ฏผ๊ตญ", "korea"],
|
| 817 |
+
"์๊ตญ": ["์๊ตญ", "uk", "united kingdom"],
|
| 818 |
+
}
|
| 819 |
+
rows = []
|
| 820 |
+
for country, aliases in country_patterns.items():
|
| 821 |
+
found_index = -1
|
| 822 |
+
for alias in aliases:
|
| 823 |
+
idx = lower_clean.find(alias)
|
| 824 |
+
if idx >= 0:
|
| 825 |
+
found_index = idx
|
| 826 |
+
break
|
| 827 |
+
if found_index < 0:
|
| 828 |
+
continue
|
| 829 |
+
start = max(0, found_index - 350)
|
| 830 |
+
end = min(len(clean), found_index + 1000)
|
| 831 |
+
snippet = clean[start:end]
|
| 832 |
+
snippet_lower = snippet.lower()
|
| 833 |
+
category = "์ ํ"
|
| 834 |
+
if any(k in snippet_lower for k in ["๊ธ์ง", "์ฌ์ฉ๊ธ์ง", "๋ฐฐํฉ๊ธ์ง", "prohibited", "banned", "not allowed"]):
|
| 835 |
+
category = "๊ธ์ง"
|
| 836 |
+
rows.append({
|
| 837 |
+
"์๋ฃ๋ช
": term,
|
| 838 |
+
"INCI": term,
|
| 839 |
+
"CAS.No": "",
|
| 840 |
+
"๊ตฌ๋ถ": category,
|
| 841 |
+
"๊ตญ๊ฐ": country,
|
| 842 |
+
"๊ท์ ๋ด์ฉ": snippet[:500],
|
| 843 |
+
"ํ๋": "",
|
| 844 |
+
"์กฐ๊ฑด": "",
|
| 845 |
+
"์ถ์ฒ": "MFDS live: " + MFDS_LIVE_URL,
|
| 846 |
+
"์์ธ์๋ฌธ": clean[:5000],
|
| 847 |
+
})
|
| 848 |
+
return rows
|
| 849 |
+
|
| 850 |
+
|
| 851 |
+
def mfds_live_lookup_terms(terms, max_terms=30, headless=True):
|
| 852 |
+
if not PLAYWRIGHT_AVAILABLE:
|
| 853 |
+
return pd.DataFrame(), "playwright ๋ฏธ์ค์น: pip install playwright && python -m playwright install chromium ํ์"
|
| 854 |
+
terms = [safe_str(t) for t in terms if safe_str(t)]
|
| 855 |
+
terms = terms[:int(max_terms)] if max_terms else terms[:30]
|
| 856 |
+
all_rows = []
|
| 857 |
+
errors = []
|
| 858 |
+
try:
|
| 859 |
+
with sync_playwright() as p:
|
| 860 |
+
browser = p.chromium.launch(headless=bool(headless))
|
| 861 |
+
context = browser.new_context(viewport={"width": 1400, "height": 1000}, user_agent="Mozilla/5.0 reBom Regulatory Screening")
|
| 862 |
+
page = context.new_page()
|
| 863 |
+
for idx, term in enumerate(terms, start=1):
|
| 864 |
+
try:
|
| 865 |
+
print(f"MFDS ์ค์๊ฐ ์กฐํ {idx}/{len(terms)}: {term}")
|
| 866 |
+
page.goto(MFDS_LIVE_URL, wait_until="domcontentloaded", timeout=30000)
|
| 867 |
+
page.wait_for_timeout(2000)
|
| 868 |
+
if not mfds_live_fill_search_input(page, term):
|
| 869 |
+
errors.append(f"{term}: ๊ฒ์ ์
๋ ฅ์ฐฝ ์ฐพ๊ธฐ ์คํจ")
|
| 870 |
+
continue
|
| 871 |
+
if not mfds_live_click_search(page):
|
| 872 |
+
try:
|
| 873 |
+
page.keyboard.press("Enter")
|
| 874 |
+
except Exception:
|
| 875 |
+
pass
|
| 876 |
+
page.wait_for_timeout(2500)
|
| 877 |
+
mfds_live_click_result_row(page, term)
|
| 878 |
+
page.wait_for_timeout(1500)
|
| 879 |
+
text = mfds_live_visible_text(page)
|
| 880 |
+
rows = parse_mfds_live_text(term, text)
|
| 881 |
+
if rows:
|
| 882 |
+
all_rows.extend(rows)
|
| 883 |
+
else:
|
| 884 |
+
errors.append(f"{term}: ๊ตญ๊ฐ๋ณ ์์ธ์ ๋ณด ๋ฏธ๊ฒ์ถ")
|
| 885 |
+
except Exception as e:
|
| 886 |
+
errors.append(f"{term}: {e}")
|
| 887 |
+
context.close()
|
| 888 |
+
browser.close()
|
| 889 |
+
except Exception as e:
|
| 890 |
+
return pd.DataFrame(), f"MFDS ๋ธ๋ผ์ฐ์ ์คํ ์คํจ: {e}"
|
| 891 |
+
df = pd.DataFrame(all_rows)
|
| 892 |
+
msg = f"MFDS ์ค์๊ฐ ์กฐํ ์๋ฃ: ๊ฒ์์ด {len(terms)}๊ฐ, ๊ฒฐ๊ณผ {len(df)}ํ"
|
| 893 |
+
if errors:
|
| 894 |
+
msg += " / ์ผ๋ถ ์คํจ: " + " ; ".join(errors[:5])
|
| 895 |
+
if len(errors) > 5:
|
| 896 |
+
msg += f" ์ธ {len(errors) - 5}๊ฑด"
|
| 897 |
+
return df, msg
|
| 898 |
|
| 899 |
|
| 900 |
# ============================================================
|
|
|
|
| 2054 |
# 12. ๋ฉ์ธ ์ฒ๋ฆฌ
|
| 2055 |
# ============================================================
|
| 2056 |
|
| 2057 |
+
def process(countries, file, product_name="", use_mfds_live=False, mfds_max_terms=30, mfds_headless=True):
|
| 2058 |
global RAW_SEARCH_LOGS
|
| 2059 |
RAW_SEARCH_LOGS = []
|
| 2060 |
|
|
|
|
| 2071 |
|
| 2072 |
ingredient_totals = meta["ingredient_totals"]
|
| 2073 |
ingredient_amount_parts = meta["ingredient_amount_parts"]
|
| 2074 |
+
mfds_df = pd.DataFrame()
|
| 2075 |
+
mfds_live_msg = ""
|
| 2076 |
|
| 2077 |
llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)
|
| 2078 |
|
|
|
|
| 2094 |
}
|
| 2095 |
row_items.append({"target_id": target_id, "material": material, "component": comp, "row_data": row_data, "notes": []})
|
| 2096 |
|
| 2097 |
+
if use_mfds_live:
|
| 2098 |
+
try:
|
| 2099 |
+
terms = extract_terms_for_mfds_live(row_items)
|
| 2100 |
+
mfds_df, mfds_live_msg = mfds_live_lookup_terms(
|
| 2101 |
+
terms=terms,
|
| 2102 |
+
max_terms=mfds_max_terms,
|
| 2103 |
+
headless=mfds_headless,
|
| 2104 |
+
)
|
| 2105 |
+
except Exception as e:
|
| 2106 |
+
mfds_df = pd.DataFrame()
|
| 2107 |
+
mfds_live_msg = f"MFDS ์ค์๊ฐ ์กฐํ ์คํจ: {e}"
|
| 2108 |
+
|
| 2109 |
for country in countries:
|
| 2110 |
col_name = display_country(country)
|
| 2111 |
gpt_targets = []
|
|
|
|
| 2121 |
continue
|
| 2122 |
|
| 2123 |
mfds_result = None
|
| 2124 |
+
if use_mfds_live and mfds_df is not None and not mfds_df.empty:
|
| 2125 |
mfds_result = evaluate_mfds_detail_rule(country, item["material"], item["component"], mfds_df)
|
| 2126 |
|
| 2127 |
if mfds_result is not None:
|
|
|
|
| 2182 |
f"- ์ ์ฑ๋ถ ํ ์: {len(formula_df)}๊ฐ\n"
|
| 2183 |
f"- In formula ํฉ๊ณ: {format_amount(formula_total)}%\n"
|
| 2184 |
f"- ์ฌ๊ฒํ ํ์ ์ฑ๋ถ: {issue_count}๊ฐ\n"
|
| 2185 |
+
f"- MFDS ์ค์๊ฐ ์กฐํ ๊ฒฐ๊ณผ ํ ์: {mfds_count}๊ฐ\n"
|
| 2186 |
"- ๊ฒฐ๊ณผ ํ์ผ์ 3๊ฐ ์ํธ๋ก ์ ์ฅํ์ต๋๋ค.\n"
|
| 2187 |
" 1) Formula Ingredients Statement: ์๋ณธ ์์ ์ ์ฑ๋ถํ + ๊ตญ๊ฐ๋ณ ์งง์ ํ์ \n"
|
| 2188 |
" 2) Regulatory Screening Summary: ๋ฌธ์ ์๋ ์ฑ๋ถ๋ง ๊ตญ๊ฐ๋ณ ์์ฝ\n"
|
| 2189 |
" 3) Raw Search Log: ๋ก์ปฌ ๊ท์น/MFDS/GPT ๊ฒ์ ๊ทผ๊ฑฐ ๋ก๊ทธ\n"
|
| 2190 |
+
"- ํ์ ์ฐ์ ์์: ๋ก์ปฌ ๊ณ ์ ๊ท์น โ MFDS ์ค์๊ฐ ์กฐํ โ ๊ตญ๊ฐ๋ณ FAISS/GPT\n"
|
| 2191 |
+
f"- MFDS ์ํ: {mfds_live_msg or '์ฌ์ฉ ์ ํจ'}\n"
|
| 2192 |
"- GPT ํธ์ถ ์ ๊ฒ์ ์๋ฌธ์ ์ค์ ์ฑ๋ถ๋ช
์ด ์์ผ๋ฉด GPT๋ฅผ ํธ์ถํ์ง ์๊ณ 'ํด๋น ์๋ฃ ๋ด ์ ํ ๊ทผ๊ฑฐ ์์'์ผ๋ก ์ฒ๋ฆฌํฉ๋๋ค.\n"
|
| 2193 |
"- MergedCell column_letter ์ค๋ฅ ์์ ์๋ฃ ๋ฒ์ ์
๋๋ค.\n"
|
| 2194 |
"- public share link๊ฐ ์์ฑ๋๋๋ก share=True๋ก ์คํํฉ๋๋ค."
|
|
|
|
| 2227 |
|
| 2228 |
file = gr.File(label="์ ์ฑ๋ถ ์์
์
๋ก๋", file_types=[".xlsx"])
|
| 2229 |
|
| 2230 |
+
use_mfds_live = gr.Checkbox(label="์์ฝ์ฒ ์ฌ์ดํธ ์ค์๊ฐ ์กฐํ ์ฌ์ฉ", value=False)
|
| 2231 |
+
|
| 2232 |
+
mfds_max_terms = gr.Number(
|
| 2233 |
+
label="์์ฝ์ฒ ์ค์๊ฐ ์กฐํ ์ต๋ ๊ฒ์์ด ์",
|
| 2234 |
+
value=30,
|
| 2235 |
+
precision=0,
|
| 2236 |
+
)
|
| 2237 |
+
|
| 2238 |
+
mfds_headless = gr.Checkbox(
|
| 2239 |
+
label="์์ฝ์ฒ ์กฐํ ๋ธ๋ผ์ฐ์ ์จ๊น ๋ชจ๋",
|
| 2240 |
+
value=True,
|
| 2241 |
+
)
|
| 2242 |
|
| 2243 |
btn = gr.Button("๐ ๋ถ์ ์์", variant="primary")
|
| 2244 |
|
|
|
|
| 2255 |
print(f"์๋ ๊ตญ๊ฐ ๋ชฉ๋ก ๊ฐฑ์ ํ์ด๋จธ ๋นํ์ฑํ: {e}")
|
| 2256 |
|
| 2257 |
file.change(fn=preview_excel, inputs=file, outputs=df_out)
|
| 2258 |
+
btn.click(process, inputs=[country, file, product_name, use_mfds_live, mfds_max_terms, mfds_headless], outputs=[df_out, file_out, msg_out])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2259 |
|
| 2260 |
+
# MFDS ์์
DB ๊ด๋ฆฌ ํญ์ ์ ๊ฑฐํ์ต๋๋ค.
|
| 2261 |
+
# ์์ฝ์ฒ ์ ๋ณด๋ ์คํฌ๋ฆฌ๋ ํญ์ '์์ฝ์ฒ ์ฌ์ดํธ ์ค์๊ฐ ์กฐํ ์ฌ์ฉ' ์ต์
์ผ๋ก๋ง ์กฐํํฉ๋๋ค.
|
|
|
|
|
|
|
|
|
|
| 2262 |
|
| 2263 |
|
| 2264 |
# ============================================================
|