from api.fetch_api_data import fetch_api_data from api.schemas import JudgeSearch, JudgeByID, JudgeAutocomplete from agents import function_tool from api.config import JUSTICE_API_BASE class JudgesAPI: @function_tool async def judge(self, params: JudgeSearch) -> dict: """ Fetch a list of judges from the Justice API with optional filtering. Args: params (JudgeSearch): Filtering and pagination parameters. Returns: dict: A dictionary containing a list of judges and related metadata. """ url = f"{JUSTICE_API_BASE}/v1/sudca" return await fetch_api_data(icon="🧑‍⚖️", url=url, params=params.model_dump(exclude_none=True), remove_keys=['sudcaMapList']) @function_tool async def judge_id(self, params: JudgeByID) -> dict: """ Fetch detailed information about a specific judge by their identifier. Args: params (JudgeByID): Unique identifier of the judge. Returns: dict: Details of the specified judge. """ url = f"{JUSTICE_API_BASE}/v1/sudca/{params.id}" return await fetch_api_data(icon="🧑‍⚖️", url=url, params={}) @function_tool async def judge_autocomplete(self, params: JudgeAutocomplete) -> dict: """ Fetch autocomplete suggestions for judges' names. Args: params (JudgeAutocomplete): Parameters for autocomplete query (e.g., partial name). Returns: dict: Suggested judge names matching the input query. """ url = f"{JUSTICE_API_BASE}/v1/sudca/autocomplete" return await fetch_api_data(icon="🧑‍⚖️", url=url, params=params.model_dump(exclude_none=True))