Spaces:
Runtime error
Runtime error
Download utils.py from zxc4wewewe/agent: direct link, hf CLI and curl.
- Browser
- Download file 617 Bytes
-
https://huggingface.co/spaces/zxc4wewewe/agent/resolve/main/utils.py
- Command line
-
hf download hf://spaces/zxc4wewewe/agent/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/zxc4wewewe/agent/resolve/main/utils.py
617 Bytes
| """ | |
| Utility functions shared across the application | |
| """ | |
| import os | |
| import json | |
| def load_settings(file_path): | |
| """Load settings from a JSON file""" | |
| try: | |
| with open(file_path, 'r', encoding='utf-8') as f: | |
| return json.load(f) | |
| except FileNotFoundError: | |
| return {} | |
| except json.JSONDecodeError: | |
| return {} | |
| def save_settings(file_path, data): | |
| """Save settings to a JSON file""" | |
| os.makedirs(os.path.dirname(file_path), exist_ok=True) | |
| with open(file_path, 'w', encoding='utf-8') as f: | |
| json.dump(data, f, indent=2, ensure_ascii=False) |