Refactor threshold handling to use environment variables and global config settings for oracle, postgres and tidb

This commit is contained in:
yangdx
2025-01-29 23:47:57 +08:00
parent 46c9c7d95b
commit 06647438b2
3 changed files with 15 additions and 6 deletions

View File

@@ -301,12 +301,14 @@ class PGKVStorage(BaseKVStorage):
@dataclass
class PGVectorStorage(BaseVectorStorage):
cosine_better_than_threshold: float = 0.2
cosine_better_than_threshold: float = float(os.getenv("COSINE_THRESHOLD", "0.2"))
db: PostgreSQLDB = None
def __post_init__(self):
self._max_batch_size = self.global_config["embedding_batch_num"]
self.cosine_better_than_threshold = self.global_config.get(
# Use global config value if specified, otherwise use default
config = self.global_config.get("vector_db_storage_cls_kwargs", {})
self.cosine_better_than_threshold = config.get(
"cosine_better_than_threshold", self.cosine_better_than_threshold
)