Add files via upload

initial commit
This commit is contained in:
Alpha Nerd 2026-03-06 15:54:47 +01:00 committed by GitHub
parent 8d3d5ff628
commit b33bb415dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 4840 additions and 0 deletions

50
tests/conftest.py Normal file
View file

@ -0,0 +1,50 @@
"""Pytest configuration and fixtures for prompt-cache tests."""
import time
import pytest
from semantic_llm_cache.backends import MemoryBackend
from semantic_llm_cache.config import CacheConfig, CacheEntry
@pytest.fixture
def backend():
"""Provide a fresh memory backend for each test."""
return MemoryBackend()
@pytest.fixture
def cache_config():
"""Provide default cache configuration."""
return CacheConfig()
@pytest.fixture
def sample_entry():
"""Provide a sample cache entry."""
return CacheEntry(
prompt="What is Python?",
response="Python is a programming language.",
embedding=[0.1, 0.2, 0.3],
created_at=time.time(), # Use current time
ttl=3600,
namespace="default",
hit_count=0,
)
@pytest.fixture
def mock_llm_func():
"""Provide a mock LLM function."""
responses = {
"What is Python?": "Python is a programming language.",
"What's Python?": "Python is a programming language.",
"Explain Python": "Python is a high-level programming language.",
"What is Rust?": "Rust is a systems programming language.",
}
def _func(prompt: str) -> str:
return responses.get(prompt, f"Response to: {prompt}")
return _func