Скелет проекта

This commit is contained in:
2026-01-30 22:21:12 +03:00
commit 84ded7d7a9
30 changed files with 752 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
from __future__ import annotations
import hashlib
from dataclasses import dataclass
from typing import Iterable, Protocol
class EmbeddingClient(Protocol):
def embed_texts(self, texts: Iterable[str]) -> list[list[float]]:
raise NotImplementedError
@dataclass
class StubEmbeddingClient:
dim: int
def embed_texts(self, texts: Iterable[str]) -> list[list[float]]:
vectors: list[list[float]] = []
for text in texts:
digest = hashlib.sha256(text.encode("utf-8")).digest()
values = [b / 255.0 for b in digest]
if len(values) < self.dim:
values = (values * ((self.dim // len(values)) + 1))[: self.dim]
vectors.append(values[: self.dim])
return vectors
def get_embedding_client(dim: int) -> EmbeddingClient:
return StubEmbeddingClient(dim=dim)