get_act_content
Retrieve full text content of Polish legal acts from Dziennik Ustaw or Monitor Polski in PDF or HTML format for legal research and document analysis.
Instructions
Retrieve the actual text content of a legal act in PDF or HTML format. Use for reading the full document content.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format_type | No | Content format: 'pdf' or 'html' (default: pdf) | |
| num | Yes | Act number/position within the year | |
| publisher | Yes | Publisher code (DU for Dziennik Ustaw, MP for Monitor Polski) | |
| year | Yes | Publication year |
Implementation Reference
- app.py:527-579 (handler)The handler function `get_act_text` that implements the `get_act_content` tool logic. It constructs the API URL based on publisher, year, and number, fetches the content in specified format (PDF or HTML), and returns either the PDF download URL or the full HTML text.publisher: Annotated[str, "Publisher code (DU for Dziennik Ustaw, MP for Monitor Polski)"], year: Annotated[int, "Publication year"], num: Annotated[Union[int, str], "Act number/position within the year"], format_type: Annotated[str, "Content format: 'pdf' or 'html' (default: pdf)"] = "pdf" ) -> str: """Fetches the text content of a specific legal act in PDF or HTML format. Retrieves the actual textual content of a legal act for reading and analysis. For PDF format, returns a download URL. For HTML format, returns the full HTML content of the document. Args: publisher: Publication code (e.g., 'DU' for Dziennik Ustaw, 'MP' for Monitor Polski). year: Year of publication as integer. num: Act number/position within the year as integer or string. format_type: Content format - 'pdf' or 'html'. Defaults to 'pdf'. Returns: str: For PDF format, returns download URL string. For HTML format, returns the full HTML content. Returns empty string if content not found or error. Examples: User asks: "Get the PDF text of DU/2020/1280": Parameters: publisher = 'DU', year = 2020, num = 1280, format_type = 'pdf' Returns: "PDF content available at: https://api.sejm.gov.pl/eli/acts/DU/2020/1280/text.pdf" User asks: "Get the HTML text of DU/2020/1": Parameters: publisher = 'DU', year = 2020, num = 1, format_type = 'html' User asks: "Download PDF of act MP/2023/100": Parameters: publisher = 'MP', year = 2023, num = 100, format_type = 'pdf' User asks: "Show me the HTML content of DU/2019/50": Parameters: publisher = 'DU', year = 2019, num = 50, format_type = 'html' User asks: "I need the text of act DU/2022/200 in PDF": Parameters: publisher = 'DU', year = 2022, num = 200, format_type = 'pdf' """ logger.debug(f"get_act_text called with: publisher={publisher}, year={year}, num={num}, format_type={format_type}") try: url = f"https://api.sejm.gov.pl/eli/acts/{publisher}/{year}/{num}/text.{format_type}" logger.debug(f"Making GET request to: {url}") response = requests.get(url) response.raise_for_status() if format_type == "pdf": # For PDF, return download URL since binary content can't be displayed directly result = f"PDF content available at: {url}" logger.info(f"get_act_text retrieved PDF for act: {publisher}/{year}/{num}") return result else: # For HTML, return the actual content logger.info(f"get_act_text retrieved HTML content for act: {publisher}/{year}/{num}") return response.text except Exception as e: logger.error(f"Error: {e}") return ""
- app.py:522-525 (registration)The @app.tool decorator registration for the 'get_act_content' tool, specifying name, description, and tags.name="get_act_content", description="Retrieve the actual text content of a legal act in PDF or HTML format. Use for reading the full document content.", tags={"analysis", "content", "text", "reading"} )
- app.py:527-530 (schema)The function parameters with Annotated type hints defining the input schema for publisher, year, num, and optional format_type, along with return type str.publisher: Annotated[str, "Publisher code (DU for Dziennik Ustaw, MP for Monitor Polski)"], year: Annotated[int, "Publication year"], num: Annotated[Union[int, str], "Act number/position within the year"], format_type: Annotated[str, "Content format: 'pdf' or 'html' (default: pdf)"] = "pdf"