feat(agent-office): replace blog_* proxy with insta_* helpers

This commit is contained in:
2026-05-16 00:47:16 +09:00
parent 8a4a8790ca
commit 8cb5a01431

View File

@@ -1,7 +1,7 @@
import httpx
from typing import Any, Dict, List, Optional
from .config import STOCK_URL, MUSIC_LAB_URL, BLOG_LAB_URL, REALESTATE_LAB_URL
from .config import STOCK_URL, MUSIC_LAB_URL, INSTA_LAB_URL, REALESTATE_LAB_URL
_client = httpx.AsyncClient(timeout=30.0)
@@ -101,58 +101,70 @@ async def get_music_credits() -> Dict[str, Any]:
return resp.json()
# --- blog-lab ---
# --- insta-lab ---
async def blog_research(keyword: str) -> Dict[str, Any]:
"""키워드 리서치 시작 → task_id 반환"""
async def insta_collect(categories: Optional[list] = None) -> Dict[str, Any]:
"""뉴스 수집 트리거 → task_id 반환."""
payload = {"categories": categories} if categories else {}
resp = await _client.post(f"{INSTA_LAB_URL}/api/insta/news/collect", json=payload)
resp.raise_for_status()
return resp.json()
async def insta_extract(categories: Optional[list] = None) -> Dict[str, Any]:
payload = {"categories": categories} if categories else {}
resp = await _client.post(f"{INSTA_LAB_URL}/api/insta/keywords/extract", json=payload)
resp.raise_for_status()
return resp.json()
async def insta_list_keywords(category: Optional[str] = None,
used: Optional[bool] = None) -> List[Dict[str, Any]]:
params: Dict[str, Any] = {}
if category:
params["category"] = category
if used is not None:
params["used"] = "true" if used else "false"
resp = await _client.get(f"{INSTA_LAB_URL}/api/insta/keywords", params=params)
resp.raise_for_status()
return resp.json().get("items", [])
async def insta_get_keyword(keyword_id: int) -> Optional[Dict[str, Any]]:
items = await insta_list_keywords()
for it in items:
if it["id"] == keyword_id:
return it
return None
async def insta_create_slate(keyword: str, category: str, keyword_id: Optional[int] = None) -> Dict[str, Any]:
resp = await _client.post(
f"{BLOG_LAB_URL}/api/blog-marketing/research",
json={"keyword": keyword},
f"{INSTA_LAB_URL}/api/insta/slates",
json={"keyword": keyword, "category": category, "keyword_id": keyword_id},
)
resp.raise_for_status()
return resp.json()
async def blog_task_status(task_id: str) -> Dict[str, Any]:
resp = await _client.get(f"{BLOG_LAB_URL}/api/blog-marketing/task/{task_id}")
async def insta_task_status(task_id: str) -> Dict[str, Any]:
resp = await _client.get(f"{INSTA_LAB_URL}/api/insta/tasks/{task_id}")
resp.raise_for_status()
return resp.json()
async def blog_generate(keyword_id: int) -> Dict[str, Any]:
resp = await _client.post(
f"{BLOG_LAB_URL}/api/blog-marketing/generate",
json={"keyword_id": keyword_id},
)
async def insta_get_slate(slate_id: int) -> Dict[str, Any]:
resp = await _client.get(f"{INSTA_LAB_URL}/api/insta/slates/{slate_id}")
resp.raise_for_status()
return resp.json()
async def blog_market(post_id: int) -> Dict[str, Any]:
resp = await _client.post(f"{BLOG_LAB_URL}/api/blog-marketing/market/{post_id}")
async def insta_get_asset_bytes(slate_id: int, page: int) -> bytes:
"""카드 PNG 바이트를 가져와 텔레그램 미디어 그룹에 첨부."""
async with httpx.AsyncClient(timeout=30) as client:
resp = await client.get(f"{INSTA_LAB_URL}/api/insta/slates/{slate_id}/assets/{page}")
resp.raise_for_status()
return resp.json()
async def blog_review(post_id: int) -> Dict[str, Any]:
resp = await _client.post(f"{BLOG_LAB_URL}/api/blog-marketing/review/{post_id}")
resp.raise_for_status()
return resp.json()
async def blog_publish(post_id: int, url: str = "") -> Dict[str, Any]:
resp = await _client.post(
f"{BLOG_LAB_URL}/api/blog-marketing/posts/{post_id}/publish",
json={"url": url},
)
resp.raise_for_status()
return resp.json()
async def blog_get_post(post_id: int) -> Dict[str, Any]:
resp = await _client.get(f"{BLOG_LAB_URL}/api/blog-marketing/posts/{post_id}")
resp.raise_for_status()
return resp.json()
return resp.content
# --- realestate-lab ---