#!/bin/bash # Script update_gov_bash.sh # Dùng bash curl gọi 9router với prompt cực kỳ chi tiết. KEY=$(grep LOCAL9R_KEY= /root/.hermes/.env | cut -d= -f2) # File chứa 28 ID và Title cat << 'EOF' > /tmp/gov_sources.txt c7923829-7313-43db-9aa1-2db1b631c17e|GOV_2017_Nghị quyết số 08-NQTW phát triển du lịch trở thành ngành kinh tế mũi nhọn 2017.md 656da2d2-2f72-4384-84b3-4ceee8e53543|GOV_2019_Quyết định 147QĐ-TTg 2020 phê duyệt Chiến lược phát triển du lịch Việt Nam đến năm 2030.md 107d6263-a22a-4461-a72c-b8796f9c20e4|GOV_2020_Luật Đầu tư theo phương thức đối tác công tư 2020 số 64/2020/QH14 áp dụng năm 2024 mới nhất d09889b7-cf01-40f9-88d9-caaae92e9c2f|GOV_2020_Phê duyệt Chiến lược phát triển du lịch Việt Nam đến năm 2030 516f7148-436d-4b20-84ca-ae24d4b5959b|GOV_2020_Quyết định 147/QĐ-TTg chiến lược phát triển du lịch Việt Nam đến năm 2030 e71e6594-a92e-42e4-899d-470dff3e2ec6|GOV_2021_Quyết định 1658/QĐ-TTg 2021 Chiến lược quốc gia về tăng trưởng xanh giai đoạn 2021-2030, tầm nhìn 2050 18528a87-bb0e-4277-a67f-24571c5cc70e|GOV_2021_Thông tư 11/2021/TT-BVHTTDL Hệ thống chỉ tiêu thống kê ngành văn hóa thể thao và du lịch mới nhất 0aa0c6a5-f1e1-4fba-8fa2-a4dfb59032f2|GOV_2022_Quyết định 754/QĐ-UBND TP.HCM 2022 phân bổ chi tiết kế hoạch đầu tư công a7a7b1be-8ddf-4e8f-a7ec-1b9fc70cd35f|GOV_2023_Nghị quyết 82_NQ-CP 2023 giải pháp đẩy nhanh phục hồi tăng tốc phát triển du lịch hiệu quả bền vững.md 3cd8373e-407a-4d08-8250-c070360a107c|GOV_2023_Nghị quyết 81/2023/QH15 Quy hoạch tổng thể quốc gia thời kỳ 2021 2030 d669d629-188d-4c5f-be79-4200c68d7613|GOV_2023_QD440_Phê duyệt Chiến lược Marketing du lịch Việt Nam đến 2030 88a8e5c4-b5e6-47b6-8399-0c7f87b4dffd|GOV_2024_509qd-ttg-Quy hoạch hệ thống du lịch thời kỳ 2021-2030, tầm nhìn đến năm 2045.pdf 2e760930-9640-4704-bd61-449a8e59ddc5|GOV_2024_Chỉ thị 08/CT-TTg năm 2024 phát triển du lịch toàn diện, nhanh và bền vững thời gian tới do Thủ tướng Chính phủ ban hành 83f4e69c-4528-438c-aed3-bdac0d85d460|GOV_2024_Quy hoạch hệ thống du lịch thời kỳ 2021-2030, tầm nhìn đến năm 2045..pdf 9fd3b5cc-7f24-439d-a70c-0e1740c66082|GOV_2024_Quyết định 1704/QĐ-BKHĐT 2024 Phương án Điều tra chi tiêu khách du lịch đến Việt Nam ac03012e-4b2f-4e2f-8f63-1fa2e394d2ed|GOV_2024_Quyết định 509/QÐ-TTg năm 2024 phê duyệt Quy hoạch hệ thống du lịch thời kỳ 2021-2030, tầm nhìn đến năm 2045 do Thủ tướng Chính phủ ban hành fb97a91e-5130-4f16-ae3a-d598cf7a86d1|GOV_2024_TOÀN VĂN: Nghị quyết 57-NQ/TW về đột phá phát triển khoa học, công nghệ, đổi mới sáng tạo và chuyển đổi số quốc gia_Mục tiêu 2045 3acf33a8-7b06-4a37-8fcd-16b9881c3c43|GOV_2025_47 BC-KTNN.pdf 68e5815b-3eb2-4cf6-9764-ba858834b93e|GOV_2025_Nghị quyết 68-NQTW 2025 về phát triển kinh tế tư nhân_Mục tiêu 2045.md df7eeecf-0424-418f-b41d-e80ce367529a|GOV_2025_Nghị quyết 252/2025/QH15 sửa đổi Nghị quyết 81/2023/QH15 Quy hoạch tổng thể quốc gia 2021 2030 ff916eaf-5612-44bf-9f54-02a80a14187d|GOV_2025_Nghị quyết 62/2025/NQ-HĐND thu hút đoàn khách du lịch tham dự hội nghị Hồ Chí Minh 03537aa1-7217-4b0e-871d-3d5a11c3ec2e|GOV_2025_Nghị quyết 66-NQ/TW về đổi mới công tác xây dựng và thi hành pháp luật_Mục tiêu 2045 bd20af3e-93dd-49c6-a8c8-faa3f1a5da87|GOV_2025_Nghị quyết số 59-NQ/TW của Bộ Chính trị khóa XIII: Bước phát triển mới trong tư duy của Đảng về đối ngoại và hội nhập quốc tế - Tạp chí Cộng sản_Mục tiêu 2045 5ace7d69-7204-4959-b264-e381a4c4e682|GOV_2025_Văn bản hợp nhất 123/VBHN-VPQH 2025 Luật Đầu tư theo phương thức đối tác công tư 12edefe7-fbb0-4c8d-9dbf-e04f7a948593|GOV_2026_18-KL/TW_Thúc đẩy du lịch quốc tế gắn với các dịch vụ chăm sóc sức khoẻ, mua sắm hàng hoá 1ff804a3-74e4-4932-83e0-d076308a1f4d|GOV_2026_Phê duyệt điều chỉnh Quy hoạch hệ thống du lịch thời kỳ 2021-2030, tầm nhìn đến năm 2045 86a7aefe-d144-4fea-8be8-635fb1d6f745|GOV_2026_QĐ374-dc_qhhtdl.pdf 193d80c7-e166-4010-b3b7-728f098b7ad4|GOV_2026_Đánh giá việc thực hiện chính sách, pháp luật lĩnh vực văn hóa, thể thao và du lịch EOF # Chúng ta gọi python cho phần ruột để dễ JSON escape cat << 'EOF' > /tmp/process_single.py import json, sys, subprocess, urllib.request, time source_id, title, key = sys.argv[1], sys.argv[2], sys.argv[3] print(f"\n> Processing: {title[:50]}...") # 1. Fetch content res = subprocess.run(["/opt/ai-os/products/ceo/integrations/notebooklm-mcp-cli/.venv/bin/nlm", "content", "source", source_id], capture_output=True, text=True, cwd="/opt/ai-os/products/ceo") if res.returncode != 0: print(f"Fetch failed: {res.stderr[:100]}") sys.exit(1) try: content = json.loads(res.stdout).get("content", "") except: content = res.stdout if len(content) < 50: print("Content too short") sys.exit(1) # 2. Call 9router prompt = f"""You are a strict RAG summarizer for Vietnamese government documents. Provide a highly detailed summary chapter by chapter. ONLY state facts from the document. NEVER fabricate bottlenecks or challenges if not mentioned. Output EXACTLY this format: - **Tóm tắt:** ** [Detailed English summary, 5-8 sentences covering main policies, chapters, targets, and EXPLICIT bottlenecks] - **Tóm tắt (VN):** ** [Detailed Vietnamese summary, 5-8 sentences covering the exact same points. DO NOT use dashes in prose or lists; use numbers or asterisks.] Content: {content[:15000]} """ payload = { "model": "default", "messages": [{"role": "user", "content": prompt}], "max_tokens": 1500, "temperature": 0.1, "stream": False } req = urllib.request.Request("http://127.0.0.1:20128/v1/chat/completions", data=json.dumps(payload).encode(), headers={"Content-Type": "application/json", "Authorization": f"Bearer {key}"}) try: with urllib.request.urlopen(req, timeout=180) as resp: result = json.loads(resp.read()) summary = result["choices"][0]["message"]["content"] if "- **Tóm tắt:" not in summary: print("Bad output format") sys.exit(1) # 3. Patch file master = "/opt/ai-os/products/ceo/content/research/domains/tourism/master_tourism_vn.md" with open(master, 'r') as f: m = f.read() import re entries = list(re.finditer(r'(##? \d+\.\s*.*?)(?=\n##? \d+\.|\Z)', m, re.DOTALL)) target = None for e in entries: if f"`{source_id}`" in e.group(0): target = e break if not target: print("ID not found in master") sys.exit(1) etext = target.group(0) sum_match = re.search(r'(- \*\*Tóm tắt:\*\* \*\* .*?)(?=\n### \d+\.|\n## \d+\.|\Z)', etext, re.DOTALL) if sum_match: new_e = etext.replace(sum_match.group(0), summary.strip()) else: new_e = etext.rstrip() + '\n' + summary.strip() + '\n' m = m.replace(etext, new_e, 1) with open(master, 'w') as f: f.write(m) print("✅ SUCCESS") except Exception as e: print(f"Error: {e}") sys.exit(1) EOF while IFS='|' read -r sid title; do python3 /tmp/process_single.py "$sid" "$title" "$KEY" sleep 3 done < /tmp/gov_sources.txt