Files
DraconicDragon-ComfyUI-Veni…/__init__.py
T
draconicdragon e6266cc049 refactor with new API client and config management
my shitty description:
refactor a bunch of stuff
better model loading, removed the stupid js workaround to populating the COMBO fields
removed model loading from js and model fetching from routes/pyserver
unified model/character/styles lists internally as "catalog"

changed textbox in settings to by type: password

replaced primitive requests with client session for better/cleaner/modular request managing, added some better error logging and responses
added dry run env var VENICE_CLIENT_DRY_RUN can be set to 'true' or '1' (it just returns dummy response and doesnt hit the veniceai api)

make __init__.py module/node loading better by loading any .py file with NODE_*_MAPPING in nodes folder instead of hardcoding names

remove old redundant files

AI summarized description with some editing:
- Added `venice_client.py` for handling API requests to VeniceAI.
- Introduced `venice_config.py` for managing API key configuration.
- Created `venice_catalog.py` to manage and cache models, styles, and characters.
- Removed outdated key management logic from `pyserver/get_key_from_jssetting.py`.
- Consolidated character and model update logic into the new catalog management system.
- Move utility functions to `nodes/utils.py` containing validation stuff mostly.
- Removed legacy update scripts for characters, models, and styles.
- Added error handling and logging for API interactions.
- remove obsolete workflow JSON file.
2025-12-12 04:02:43 +01:00

42 lines
1.5 KiB
Python

import importlib
import logging
import os
from pathlib import Path
from .pyserver import routes # noqa: F401
NODE_PACKAGE = Path(__file__).with_name("nodes")
node_list = sorted(
module.stem for module in NODE_PACKAGE.glob("*.py") if module.is_file() and not module.name.startswith("_")
)
NODE_CLASS_MAPPINGS = {}
NODE_DISPLAY_NAME_MAPPINGS = {}
NODE_MODULE_PREFIX = f"{__name__}.nodes"
for module_name in node_list:
try:
imported_module = importlib.import_module(f"{NODE_MODULE_PREFIX}.{module_name}")
except ImportError as e:
logging.warning(f"Could not import module '{module_name}': {e}")
continue
has_classes = hasattr(imported_module, "NODE_CLASS_MAPPINGS")
has_display = hasattr(imported_module, "NODE_DISPLAY_NAME_MAPPINGS")
if has_classes and has_display:
NODE_CLASS_MAPPINGS.update(imported_module.NODE_CLASS_MAPPINGS)
NODE_DISPLAY_NAME_MAPPINGS.update(imported_module.NODE_DISPLAY_NAME_MAPPINGS)
elif has_classes or has_display:
logging.warning(
"Module '%s' defines '%s' but is missing '%s'; module skipped",
module_name,
"NODE_CLASS_MAPPINGS" if has_classes else "NODE_DISPLAY_NAME_MAPPINGS",
"NODE_DISPLAY_NAME_MAPPINGS" if has_classes else "NODE_CLASS_MAPPINGS",
)
# modules without either mapping are ignored silently
WEB_DIRECTORY = os.path.join(os.path.dirname(__file__), "js")
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"]