CoolFace
Apppublic

Limour/llama-python-streamingllm

sourceHugging Facegpl-3.0updated 2y agoView on Hugging Face
1likes
read_cfg.py30 linesDownload Raw Back to mods
1import hashlib2import json3import os4 5 6def get_all_files_in_directory(directory, ext=''):7    all_files = []8    for root, dirs, files in os.walk(directory):9        for file in files:10            if file.endswith(ext):11                file_path = os.path.join(root, file)12                all_files.append(file_path)13    return all_files14 15 16# ========== 哈希函数 ==========17def x_hash(x: str):18    return hashlib.sha1(x.encode('utf-8')).hexdigest()19 20 21# ========== 读取配置文件 ==========22with open('rp_config.json', encoding='utf-8') as f:23    tmp = f.read()24cfg = json.loads(tmp)25for path in get_all_files_in_directory('config', ext='.json'):26    with open(path, encoding='utf-8') as f:27        cfg.update(json.load(f))28cfg['setting_cache_path']['value'] += x_hash(tmp)29 30