mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-15 03:04:44 +08:00
feat: Implement Milvus retriver for RAG (#516)
* feat: Implement MilvusRetriever with embedding model and resource management * chore: Update configuration and loader files for consistency * chore: Clean up test_milvus.py for improved readability and organization * feat: Add tests for DashscopeEmbeddings query and document embedding methods * feat: Add tests for embedding model initialization and example file loading in MilvusProvider * chore: Remove unused imports and clean up test_milvus.py for better readability * chore: Clean up test_milvus.py for improved readability and organization * chore: Clean up test_milvus.py for improved readability and organization * fix: replace print statements with logging in recursion limit function * Implement feature X to enhance user experience and optimize performance * refactor: clean up unused imports and comments in AboutTab component * Implement feature X to enhance user experience and fix bug Y in module Z --------- Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
This commit is contained in:
@@ -10,36 +10,10 @@ from langchain_core.runnables import RunnableConfig
|
||||
|
||||
from src.config.report_style import ReportStyle
|
||||
from src.rag.retriever import Resource
|
||||
from src.config.loader import get_str_env, get_int_env, get_bool_env
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
_TRUTHY = {"1", "true", "yes", "y", "on"}
|
||||
|
||||
|
||||
def get_bool_env(name: str, default: bool = False) -> bool:
|
||||
val = os.getenv(name)
|
||||
if val is None:
|
||||
return default
|
||||
return str(val).strip().lower() in _TRUTHY
|
||||
|
||||
|
||||
def get_str_env(name: str, default: str = "") -> str:
|
||||
val = os.getenv(name)
|
||||
return default if val is None else str(val).strip()
|
||||
|
||||
|
||||
def get_int_env(name: str, default: int = 0) -> int:
|
||||
val = os.getenv(name)
|
||||
if val is None:
|
||||
return default
|
||||
try:
|
||||
return int(val.strip())
|
||||
except ValueError:
|
||||
logger.warning(
|
||||
f"Invalid integer value for {name}: {val}. Using default {default}."
|
||||
)
|
||||
return default
|
||||
|
||||
|
||||
def get_recursion_limit(default: int = 25) -> int:
|
||||
"""Get the recursion limit from environment variable or use default.
|
||||
|
||||
@@ -7,6 +7,29 @@ from typing import Any, Dict
|
||||
import yaml
|
||||
|
||||
|
||||
def get_bool_env(name: str, default: bool = False) -> bool:
|
||||
val = os.getenv(name)
|
||||
if val is None:
|
||||
return default
|
||||
return str(val).strip().lower() in {"1", "true", "yes", "y", "on"}
|
||||
|
||||
|
||||
def get_str_env(name: str, default: str = "") -> str:
|
||||
val = os.getenv(name)
|
||||
return default if val is None else str(val).strip()
|
||||
|
||||
|
||||
def get_int_env(name: str, default: int = 0) -> int:
|
||||
val = os.getenv(name)
|
||||
if val is None:
|
||||
return default
|
||||
try:
|
||||
return int(val.strip())
|
||||
except ValueError:
|
||||
print(f"Invalid integer value for {name}: {val}. Using default {default}.")
|
||||
return default
|
||||
|
||||
|
||||
def replace_env_vars(value: str) -> str:
|
||||
"""Replace environment variables in string values."""
|
||||
if not isinstance(value, str):
|
||||
|
||||
@@ -24,6 +24,7 @@ SELECTED_SEARCH_ENGINE = os.getenv("SEARCH_API", SearchEngine.TAVILY.value)
|
||||
class RAGProvider(enum.Enum):
|
||||
RAGFLOW = "ragflow"
|
||||
VIKINGDB_KNOWLEDGE_BASE = "vikingdb_knowledge_base"
|
||||
MILVUS = "milvus"
|
||||
|
||||
|
||||
SELECTED_RAG_PROVIDER = os.getenv("RAG_PROVIDER")
|
||||
|
||||
Reference in New Issue
Block a user