Spaces:
Sleeping
Sleeping
Download utils/file.py from Songyou/LLM-fastAPI: direct link, hf CLI and curl.
- Browser
- Download file 693 Bytes
-
https://huggingface.co/spaces/Songyou/LLM-fastAPI/resolve/main/utils/file.py
- Command line
-
hf download hf://spaces/Songyou/LLM-fastAPI/utils/file.py
-
curl -L -o file.py https://huggingface.co/spaces/Songyou/LLM-fastAPI/resolve/main/utils/file.py
693 Bytes
| import os | |
| def make_directory(file, is_dir=True): | |
| dirs = file.split('/')[:-1] if not is_dir else file.split('/') | |
| path = '/' if file.startswith('/') else '' | |
| for dir in dirs: | |
| path = os.path.join(path, dir) | |
| if not os.path.exists(path): | |
| os.makedirs(path) | |
| def get_parent_dir(file): | |
| dirs = file.split('/')[:-1] | |
| path = '' | |
| for dir in dirs: | |
| path = os.path.join(path, dir) | |
| if file.startswith('/'): | |
| path = '/' + path | |
| return path | |
| def chunkIt(seq, num): | |
| avg = len(seq) / float(num) | |
| out = [] | |
| last = 0.0 | |
| while last < len(seq): | |
| out.append(seq[int(last):int(last + avg)]) | |
| last += avg | |
| return out |