- JWT middleware для FastAPI - Генерація/перевірка JWT токенів - Скрипти для генерації Qdrant API keys - Скрипти для генерації NATS operator JWT - План реалізації Auth TODO: Додати JWT до endpoints, NATS nkeys config, Qdrant API key config
62 lines
1.7 KiB
Python
62 lines
1.7 KiB
Python
"""
|
|
DAARION Memory Service Configuration
|
|
"""
|
|
from pydantic_settings import BaseSettings
|
|
from functools import lru_cache
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""Application settings"""
|
|
|
|
# Service
|
|
service_name: str = "memory-service"
|
|
debug: bool = False
|
|
|
|
# PostgreSQL
|
|
postgres_host: str = "daarion-pooler.daarion"
|
|
postgres_port: int = 5432
|
|
postgres_user: str = "daarion"
|
|
postgres_password: str = "DaarionDB2026!"
|
|
postgres_db: str = "daarion_main"
|
|
|
|
@property
|
|
def postgres_url(self) -> str:
|
|
return f"postgresql+asyncpg://{self.postgres_user}:{self.postgres_password}@{self.postgres_host}:{self.postgres_port}/{self.postgres_db}"
|
|
|
|
# Qdrant
|
|
qdrant_host: str = "qdrant.qdrant"
|
|
qdrant_port: int = 6333
|
|
qdrant_collection_memories: str = "memories"
|
|
qdrant_collection_messages: str = "messages"
|
|
|
|
# Cohere (embeddings)
|
|
cohere_api_key: str = "" # Must be set via MEMORY_COHERE_API_KEY env var or Vault
|
|
cohere_model: str = "embed-multilingual-v3.0" # 1024 dimensions
|
|
embedding_dimensions: int = 1024
|
|
|
|
# Memory settings
|
|
short_term_window_messages: int = 20
|
|
short_term_window_minutes: int = 60
|
|
summary_trigger_tokens: int = 4000
|
|
summary_target_tokens: int = 500
|
|
retrieval_top_k: int = 10
|
|
|
|
# Confidence thresholds
|
|
memory_min_confidence: float = 0.5
|
|
memory_confirm_boost: float = 0.1
|
|
memory_reject_penalty: float = 0.3
|
|
|
|
# JWT Auth
|
|
jwt_secret: str = "" # Must be set via MEMORY_JWT_SECRET env var or Vault
|
|
jwt_algorithm: str = "HS256"
|
|
jwt_expiration: int = 3600 # 1 година
|
|
|
|
class Config:
|
|
env_prefix = "MEMORY_"
|
|
env_file = ".env"
|
|
|
|
|
|
@lru_cache()
|
|
def get_settings() -> Settings:
|
|
return Settings()
|