53 lines
1.7 KiB
Python
53 lines
1.7 KiB
Python
from core.api.fetch_api_data import fetch_api_data
|
|
from core.api.schemas import Court, CourtID, CourtAutocomplete
|
|
from agents import function_tool
|
|
|
|
BASE_URL = 'https://obcan.justice.sk/pilot/api/ress-isu-service'
|
|
|
|
class CourtsAPI:
|
|
|
|
@function_tool
|
|
async def court(self, params: Court) -> dict:
|
|
"""
|
|
Fetch a list of courts from the Justice API with optional filtering.
|
|
|
|
Args:
|
|
params (Court): Filtering and pagination parameters.
|
|
|
|
Returns:
|
|
dict: A dictionary containing a list of courts and related metadata.
|
|
"""
|
|
url = f"{BASE_URL}/v1/sud"
|
|
|
|
return await fetch_api_data(icon="🏛️️", url=url, params=params.model_dump(exclude_none=True))
|
|
|
|
@function_tool
|
|
async def court_id(self, params: CourtID) -> dict:
|
|
"""
|
|
Fetch detailed information about a specific court by its identifier.
|
|
|
|
Args:
|
|
params (CourtID): Unique identifier of the court.
|
|
|
|
Returns:
|
|
dict: Details of the specified court.
|
|
"""
|
|
url = f"{BASE_URL}/v1/sud/{params.id}"
|
|
|
|
return await fetch_api_data(icon="🏛️️", url=url, params=params.model_dump(exclude_none=True), remove_keys=['foto'])
|
|
|
|
@function_tool
|
|
async def court_autocomplete(self, params: CourtAutocomplete) -> dict:
|
|
"""
|
|
Fetch autocomplete suggestions for court names.
|
|
|
|
Args:
|
|
params (CourtAutocomplete): Parameters for autocomplete.
|
|
|
|
Returns:
|
|
dict: Suggested court names matching the input query.
|
|
"""
|
|
url = f"{BASE_URL}/v1/sud/autocomplete"
|
|
|
|
return await fetch_api_data(icon="🏛️️", url=url, params=params.model_dump(exclude_none=True))
|