Coverage for /home/admin/Documents/AI/applications/lexigram-dev/lexigram/experimental/ai/lexigram-ai-llm/src/lexigram/ai/llm/protocols.py: 100%
10 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-25 07:19 +0800
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-25 07:19 +0800
1"""LLM-specific protocols owned by lexigram-ai-llm."""
3from __future__ import annotations
5from typing import Any, Protocol, runtime_checkable
8@runtime_checkable
9class LLMCacheProtocol(Protocol):
10 """Protocol for LLM cache implementations."""
12 async def get(self, key: str | dict[str, Any]) -> Any | None:
13 """Get value from cache.
15 Args:
16 key: Cache key (string or structured dict).
18 Returns:
19 Cached value, or ``None`` if not present.
20 """
21 ...
23 async def set(
24 self,
25 key: str | dict[str, Any],
26 value: Any,
27 ttl: float | None = None,
28 ) -> None:
29 """Set value in cache.
31 Args:
32 key: Cache key (string or structured dict).
33 value: Value to store.
34 ttl: Optional time-to-live in seconds.
35 """
36 ...
38 async def delete(self, key: str | dict[str, Any]) -> bool:
39 """Delete entry from cache.
41 Args:
42 key: Cache key to remove.
44 Returns:
45 ``True`` if the key existed and was removed, ``False`` otherwise.
46 """
47 ...
49 async def clear(self) -> None:
50 """Clear all entries."""
51 ...
53 def get_stats(self) -> dict[str, Any]:
54 """Return cache statistics.
56 Returns:
57 Mapping of statistic name to value.
58 """
59 ...
62__all__ = ["LLMCacheProtocol"]