59 lines
1.9 KiB
Python
59 lines
1.9 KiB
Python
from api.fetch_api_data import fetch_api_data, docstring_from_model
|
|
from 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
|
|
@docstring_from_model(Court)
|
|
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.
|
|
{params}
|
|
|
|
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
|
|
@docstring_from_model(CourtID)
|
|
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.
|
|
{params}
|
|
|
|
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
|
|
@docstring_from_model(CourtAutocomplete)
|
|
async def court_autocomplete(self, params: CourtAutocomplete) -> dict:
|
|
"""
|
|
Fetch autocomplete suggestions for court names.
|
|
|
|
Args:
|
|
params (CourtAutocomplete): Parameters for autocomplete.
|
|
{params}
|
|
|
|
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))
|