diff --git a/src/__init__.py b/src/__init__.py index 4062beb4..6dcf301b 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -3,8 +3,9 @@ from dotenv import load_dotenv load_dotenv("src/.env", override=True) from concurrent.futures import ThreadPoolExecutor # noqa: E402 -from src.config import config # noqa: E402 -from src.knowledge import knowledge_base, graph_base # noqa: E402 +from src.config import config as config # noqa: E402 +from src.knowledge import knowledge_base as knowledge_base # noqa: E402 +from src.knowledge import graph_base as graph_base # noqa: E402 -executor = ThreadPoolExecutor() +executor = ThreadPoolExecutor() # noqa: E402 diff --git a/src/models/__init__.py b/src/models/__init__.py index 9e3ca618..585e9d70 100644 --- a/src/models/__init__.py +++ b/src/models/__init__.py @@ -1,4 +1,4 @@ from src.models.chat_model import select_model, get_custom_model from src.models.embedding import select_embedding_model -__all__ = ['select_model', 'select_embedding_model', 'get_custom_model'] +__all__ = ["select_model", "select_embedding_model", "get_custom_model"] diff --git a/src/plugins/guard.py b/src/plugins/guard.py index 3aa66b34..7f77ae83 100644 --- a/src/plugins/guard.py +++ b/src/plugins/guard.py @@ -1,15 +1,16 @@ import os -from typing import List -def load_keywords(file_path: str) -> List[str]: + +def load_keywords(file_path: str) -> list[str]: """Loads keywords from a file, one per line.""" if not os.path.exists(file_path): keywords = [] - with open(file_path, "r", encoding="utf-8") as f: + with open(file_path, encoding="utf-8") as f: keywords = [line.strip() for line in f if line.strip() and not line.startswith("#")] return keywords + class ContentGuard: def __init__(self, keywords_file: str = "src/static/bad_keywords.txt"): self.keywords = load_keywords(keywords_file) @@ -30,5 +31,6 @@ class ContentGuard: return True return False + # Global instance content_guard = ContentGuard()