Spaces:
Running
Running
Upload 3 files
Browse files- scripts/chunk_handlers.py +18 -5
- scripts/sync_to_supabase.py +19 -0
scripts/chunk_handlers.py
CHANGED
|
@@ -620,6 +620,7 @@ def handle_tier_implementations(data: Any, context: Dict[str, Any]) -> List[Dict
|
|
| 620 |
"""tier_implementations ์ฒ๋ฆฌ - ๊ตญ๊ฐ/ํธํ
๋ช
์ ๋ณด ํฌํจ์ผ๋ก ๊ฒ์ ์ ํ๋ ํฅ์"""
|
| 621 |
chunks = []
|
| 622 |
chain = context.get("chain", "UNKNOWN")
|
|
|
|
| 623 |
|
| 624 |
impls = data if isinstance(data, list) else [data]
|
| 625 |
|
|
@@ -631,10 +632,19 @@ def handle_tier_implementations(data: Any, context: Dict[str, Any]) -> List[Dict
|
|
| 631 |
tier_level = impl.get("tier_level", "N/A")
|
| 632 |
impl_chain = impl.get("chain", chain)
|
| 633 |
|
| 634 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 635 |
extra = impl.get("extra_attributes", {})
|
| 636 |
-
|
| 637 |
-
|
|
|
|
|
|
|
| 638 |
region = extra.get("region", "")
|
| 639 |
|
| 640 |
content = f"""
|
|
@@ -643,12 +653,15 @@ def handle_tier_implementations(data: Any, context: Dict[str, Any]) -> List[Dict
|
|
| 643 |
# ์ค์ ํธํ
๋ช
์ด ์์ผ๋ฉด ์ฐ์ ํ์
|
| 644 |
if hotel_name:
|
| 645 |
content += f"ํธํ
: {hotel_name}\n"
|
| 646 |
-
|
| 647 |
-
|
|
|
|
| 648 |
|
| 649 |
# ๊ตญ๊ฐ/์ง์ญ ์ ๋ณด (๊ฒ์ ๋งค์นญ์ ์ค์)
|
| 650 |
if country:
|
| 651 |
content += f"๊ตญ๊ฐ: {country}\n"
|
|
|
|
|
|
|
| 652 |
if region:
|
| 653 |
content += f"์ง์ญ: {region}\n"
|
| 654 |
|
|
|
|
| 620 |
"""tier_implementations ์ฒ๋ฆฌ - ๊ตญ๊ฐ/ํธํ
๋ช
์ ๋ณด ํฌํจ์ผ๋ก ๊ฒ์ ์ ํ๋ ํฅ์"""
|
| 621 |
chunks = []
|
| 622 |
chain = context.get("chain", "UNKNOWN")
|
| 623 |
+
hotel_id_map = context.get("hotel_id_map", {}) # hotel_id โ ํธํ
์ ๋ณด ๋งคํ
|
| 624 |
|
| 625 |
impls = data if isinstance(data, list) else [data]
|
| 626 |
|
|
|
|
| 632 |
tier_level = impl.get("tier_level", "N/A")
|
| 633 |
impl_chain = impl.get("chain", chain)
|
| 634 |
|
| 635 |
+
# hotel_id_map์์ ํธํ
์ ๋ณด ์กฐํ (์ฐ์ )
|
| 636 |
+
hotel_info = hotel_id_map.get(hotel_id, {})
|
| 637 |
+
hotel_name = hotel_info.get("name", "")
|
| 638 |
+
hotel_name_ko = hotel_info.get("name_ko", "")
|
| 639 |
+
country = hotel_info.get("country", "")
|
| 640 |
+
city = hotel_info.get("city", "")
|
| 641 |
+
|
| 642 |
+
# extra_attributes์์ ๋ณด์ (ํด๋ฐฑ)
|
| 643 |
extra = impl.get("extra_attributes", {})
|
| 644 |
+
if not hotel_name:
|
| 645 |
+
hotel_name = extra.get("hotel_name", "")
|
| 646 |
+
if not country:
|
| 647 |
+
country = extra.get("country", "")
|
| 648 |
region = extra.get("region", "")
|
| 649 |
|
| 650 |
content = f"""
|
|
|
|
| 653 |
# ์ค์ ํธํ
๋ช
์ด ์์ผ๋ฉด ์ฐ์ ํ์
|
| 654 |
if hotel_name:
|
| 655 |
content += f"ํธํ
: {hotel_name}\n"
|
| 656 |
+
if hotel_name_ko and hotel_name_ko != hotel_name:
|
| 657 |
+
content += f"ํธํ
(ํ๊ธ๋ช
): {hotel_name_ko}\n"
|
| 658 |
+
content += f"ํธํ
ID: {hotel_id}\n"
|
| 659 |
|
| 660 |
# ๊ตญ๊ฐ/์ง์ญ ์ ๋ณด (๊ฒ์ ๋งค์นญ์ ์ค์)
|
| 661 |
if country:
|
| 662 |
content += f"๊ตญ๊ฐ: {country}\n"
|
| 663 |
+
if city:
|
| 664 |
+
content += f"๋์: {city}\n"
|
| 665 |
if region:
|
| 666 |
content += f"์ง์ญ: {region}\n"
|
| 667 |
|
scripts/sync_to_supabase.py
CHANGED
|
@@ -68,9 +68,27 @@ def create_chunks_from_knowledge(
|
|
| 68 |
# ํธํ
์ ๋ณด ๋ฏธ๋ฆฌ ์ถ์ถ (context์ฉ)
|
| 69 |
hotel_name = "Unknown Hotel"
|
| 70 |
hotel_name_ko = None
|
|
|
|
| 71 |
|
| 72 |
hotel_properties = extracted_knowledge.get("hotel_properties", [])
|
| 73 |
if hotel_properties and isinstance(hotel_properties, list):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
first_hotel = hotel_properties[0]
|
| 75 |
if isinstance(first_hotel, dict):
|
| 76 |
hotel_name = first_hotel.get("name", "Unknown Hotel")
|
|
@@ -91,6 +109,7 @@ def create_chunks_from_knowledge(
|
|
| 91 |
"chain": chain,
|
| 92 |
"hotel_name": hotel_name,
|
| 93 |
"hotel_name_ko": hotel_name_ko,
|
|
|
|
| 94 |
"doc_id": doc_id,
|
| 95 |
# identity ์ถ๊ฐ ์ ๋ณด
|
| 96 |
"document_category": identity.get("category") if identity else None,
|
|
|
|
| 68 |
# ํธํ
์ ๋ณด ๋ฏธ๋ฆฌ ์ถ์ถ (context์ฉ)
|
| 69 |
hotel_name = "Unknown Hotel"
|
| 70 |
hotel_name_ko = None
|
| 71 |
+
hotel_id_map = {} # hotel_id โ ํธํ
๋ช
๋งคํ
|
| 72 |
|
| 73 |
hotel_properties = extracted_knowledge.get("hotel_properties", [])
|
| 74 |
if hotel_properties and isinstance(hotel_properties, list):
|
| 75 |
+
for hotel in hotel_properties:
|
| 76 |
+
if isinstance(hotel, dict):
|
| 77 |
+
h_id = hotel.get("hotel_id")
|
| 78 |
+
h_name = hotel.get("name", "Unknown")
|
| 79 |
+
h_name_localized = hotel.get("name_localized", {})
|
| 80 |
+
h_name_ko = h_name_localized.get("ko") if isinstance(h_name_localized, dict) else None
|
| 81 |
+
|
| 82 |
+
# hotel_id ๋งคํ ์ถ๊ฐ
|
| 83 |
+
if h_id:
|
| 84 |
+
hotel_id_map[h_id] = {
|
| 85 |
+
"name": h_name,
|
| 86 |
+
"name_ko": h_name_ko,
|
| 87 |
+
"country": hotel.get("location", {}).get("country", "") if isinstance(hotel.get("location"), dict) else "",
|
| 88 |
+
"city": hotel.get("location", {}).get("city", "") if isinstance(hotel.get("location"), dict) else ""
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
# ์ฒซ ๋ฒ์งธ ํธํ
์ ๊ธฐ๋ณธ ํธํ
๋ก ์ฌ์ฉ
|
| 92 |
first_hotel = hotel_properties[0]
|
| 93 |
if isinstance(first_hotel, dict):
|
| 94 |
hotel_name = first_hotel.get("name", "Unknown Hotel")
|
|
|
|
| 109 |
"chain": chain,
|
| 110 |
"hotel_name": hotel_name,
|
| 111 |
"hotel_name_ko": hotel_name_ko,
|
| 112 |
+
"hotel_id_map": hotel_id_map, # hotel_id โ ํธํ
์ ๋ณด ๋งคํ ์ถ๊ฐ
|
| 113 |
"doc_id": doc_id,
|
| 114 |
# identity ์ถ๊ฐ ์ ๋ณด
|
| 115 |
"document_category": identity.get("category") if identity else None,
|