llm_game_hackathon/helper.py
Thomas van der Meer 0a9571de3d Initial commit
2024-11-22 14:20:37 +01:00

21 lines
917 B
Python

# Add your utilities or helper functions to this file.
import os
from dotenv import load_dotenv, find_dotenv
# these expect to find a .env file at the directory above the lesson. # the format for that file is (without the comment) # API_KEYNAME=AStringThatIsTheLongAPIKeyFromSomeService
def load_env():
_ = load_dotenv(find_dotenv())
def save_world(world, filename):
with open(filename, 'w') as f:
json.dump(world, f)
def load_world(filename):
with open(filename, 'r') as f:
return json.load(f)
def get_together_api_key():
load_env()
together_api_key = os.getenv("TOGETHER_API_KEY")
return together_api_key