# Intelligence Agent 🧠 **AI-powered Security Blog Automation System** ## Overview Intelligence AgentλŠ” λ³΄μ•ˆ λ‰΄μŠ€λ₯Ό μžλ™μœΌλ‘œ μˆ˜μ§‘ν•˜κ³ , LLM(GLM-4.7)을 μ‚¬μš©ν•˜μ—¬ μ „λ¬Έκ°€ μˆ˜μ€€μ˜ λΈ”λ‘œκ·Έ 글을 μž‘μ„±ν•œ ν›„, Notionκ³Ό GitHub Pages에 μžλ™μœΌλ‘œ κ²Œμ‹œν•˜λŠ” μ‹œμŠ€ν…œμž…λ‹ˆλ‹€. ## Features - πŸ” **λ‰΄μŠ€ μˆ˜μ§‘**: Google News, arXiv, HackerNews RSS ν”Όλ“œμ—μ„œ μ΅œμ‹  λ³΄μ•ˆ λ‰΄μŠ€ μˆ˜μ§‘ - ✍️ **AI κΈ€ μž‘μ„±**: GLM-4.7을 μ‚¬μš©ν•˜μ—¬ 3000+ 자의 전문적인 λΈ”λ‘œκ·Έ κΈ€ μž‘μ„± - πŸ“ **Notion 연동**: μ΄ˆμ•ˆ μž‘μ„± β†’ 검토쀑 β†’ κ²€ν†  μ™„λ£Œ μƒνƒœ 관리 - πŸš€ **μžλ™ 배포**: Git 기반 GitHub Actions으둜 μžλ™ λΈ”λ‘œκ·Έ 배포 - πŸ“… **μŠ€μΌ€μ€„λ§**: 맀일 08:30 μžλ™ μ‹€ν–‰ (APScheduler) ## Architecture ``` λ‰΄μŠ€ μˆ˜μ§‘ (Collector) ↓ GLM-4.7 κΈ€ μž‘μ„± (LLM Client) ↓ Notion μ €μž₯ (Notion Publisher) ↓ μ‚¬μš©μž κ²€ν†  (Human-in-the-Loop) ↓ Git 배포 (Git Publisher) ↓ GitHub Actions β†’ GitHub Pages ``` ## Project Structure ``` intelligence-agent/ β”œβ”€β”€ __init__.py β”œβ”€β”€ collector.py # λ‰΄μŠ€ μˆ˜μ§‘κΈ° β”œβ”€β”€ llm_client.py # GLM-4.7 API ν΄λΌμ΄μ–ΈνŠΈ β”œβ”€β”€ llm_client_async.py # 비동기 LLM ν΄λΌμ΄μ–ΈνŠΈ β”œβ”€β”€ notion_publisher.py # Notion API 연동 β”œβ”€β”€ git_publisher_service.py # Git 배포 μ„œλΉ„μŠ€ β”œβ”€β”€ publisher_git.py # Git 퍼블리셔 β”œβ”€β”€ intelligence_pipeline.py # 전체 νŒŒμ΄ν”„λΌμΈ β”œβ”€β”€ config.py # μ„€μ • β”œβ”€β”€ models.py # 데이터 λͺ¨λΈ β”œβ”€β”€ prompt_manager.py # ν”„λ‘¬ν”„νŠΈ 관리 β”œβ”€β”€ prompts.yaml # ν”„λ‘¬ν”„νŠΈ ν…œν”Œλ¦Ώ β”œβ”€β”€ requirements.txt # μ˜μ‘΄μ„± └── README.md # 이 파일 ``` ## Installation ```bash # μ €μž₯μ†Œ 클둠 git clone https://github.com/rebugui/intelligence-agent.git cd intelligence-agent # κ°€μƒν™˜κ²½ 생성 python3 -m venv venv source venv/bin/activate # μ˜μ‘΄μ„± μ„€μΉ˜ pip install -r requirements.txt # ν™˜κ²½ λ³€μˆ˜ μ„€μ • cp .env.example .env # .env 파일 νŽΈμ§‘ ``` ## Configuration ### ν•„μˆ˜ ν™˜κ²½ λ³€μˆ˜ ```bash # GLM API GLM_API_KEY=your_glm_api_key GLM_BASE_URL=https://api.z.ai/api/coding/paas/v4 # Notion API NOTION_API_KEY=your_notion_api_key NOTION_DATABASE_ID=your_database_id # GitHub GITHUB_TOKEN=your_github_token GITHUB_REPO=rebugui/rebugui.github.io # λΈ”λ‘œκ·Έ BLOG_LOCAL_PATH=/path/to/blog/repo ``` ## Usage ### 1회 μ‹€ν–‰ (ν…ŒμŠ€νŠΈμš©) ```bash python intelligence_pipeline.py ``` ### μŠ€μΌ€μ€„λŸ¬ μ‹€ν–‰ (맀일 08:30) ```bash python scheduler_intelligence.py ``` ### μˆ˜λ™ μ‹€ν–‰ ```python from intelligence_pipeline import IntelligencePipeline pipeline = IntelligencePipeline() pipeline.run() ``` ## API Reference ### NewsCollector ```python from collector import NewsCollector collector = NewsCollector() articles = collector.collect_all() # Returns: List[Article] ``` ### LLMClient ```python from llm_client import LLMClient client = LLMClient() blog_post = client.generate_blog_post(articles) # Returns: str (Markdown formatted) ``` ### NotionPublisher ```python from notion_publisher import NotionPublisher publisher = NotionPublisher() page_id = publisher.create_page(title, content, status="μ΄ˆμ•ˆ μž‘μ„±μ€‘") # Returns: str (Page ID) ``` ### GitPublisher ```python from git_publisher_service import GitPublisher publisher = GitPublisher() publisher.publish_to_blog(page_id, content) # Deploys to GitHub Pages ``` ## Workflow ### μƒνƒœ λ³€ν™” ν”Œλ‘œμš° ``` 1. μ΄ˆμ•ˆ μž‘μ„±μ€‘ (μžλ™ μ €μž₯) ↓ 2. 검토쀑 (μ‚¬μš©μž κ²€ν†  μ‹œμž‘) ↓ 3. κ²€ν†  μ™„λ£Œ (μ‚¬μš©μž 승인) β†’ Git 배포 μžλ™ μ‹œμž‘ ↓ 4. κ²Œμ‹œ μ™„λ£Œ (GitHub Pages 배포) ``` ### Human-in-the-Loop - **μžλ™ν™”λœ λΆ€λΆ„**: λ‰΄μŠ€ μˆ˜μ§‘, κΈ€ μž‘μ„±, Notion μ €μž₯ - **μˆ˜λ™ κ²€ν† **: Notionμ—μ„œ λ‚΄μš© 확인/μˆ˜μ • - **μžλ™ 배포**: "κ²€ν†  μ™„λ£Œ" μƒνƒœ μ‹œ μžλ™ Git 배포 ## Technical Stack - **Language**: Python 3.9+ - **LLM**: GLM-4.7 (Zhipu AI) - **News Sources**: Google News, arXiv, HackerNews - **CMS**: Notion API - **Blog**: Hugo + GitHub Pages - **Scheduler**: APScheduler - **State Management**: Notion Database ## Blog - **URL**: https://rebugui.github.io/ - **Repository**: https://github.com/rebugui/rebugui.github.io - **Theme**: Hugo Stack Theme ## Monitoring ### 둜그 확인 ```bash tail -f logs/intelligence.log ``` ### μƒνƒœ 확인 ```bash python -c "from intelligence_pipeline import IntelligencePipeline; p = IntelligencePipeline(); print(p.get_status())" ``` ## Troubleshooting ### GLM API μ—°κ²° 였λ₯˜ ```bash # API ν‚€ 확인 echo $GLM_API_KEY # μ—°κ²° ν…ŒμŠ€νŠΈ curl -X POST https://api.z.ai/api/coding/paas/v4/chat/completions \ -H "Authorization: Bearer $GLM_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "glm-4.7", "messages": [{"role": "user", "content": "Hello"}]}' ``` ### Notion API 였λ₯˜ ```bash # Database κΆŒν•œ 확인 # https://www.notion.so/my-integrations μ—μ„œ μ—°κ²° μƒνƒœ 확인 ``` ### Git 배포 였λ₯˜ ```bash # Git κΆŒν•œ 확인 ssh -T git@github.com # μ €μž₯μ†Œ μƒνƒœ 확인 cd $BLOG_LOCAL_PATH git status ``` ## Contributing 1. Fork the repository 2. Create your feature branch (`git checkout -b feature/amazing-feature`) 3. Commit your changes (`git commit -m 'Add some amazing feature'`) 4. Push to the branch (`git push origin feature/amazing-feature`) 5. Open a Pull Request ## License MIT License ## Author Generated by Builder Agent v3 ## Links - GitHub: https://github.com/rebugui/intelligence-agent - Blog: https://rebugui.github.io/ - Notion: https://www.notion.so/