Spaces:
Runtime error
Runtime error
Download mods/read_cfg.py from NLPark/llama-python-streamingllm: direct link, hf CLI and curl.
- Browser
- Download file 781 Bytes
-
https://huggingface.co/spaces/NLPark/llama-python-streamingllm/resolve/5827f977a64884b2fb439c99134ce2d0889de949/mods/read_cfg.py
- Command line
-
hf download hf://spaces/NLPark/llama-python-streamingllm@5827f977a64884b2fb439c99134ce2d0889de949/mods/read_cfg.py
-
curl -L -o read_cfg.py https://huggingface.co/spaces/NLPark/llama-python-streamingllm/resolve/5827f977a64884b2fb439c99134ce2d0889de949/mods/read_cfg.py
781 Bytes
| import hashlib | |
| import json | |
| import os | |
| def get_all_files_in_directory(directory, ext=''): | |
| all_files = [] | |
| for root, dirs, files in os.walk(directory): | |
| for file in files: | |
| if file.endswith(ext): | |
| file_path = os.path.join(root, file) | |
| all_files.append(file_path) | |
| return all_files | |
| # ========== 哈希函数 ========== | |
| def x_hash(x: str): | |
| return hashlib.sha1(x.encode('utf-8')).hexdigest() | |
| # ========== 读取配置文件 ========== | |
| with open('rp_config.json', encoding='utf-8') as f: | |
| tmp = f.read() | |
| cfg = json.loads(tmp) | |
| for path in get_all_files_in_directory('config', ext='.json'): | |
| with open(path, encoding='utf-8') as f: | |
| cfg.update(json.load(f)) | |
| cfg['setting_cache_path']['value'] += x_hash(tmp) | |