284 lines
11 KiB
Python
284 lines
11 KiB
Python
from agents import function_tool
|
|
from api.fetch_api_data import fetch_api_data
|
|
from api.schemas import (
|
|
CourtSearch, CourtByID, CourtAutocomplete,
|
|
JudgeSearch, JudgeByID, JudgeAutocomplete,
|
|
DecisionSearch, DecisionByID, DecisionAutocomplete,
|
|
ContractSearch, ContractByID, ContractAutocomplete,
|
|
CivilProceedingsSearch, CivilProceedingsByID, CivilProceedingsAutocomplete,
|
|
AdminProceedingsSearch, AdminProceedingsByID, AdminProceedingsAutocomplete,
|
|
)
|
|
from api.config import JUSTICE_API_BASE
|
|
|
|
####################################################################################################################
|
|
# .../v1/sud
|
|
####################################################################################################################
|
|
|
|
@function_tool
|
|
async def court_search(params: CourtSearch) -> dict:
|
|
"""
|
|
Fetch a list of courts from the Justice API with optional filtering.
|
|
Args:
|
|
params (CourtSearch): Filtering and pagination parameters.
|
|
Returns:
|
|
dict: A dictionary containing a list of courts and related metadata.
|
|
"""
|
|
url = f"{JUSTICE_API_BASE}/v1/sud"
|
|
|
|
return await fetch_api_data(icon="🏛️️", url=url, params=params.model_dump(exclude_none=True))
|
|
|
|
@function_tool
|
|
async def court_id(params: CourtByID) -> dict:
|
|
"""
|
|
Fetch detailed information about a specific court by its identifier.
|
|
Args:
|
|
params (CourtByID): Unique identifier of the court.
|
|
Returns:
|
|
dict: Details of the specified court.
|
|
"""
|
|
url = f"{JUSTICE_API_BASE}/v1/sud/{params.id}"
|
|
|
|
return await fetch_api_data(icon="🏛️️", url=url, params={}, remove_keys=['foto'])
|
|
|
|
@function_tool
|
|
async def court_autocomplete(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"{JUSTICE_API_BASE}/v1/sud/autocomplete"
|
|
|
|
return await fetch_api_data(icon="🏛️️", url=url, params=params.model_dump(exclude_none=True))
|
|
|
|
####################################################################################################################
|
|
# .../v1/sudca
|
|
####################################################################################################################
|
|
|
|
@function_tool
|
|
async def judge_search(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(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(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))
|
|
|
|
####################################################################################################################
|
|
# .../v1/rozhodnutie
|
|
####################################################################################################################
|
|
|
|
@function_tool
|
|
async def decision_search(params: DecisionSearch) -> dict:
|
|
"""
|
|
Fetch a list of decisions from the Justice API with optional filtering.
|
|
Args:
|
|
params (DecisionSearch): Filtering and pagination parameters.
|
|
Returns:
|
|
dict: A dictionary containing a list of decisions and related metadata.
|
|
"""
|
|
url = f"{JUSTICE_API_BASE}/v1/rozhodnutie"
|
|
|
|
return await fetch_api_data(icon="⚖️️", url=url, params=params.model_dump(exclude_none=True))
|
|
|
|
|
|
@function_tool
|
|
async def decision_id(params: DecisionByID) -> dict:
|
|
"""
|
|
Fetch detailed information about a specific decision by its identifier.
|
|
Args:
|
|
params (DecisionByID): Unique identifier of the decision.
|
|
Returns:
|
|
dict: Details of the specified decision.
|
|
"""
|
|
url = f"{JUSTICE_API_BASE}/v1/rozhodnutie/{params.id}"
|
|
|
|
return await fetch_api_data(icon="⚖️️", url=url, params={})
|
|
|
|
@function_tool
|
|
async def decision_autocomplete(params: DecisionAutocomplete) -> dict:
|
|
"""
|
|
Fetch autocomplete suggestions for decision-related search terms.
|
|
Args:
|
|
params (DecisionAutocomplete): Parameters for autocomplete.
|
|
Returns:
|
|
dict: Suggested values matching the input query.
|
|
"""
|
|
url = f"{JUSTICE_API_BASE}/v1/rozhodnutie/autocomplete"
|
|
|
|
return await fetch_api_data(icon="⚖️️", url=url, params=params.model_dump(exclude_none=True))
|
|
|
|
####################################################################################################################
|
|
# .../v1/zmluvy
|
|
####################################################################################################################
|
|
|
|
@function_tool
|
|
async def contract_search(params: ContractSearch) -> dict:
|
|
"""
|
|
Fetch a list of contracts from the Justice API with optional filtering.
|
|
Args:
|
|
params (ContractSearch): Filtering and pagination parameters.
|
|
Returns:
|
|
dict: A dictionary containing a list of contracts and related metadata.
|
|
"""
|
|
url = f"{JUSTICE_API_BASE}/v1/zmluvy"
|
|
|
|
return await fetch_api_data(icon="📃", url=url, params=params.model_dump(exclude_none=True))
|
|
|
|
|
|
@function_tool
|
|
async def contract_id(params: ContractByID) -> dict:
|
|
"""
|
|
Fetch detailed information about a specific contract by its identifier.
|
|
Args:
|
|
params (ContractByID): Unique identifier of the contract.
|
|
Returns:
|
|
dict: Details of the specified contract.
|
|
"""
|
|
url = f"{JUSTICE_API_BASE}/v1/zmluvy/{params.idZmluvy}"
|
|
|
|
return await fetch_api_data(icon="📃", url=url, params={})
|
|
|
|
@function_tool
|
|
async def contract_autocomplete(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"{JUSTICE_API_BASE}/v1/zmluvy/autocomplete"
|
|
|
|
return await fetch_api_data(icon="📃", url=url, params=params.model_dump(exclude_none=True))
|
|
|
|
####################################################################################################################
|
|
# .../v1/obcianPojednavania
|
|
####################################################################################################################
|
|
|
|
@function_tool
|
|
async def civil_proceedings_search(params: CivilProceedingsSearch) -> dict:
|
|
"""
|
|
Fetch a list of civil proceedings and publicly announced judgments
|
|
from the Justice API with optional filtering.
|
|
Args:
|
|
params (CivilProceedingsSearch): Filtering and pagination parameters.
|
|
Returns:
|
|
dict: A dictionary containing a list of civil proceedings and related metadata.
|
|
"""
|
|
url = f"{JUSTICE_API_BASE}/v1/obcianPojednavania"
|
|
|
|
return await fetch_api_data(icon="🖊️", url=url, params=params.model_dump(exclude_none=True))
|
|
|
|
@function_tool
|
|
async def civil_proceedings_id(params: CivilProceedingsByID) -> dict:
|
|
"""
|
|
Fetch detailed information about a specific civil proceeding
|
|
and publicly announced judgment by its identifier.
|
|
Args:
|
|
params (CivilProceedingsByID): Unique identifier of the civil proceeding.
|
|
Returns:
|
|
dict: Details of the specified civil proceeding and judgment.
|
|
"""
|
|
url = f"{JUSTICE_API_BASE}/v1/obcianPojednavania/{params.id}"
|
|
|
|
return await fetch_api_data(icon="🖊️", url=url, params={})
|
|
|
|
@function_tool
|
|
async def civil_proceedings_autocomplete(params: CivilProceedingsAutocomplete) -> dict:
|
|
"""
|
|
Fetch autocomplete suggestions for civil proceeding search terms.
|
|
Args:
|
|
params (CivilProceedingsAutocomplete): Parameters for autocomplete query (e.g., partial text).
|
|
Returns:
|
|
dict: Suggested values matching the input query.
|
|
"""
|
|
url = f"{JUSTICE_API_BASE}/v1/obcianPojednavania/autocomplete"
|
|
|
|
return await fetch_api_data(icon="🖊️", url=url, params=params.model_dump(exclude_none=True))
|
|
|
|
####################################################################################################################
|
|
# .../v1/spravneKonanie
|
|
####################################################################################################################
|
|
|
|
@function_tool
|
|
async def admin_proceedings_search(params: AdminProceedingsSearch) -> dict:
|
|
"""
|
|
Fetch a list of administrative proceedings from the Justice API with optional filtering.
|
|
Args:
|
|
params (AdminProceedingsSearch): Filtering and pagination parameters.
|
|
Returns:
|
|
dict: A dictionary containing a list of administrative proceedings and related metadata.
|
|
"""
|
|
url = f"{JUSTICE_API_BASE}/v1/spravneKonanie"
|
|
|
|
return await fetch_api_data(icon="✒️", url=url, params=params.model_dump(exclude_none=True))
|
|
|
|
@function_tool
|
|
async def admin_proceedings_id(params: AdminProceedingsByID) -> dict:
|
|
"""
|
|
Fetch detailed information about a specific administrative proceeding by its identifier.
|
|
Args:
|
|
params (AdminProceedingsByID): Unique identifier of the administrative proceeding.
|
|
Returns:
|
|
dict: Details of the specified administrative proceeding.
|
|
"""
|
|
url = f"{JUSTICE_API_BASE}/v1/spravneKonanie/{params.id}"
|
|
|
|
return await fetch_api_data(icon="✒️", url=url, params={})
|
|
|
|
@function_tool
|
|
async def admin_proceedings_autocomplete(params: AdminProceedingsAutocomplete) -> dict:
|
|
"""
|
|
Fetch autocomplete suggestions for administrative proceeding search terms.
|
|
Args:
|
|
params (AdminProceedingsAutocomplete): Parameters for autocomplete query (e.g., partial text).
|
|
Returns:
|
|
dict: Suggested values matching the input query.
|
|
"""
|
|
url = f"{JUSTICE_API_BASE}/v1/spravneKonanie/autocomplete"
|
|
|
|
return await fetch_api_data(icon="✒️", url=url, params=params.model_dump(exclude_none=True))
|
|
|
|
ALL_TOOLS = [
|
|
court_search, court_id, court_autocomplete,
|
|
judge_search, judge_id, judge_autocomplete,
|
|
decision_search, decision_id, decision_autocomplete,
|
|
contract_search, contract_id, contract_autocomplete,
|
|
civil_proceedings_search, civil_proceedings_id, civil_proceedings_autocomplete,
|
|
admin_proceedings_search, admin_proceedings_id, admin_proceedings_autocomplete,
|
|
] |