feat: Add mock module creation for py/nodes directory to prevent loading modules from the nodes directory

This commit is contained in:
Will Miao
2025-06-30 20:19:37 +08:00
parent afe23ad6b7
commit cad5fb3fba
8 changed files with 51 additions and 32 deletions

View File

@@ -1,8 +1,29 @@
from difflib import SequenceMatcher
import requests
import tempfile
import re
import os
from bs4 import BeautifulSoup
from ..services.service_registry import ServiceRegistry
from ..config import config
async def get_lora_info(lora_name):
"""Get the lora path and trigger words from cache"""
scanner = await ServiceRegistry.get_lora_scanner()
cache = await scanner.get_cached_data()
for item in cache.raw_data:
if item.get('file_name') == lora_name:
file_path = item.get('file_path')
if file_path:
for root in config.loras_roots:
root = root.replace(os.sep, '/')
if file_path.startswith(root):
relative_path = os.path.relpath(file_path, root).replace(os.sep, '/')
# Get trigger words from civitai metadata
civitai = item.get('civitai', {})
trigger_words = civitai.get('trainedWords', []) if civitai else []
return relative_path, trigger_words
return lora_name, []
def download_twitter_image(url):
"""Download image from a URL containing twitter:image meta tag