File size: 2,637 Bytes
0769ff3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | """
ENGRAM Protocol β API Schemas
Pydantic models for all REST API request/response payloads.
"""
from __future__ import annotations
from pydantic import BaseModel, Field
# ββ Store βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
class StoreRequest(BaseModel):
agent_id: str
task_description: str
model_id: str
compression: str = "q8_0"
class StoreResponse(BaseModel):
cache_id: str
size_bytes: int
compression_ratio: float
path: str
# ββ Retrieve ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
class SearchRequest(BaseModel):
task_description: str
model_id: str | None = None
top_k: int = Field(default=5, ge=1, le=100)
min_similarity: float | None = None
class SearchResultItem(BaseModel):
cache_id: str
similarity: float
task_description: str
model_id: str
created_at: str
context_len: int
class SearchResponse(BaseModel):
results: list[SearchResultItem]
n_searched: int
# ββ Extend ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
class ExtendResponse(BaseModel):
cache_id: str
new_context_len: int
# ββ Delete ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
class DeleteResponse(BaseModel):
deleted: bool
cache_id: str
# ββ Stats βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
class StatsResponse(BaseModel):
total_entries: int
total_size_bytes: int
total_size_mb: float
avg_compression_ratio: float
model_breakdown: dict[str, int]
# ββ Health ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
class HealthResponse(BaseModel):
status: str = "ok"
version: str
index_entries: int
storage_backend: str
|