Download helper.py from Ynvers/Game_AI: direct link, hf CLI and curl.
- Browser
- Download file 462 Bytes
-
https://huggingface.co/spaces/Ynvers/Game_AI/resolve/main/helper.py
- Command line
-
hf download hf://spaces/Ynvers/Game_AI/helper.py
-
curl -L -o helper.py https://huggingface.co/spaces/Ynvers/Game_AI/resolve/main/helper.py
462 Bytes
| import os | |
| from dotenv import load_dotenv, find_dotenv | |
| import json | |
| from mistralai import Mistral | |
| def load_env(): | |
| _ = load_dotenv(find_dotenv()) | |
| def load_world(filename): | |
| with open(filename, 'r') as f: | |
| return json.load(f) | |
| def save_world(world): | |
| with open(f'{world["name"]}.json', 'w') as f: | |
| json.dump(world, f) | |
| def get_mistral_api_key(): | |
| load_env() | |
| mistral_api_key = os.getenv("MISTRAL_API_KEY") | |
| return mistral_api_key |