This commit is contained in:
Yannick Stephan
2025-02-20 13:44:17 +01:00
parent 4923f5c1d7
commit 8413537ad2
2 changed files with 27 additions and 24 deletions

View File

@@ -135,9 +135,8 @@ STORAGES = {
"QdrantVectorDBStorage": ".kg.qdrant_impl", "QdrantVectorDBStorage": ".kg.qdrant_impl",
} }
def verify_storage_implementation(
storage_type: str, storage_name: str def verify_storage_implementation(storage_type: str, storage_name: str) -> None:
) -> None:
"""Verify if storage implementation is compatible with specified storage type """Verify if storage implementation is compatible with specified storage type
Args: Args:

View File

@@ -8,7 +8,11 @@ from datetime import datetime
from functools import partial from functools import partial
from typing import Any, AsyncIterator, Callable, Iterator, cast, final from typing import Any, AsyncIterator, Callable, Iterator, cast, final
from lightrag.kg import STORAGE_ENV_REQUIREMENTS, STORAGES, verify_storage_implementation from lightrag.kg import (
STORAGE_ENV_REQUIREMENTS,
STORAGES,
verify_storage_implementation,
)
from .base import ( from .base import (
BaseGraphStorage, BaseGraphStorage,
@@ -251,6 +255,10 @@ class LightRAG:
The default function is :func:`.utils.convert_response_to_json`. The default function is :func:`.utils.convert_response_to_json`.
""" """
cosine_better_than_threshold: float = field(
default=float(os.getenv("COSINE_THRESHOLD", 0.2))
)
_storages_status: StoragesStatus = field(default=StoragesStatus.NOT_CREATED) _storages_status: StoragesStatus = field(default=StoragesStatus.NOT_CREATED)
def __post_init__(self): def __post_init__(self):
@@ -278,11 +286,8 @@ class LightRAG:
# self.check_storage_env_vars(storage_name) # self.check_storage_env_vars(storage_name)
# Ensure vector_db_storage_cls_kwargs has required fields # Ensure vector_db_storage_cls_kwargs has required fields
default_vector_db_kwargs = {
"cosine_better_than_threshold": float(os.getenv("COSINE_THRESHOLD", "0.2"))
}
self.vector_db_storage_cls_kwargs = { self.vector_db_storage_cls_kwargs = {
**default_vector_db_kwargs, "cosine_better_than_threshold": self.cosine_better_than_threshold,
**self.vector_db_storage_cls_kwargs, **self.vector_db_storage_cls_kwargs,
} }
@@ -1463,7 +1468,6 @@ class LightRAG:
return result return result
def check_storage_env_vars(self, storage_name: str) -> None: def check_storage_env_vars(self, storage_name: str) -> None:
"""Check if all required environment variables for storage implementation exist """Check if all required environment variables for storage implementation exist