Blame view

embeddings/cache_keys.py 443 Bytes
7214c2e7   tangwang   mplemented**
1
2
3
4
5
6
7
8
9
10
11
12
13
  """Shared cache key helpers for embedding inputs."""
  
  from __future__ import annotations
  
  
  def build_text_cache_key(text: str, *, normalize: bool) -> str:
      normalized_text = str(text or "").strip()
      return f"norm:{1 if normalize else 0}:text:{normalized_text}"
  
  
  def build_image_cache_key(url: str, *, normalize: bool) -> str:
      normalized_url = str(url or "").strip()
      return f"norm:{1 if normalize else 0}:image:{normalized_url}"