54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
from core.api.fetch_api_data import fetch_api_data
|
|
from core.api.schemas import Judge, JudgeID, JudgeAutocomplete
|
|
from agents import function_tool
|
|
|
|
BASE_URL = 'https://obcan.justice.sk/pilot/api/ress-isu-service'
|
|
|
|
class JudgesAPI:
|
|
|
|
@function_tool
|
|
async def judge(self, params: Judge) -> dict:
|
|
"""
|
|
Fetch a list of judges from the Justice API with optional filtering.
|
|
|
|
Args:
|
|
params (Judge): Filtering and pagination parameters.
|
|
|
|
Returns:
|
|
dict: A dictionary containing a list of judges and related metadata.
|
|
"""
|
|
url = f"{BASE_URL}/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: JudgeID) -> dict:
|
|
"""
|
|
Fetch detailed information about a specific judge by their identifier.
|
|
|
|
Args:
|
|
params (JudgeID): Unique identifier of the judge.
|
|
|
|
Returns:
|
|
dict: Details of the specified judge.
|
|
"""
|
|
url = f"{BASE_URL}/v1/sudca/{params.id}"
|
|
|
|
return await fetch_api_data(icon="🧑⚖️", url=url, params=params.model_dump(exclude_none=True))
|
|
|
|
|
|
@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"{BASE_URL}/v1/sudca/autocomplete"
|
|
|
|
return await fetch_api_data(icon="🧑⚖️", url=url, params=params.model_dump(exclude_none=True)) |