28 lines
798 B
Python
28 lines
798 B
Python
from dataclasses import asdict, dataclass
|
|
|
|
|
|
class ToolError(Exception):
|
|
def __init__(self, code):
|
|
self.code = code
|
|
super().__init__(code)
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class ToolLimits:
|
|
"""Operational limits, independent of the versioned request/result format."""
|
|
|
|
max_request_bytes: int = 65536
|
|
max_batch_requests: int = 16
|
|
max_files: int = 64
|
|
max_file_bytes: int = 8 * 1024 * 1024
|
|
max_total_bytes: int = 32 * 1024 * 1024
|
|
max_rows: int = 100000
|
|
max_matches: int = 100
|
|
max_context_lines: int = 200
|
|
max_line_characters: int = 4096
|
|
max_result_bytes: int = 2 * 1024 * 1024
|
|
|
|
def __post_init__(self):
|
|
if any(type(value) is not int or value <= 0 for value in asdict(self).values()):
|
|
raise ToolError("TOOL_LIMIT_CONFIG")
|