feat(dicts): add remote dict management via HuggingFace

Add endpoints for browsing, downloading, and deleting dicts hosted on
HuggingFace. Manifest is fetched and cached from the remote repo to
show available dicts with download status and version comparison.

- /dicts/remote GET: list available dicts from HF manifest
- /dicts/{name}/download POST: download dict from HF with atomic write
- /dicts/{name} DELETE: remove local copy and evict cache
- ItemDictRemote model with downloaded/update_available flags
- Exclude manifest.json from local dict listing in all scan paths
This commit is contained in:
CalamitousFelicitousness
2026-03-24 23:40:23 +00:00
parent 0405689606
commit f3e0b4a86b
3 changed files with 150 additions and 5 deletions
+9
View File
@@ -522,6 +522,15 @@ class ItemDictContent(BaseModel):
categories: dict = Field(default_factory=dict, title="Categories", description="Category definitions with name and color")
tags: list = Field(default_factory=list, title="Tags", description="Tag entries as [name, category_id, post_count] tuples")
class ItemDictRemote(BaseModel):
name: str = Field(title="Name", description="Dictionary identifier")
description: str = Field(default="", title="Description", description="Human-readable description")
version: str = Field(default="", title="Version", description="Version string")
tag_count: int = Field(default=0, title="Tag count", description="Number of tags")
size_mb: float = Field(default=0, title="Size (MB)", description="Approximate file size in megabytes")
downloaded: bool = Field(default=False, title="Downloaded", description="Whether the dict is available locally")
update_available: bool = Field(default=False, title="Update available", description="Whether a newer version exists remotely")
# helper function
def create_model_from_signature(func: Callable, model_name: str, base_model: type[BaseModel] = BaseModel, additional_fields: list | None = None, exclude_fields: list[str] | None = None) -> type[BaseModel]: