53 lines
1.8 KiB
Python
53 lines
1.8 KiB
Python
from core.api.fetch_api_data import fetch_api_data
|
|
from core.api.schemas import Contracts, ContractID, ContractAutocomplete
|
|
from agents import function_tool
|
|
|
|
BASE_URL = 'https://obcan.justice.sk/pilot/api/ress-isu-service'
|
|
|
|
class ContractsAPI:
|
|
|
|
@function_tool
|
|
async def contract(self, params: Contracts) -> dict:
|
|
"""
|
|
Fetch a list of contracts from the Justice API with optional filtering.
|
|
|
|
Args:
|
|
params (Contracts): Filtering and pagination parameters.
|
|
|
|
Returns:
|
|
dict: A dictionary containing a list of contracts and related metadata.
|
|
"""
|
|
url = f"{BASE_URL}/v1/zmluvy"
|
|
|
|
return await fetch_api_data(icon="📃", url=url, params=params.model_dump(exclude_none=True))
|
|
|
|
|
|
@function_tool
|
|
async def contract_id(self, params: ContractID) -> dict:
|
|
"""
|
|
Fetch detailed information about a specific contract by its identifier.
|
|
|
|
Args:
|
|
params (ContractID): Unique identifier of the contract.
|
|
|
|
Returns:
|
|
dict: Details of the specified contract.
|
|
"""
|
|
url = f"{BASE_URL}/v1/zmluvy/{params.id}"
|
|
|
|
return await fetch_api_data(icon="📃", url=url, params=params.model_dump(exclude_none=True))
|
|
|
|
@function_tool
|
|
async def contract_autocomplete(self, params: ContractAutocomplete) -> dict:
|
|
"""
|
|
Fetch autocomplete suggestions for contract-related search terms.
|
|
|
|
Args:
|
|
params (ContractAutocomplete): Parameters for autocomplete query (e.g., partial text).
|
|
|
|
Returns:
|
|
dict: Suggested values matching the input query.
|
|
"""
|
|
url = f"{BASE_URL}/v1/zmluvy/autocomplete"
|
|
|
|
return await fetch_api_data(icon="📃", url=url, params=params.model_dump(exclude_none=True)) |