File size: 4,393 Bytes
a54fd97 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | """
Runtime configuration for the classic text-only SimpleMem pipeline.
This file is intentionally environment-driven so benchmark runs can inject
credentials without storing secrets in the repository.
"""
from __future__ import annotations
import os
def _get_bool(name: str, default: bool) -> bool:
value = os.getenv(name)
if value is None:
return default
return value.strip().lower() in {"1", "true", "yes", "on"}
def _get_int(name: str, default: int | None) -> int | None:
value = os.getenv(name)
if value is None or value == "":
return default
return int(value)
def _get_optional_str(name: str, default: str | None) -> str | None:
value = os.getenv(name)
if value is None or value == "":
return default
return value
# ============================================================================
# LLM Configuration
# ============================================================================
DASHSCOPE_API_KEY = _get_optional_str("DASHSCOPE_API_KEY", None)
OPENAI_API_KEY = _get_optional_str("OPENAI_API_KEY", DASHSCOPE_API_KEY)
OPENAI_BASE_URL = _get_optional_str(
"OPENAI_BASE_URL",
"https://dashscope.aliyuncs.com/compatible-mode/v1",
)
LLM_MODEL = _get_optional_str("LLM_MODEL", "qwen3-max-2026-01-23")
# ============================================================================
# Embedding Configuration
# ============================================================================
EMBEDDING_MODEL = _get_optional_str("EMBEDDING_MODEL", "text-embedding-v4")
EMBEDDING_DIMENSION = _get_int("EMBEDDING_DIMENSION", None)
EMBEDDING_BATCH_SIZE = _get_int("EMBEDDING_BATCH_SIZE", 8)
# ============================================================================
# Advanced LLM Features
# ============================================================================
ENABLE_THINKING = _get_bool("ENABLE_THINKING", False)
USE_STREAMING = _get_bool("USE_STREAMING", False)
USE_JSON_FORMAT = _get_bool("USE_JSON_FORMAT", True)
LLM_MAX_RETRIES = _get_int("LLM_MAX_RETRIES", 5) or 5
EMBEDDING_MAX_RETRIES = _get_int("EMBEDDING_MAX_RETRIES", 5) or 5
# ============================================================================
# Memory Building Parameters
# ============================================================================
WINDOW_SIZE = _get_int("WINDOW_SIZE", 40) or 40
OVERLAP_SIZE = _get_int("OVERLAP_SIZE", 2) or 0
FAIL_ON_EXTRACTION_ERROR = _get_bool("FAIL_ON_EXTRACTION_ERROR", False)
# ============================================================================
# Retrieval Parameters
# ============================================================================
SEMANTIC_TOP_K = _get_int("SEMANTIC_TOP_K", 25) or 25
KEYWORD_TOP_K = _get_int("KEYWORD_TOP_K", 5) or 5
STRUCTURED_TOP_K = _get_int("STRUCTURED_TOP_K", 5) or 5
# ============================================================================
# Database Configuration
# ============================================================================
LANCEDB_PATH = _get_optional_str("LANCEDB_PATH", "./lancedb_data")
MEMORY_TABLE_NAME = _get_optional_str("MEMORY_TABLE_NAME", "memory_entries")
# ============================================================================
# Parallel / Planning Configuration
# ============================================================================
ENABLE_PARALLEL_PROCESSING = _get_bool("ENABLE_PARALLEL_PROCESSING", False)
MAX_PARALLEL_WORKERS = _get_int("MAX_PARALLEL_WORKERS", 4) or 4
ENABLE_PARALLEL_RETRIEVAL = _get_bool("ENABLE_PARALLEL_RETRIEVAL", False)
MAX_RETRIEVAL_WORKERS = _get_int("MAX_RETRIEVAL_WORKERS", 4) or 4
ENABLE_PLANNING = _get_bool("ENABLE_PLANNING", True)
ENABLE_REFLECTION = _get_bool("ENABLE_REFLECTION", False)
MAX_REFLECTION_ROUNDS = _get_int("MAX_REFLECTION_ROUNDS", 1) or 1
# ============================================================================
# Judge Configuration
# ============================================================================
JUDGE_API_KEY = _get_optional_str("JUDGE_API_KEY", OPENAI_API_KEY)
JUDGE_BASE_URL = _get_optional_str("JUDGE_BASE_URL", OPENAI_BASE_URL)
JUDGE_MODEL = _get_optional_str("JUDGE_MODEL", LLM_MODEL)
JUDGE_ENABLE_THINKING = _get_bool("JUDGE_ENABLE_THINKING", False)
JUDGE_USE_STREAMING = _get_bool("JUDGE_USE_STREAMING", False)
JUDGE_TEMPERATURE = float(os.getenv("JUDGE_TEMPERATURE", "0.3"))
|