feat(agent-office): replace blog_* proxy with insta_* helpers
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import httpx
|
import httpx
|
||||||
from typing import Any, Dict, List, Optional
|
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)
|
_client = httpx.AsyncClient(timeout=30.0)
|
||||||
|
|
||||||
@@ -101,58 +101,70 @@ async def get_music_credits() -> Dict[str, Any]:
|
|||||||
return resp.json()
|
return resp.json()
|
||||||
|
|
||||||
|
|
||||||
# --- blog-lab ---
|
# --- insta-lab ---
|
||||||
|
|
||||||
async def blog_research(keyword: str) -> Dict[str, Any]:
|
async def insta_collect(categories: Optional[list] = None) -> Dict[str, Any]:
|
||||||
"""키워드 리서치 시작 → task_id 반환"""
|
"""뉴스 수집 트리거 → 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(
|
resp = await _client.post(
|
||||||
f"{BLOG_LAB_URL}/api/blog-marketing/research",
|
f"{INSTA_LAB_URL}/api/insta/slates",
|
||||||
json={"keyword": keyword},
|
json={"keyword": keyword, "category": category, "keyword_id": keyword_id},
|
||||||
)
|
)
|
||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
return resp.json()
|
return resp.json()
|
||||||
|
|
||||||
|
|
||||||
async def blog_task_status(task_id: str) -> Dict[str, Any]:
|
async def insta_task_status(task_id: str) -> Dict[str, Any]:
|
||||||
resp = await _client.get(f"{BLOG_LAB_URL}/api/blog-marketing/task/{task_id}")
|
resp = await _client.get(f"{INSTA_LAB_URL}/api/insta/tasks/{task_id}")
|
||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
return resp.json()
|
return resp.json()
|
||||||
|
|
||||||
|
|
||||||
async def blog_generate(keyword_id: int) -> Dict[str, Any]:
|
async def insta_get_slate(slate_id: int) -> Dict[str, Any]:
|
||||||
resp = await _client.post(
|
resp = await _client.get(f"{INSTA_LAB_URL}/api/insta/slates/{slate_id}")
|
||||||
f"{BLOG_LAB_URL}/api/blog-marketing/generate",
|
|
||||||
json={"keyword_id": keyword_id},
|
|
||||||
)
|
|
||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
return resp.json()
|
return resp.json()
|
||||||
|
|
||||||
|
|
||||||
async def blog_market(post_id: int) -> Dict[str, Any]:
|
async def insta_get_asset_bytes(slate_id: int, page: int) -> bytes:
|
||||||
resp = await _client.post(f"{BLOG_LAB_URL}/api/blog-marketing/market/{post_id}")
|
"""카드 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()
|
resp.raise_for_status()
|
||||||
return resp.json()
|
return resp.content
|
||||||
|
|
||||||
|
|
||||||
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()
|
|
||||||
|
|
||||||
|
|
||||||
# --- realestate-lab ---
|
# --- realestate-lab ---
|
||||||
|
|||||||
Reference in New Issue
Block a user