From 3a828c0f542266c1f861021fc17f67e6b094fed2 Mon Sep 17 00:00:00 2001 From: gahusb Date: Sat, 11 Apr 2026 08:46:50 +0900 Subject: [PATCH] feat(agent-office): service proxy for stock-lab and music-lab APIs --- agent-office/app/service_proxy.py | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 agent-office/app/service_proxy.py diff --git a/agent-office/app/service_proxy.py b/agent-office/app/service_proxy.py new file mode 100644 index 0000000..ae6d3b6 --- /dev/null +++ b/agent-office/app/service_proxy.py @@ -0,0 +1,34 @@ +import httpx +from typing import Any, Dict, List, Optional + +from .config import STOCK_LAB_URL, MUSIC_LAB_URL + +_client = httpx.AsyncClient(timeout=30.0) + +async def fetch_stock_news(limit: int = 10, category: str = None) -> List[Dict[str, Any]]: + params = {"limit": limit} + if category: + params["category"] = category + resp = await _client.get(f"{STOCK_LAB_URL}/api/stock/news", params=params) + resp.raise_for_status() + return resp.json() + +async def fetch_stock_indices() -> Dict[str, Any]: + resp = await _client.get(f"{STOCK_LAB_URL}/api/stock/indices") + resp.raise_for_status() + return resp.json() + +async def generate_music(payload: dict) -> Dict[str, Any]: + resp = await _client.post(f"{MUSIC_LAB_URL}/api/music/generate", json=payload) + resp.raise_for_status() + return resp.json() + +async def get_music_status(task_id: str) -> Dict[str, Any]: + resp = await _client.get(f"{MUSIC_LAB_URL}/api/music/status/{task_id}") + resp.raise_for_status() + return resp.json() + +async def get_music_credits() -> Dict[str, Any]: + resp = await _client.get(f"{MUSIC_LAB_URL}/api/music/credits") + resp.raise_for_status() + return resp.json()