ai: add the /api/ai blueprint, the read-only LLM tool catalog
Lean, flat, LLM-shaped read-only endpoints over the library: global,
video, archive, and doc search; paged captions, archive text, and zim
entries; collections, inventories, and a media-directory text reader.
Links are server-computed; big content is paged, never truncated.
This ports the formatting layer from wrolpi_mcp (untouched for now)
into tested code. First phase of ai.md.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-25 21:03:11 -06:00
|
|
|
import dataclasses
|
|
|
|
|
from typing import Optional
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dataclasses.dataclass
|
|
|
|
|
class AISearchRequest:
|
|
|
|
|
search_str: Optional[str] = None
|
|
|
|
|
limit: int = 5
|
|
|
|
|
offset: int = 0
|
|
|
|
|
mimetypes: Optional[list] = None
|
|
|
|
|
tag_names: Optional[list] = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dataclasses.dataclass
|
|
|
|
|
class AIVideoSearchRequest:
|
|
|
|
|
search_str: Optional[str] = None
|
|
|
|
|
limit: int = 5
|
|
|
|
|
offset: int = 0
|
|
|
|
|
channel_id: Optional[int] = None
|
|
|
|
|
tag_names: Optional[list] = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dataclasses.dataclass
|
|
|
|
|
class AIArchiveSearchRequest:
|
|
|
|
|
search_str: Optional[str] = None
|
|
|
|
|
limit: int = 5
|
|
|
|
|
offset: int = 0
|
|
|
|
|
domain: Optional[str] = None
|
|
|
|
|
tag_names: Optional[list] = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dataclasses.dataclass
|
|
|
|
|
class AIDocSearchRequest:
|
|
|
|
|
search_str: Optional[str] = None
|
|
|
|
|
author: Optional[str] = None
|
|
|
|
|
subject: Optional[str] = None
|
|
|
|
|
language: Optional[str] = None
|
|
|
|
|
mimetype: Optional[str] = None
|
|
|
|
|
limit: int = 5
|
|
|
|
|
offset: int = 0
|
|
|
|
|
tag_names: Optional[list] = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dataclasses.dataclass
|
|
|
|
|
class AIZimSearchRequest:
|
|
|
|
|
search_str: Optional[str] = None
|
|
|
|
|
zim_id: Optional[int] = None
|
|
|
|
|
limit: int = 5
|
|
|
|
|
offset: int = 0
|
|
|
|
|
|
|
|
|
|
|
2026-08-25 21:13:59 -06:00
|
|
|
@dataclasses.dataclass
|
|
|
|
|
class AIHelpSearchRequest:
|
|
|
|
|
search_str: Optional[str] = None
|
|
|
|
|
limit: int = 5
|
|
|
|
|
|
|
|
|
|
|
2026-08-25 21:21:34 -06:00
|
|
|
@dataclasses.dataclass
|
|
|
|
|
class AIManageSettingsRequest:
|
|
|
|
|
enabled: Optional[bool] = None
|
|
|
|
|
active_model: Optional[str] = None
|
|
|
|
|
idle_unload_minutes: Optional[int] = None
|
|
|
|
|
context_size: Optional[int] = None
|
|
|
|
|
|
|
|
|
|
|
ai: add the /api/ai blueprint, the read-only LLM tool catalog
Lean, flat, LLM-shaped read-only endpoints over the library: global,
video, archive, and doc search; paged captions, archive text, and zim
entries; collections, inventories, and a media-directory text reader.
Links are server-computed; big content is paged, never truncated.
This ports the formatting layer from wrolpi_mcp (untouched for now)
into tested code. First phase of ai.md.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-25 21:03:11 -06:00
|
|
|
@dataclasses.dataclass
|
|
|
|
|
class AISearchResponse:
|
|
|
|
|
results: list = dataclasses.field(default_factory=list)
|
|
|
|
|
total: int = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dataclasses.dataclass
|
|
|
|
|
class AIPagedTextResponse:
|
|
|
|
|
content: str = ''
|
|
|
|
|
next_offset: Optional[int] = None
|
|
|
|
|
total_chars: int = 0
|