mirror of
https://github.com/GoodStartLabs/AI_Diplomacy.git
synced 2026-04-26 17:13:19 +00:00
WIP: Can play with bots using old frontend, and multi_bot_launcher
This is a very fragile first pass. There are no messages sent, and sometimes the bots die without warning. But, you'll get a few good turns in before they do and during that time, it's truly glorious.
This commit is contained in:
parent
a05ca5d0df
commit
02a3ef8d38
10 changed files with 139 additions and 730 deletions
|
|
@ -1,7 +1,52 @@
|
|||
from os.path import exists
|
||||
from pydantic_settings import BaseSettings
|
||||
from pathlib import Path
|
||||
import warnings
|
||||
|
||||
|
||||
class Configuration(BaseSettings):
|
||||
DEBUG: bool = False
|
||||
log_file_path: Path = Path("./logs/")
|
||||
log_file_path: Path = Path("./logs/logs.txt")
|
||||
DEEPSEEK_API_KEY: str | None = None
|
||||
OPENAI_API_KEY: str | None = None
|
||||
ANTHROPIC_API_KEY: str | None = None
|
||||
GEMINI_API_KEY: str | None = None
|
||||
OPENROUTER_API_KEY: str | None = None
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
# Make the path absolute, gets rid of weirdness of calling this in different places
|
||||
self.log_file_path = self.log_file_path.resolve()
|
||||
self.log_file_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
self.log_file_path.touch(exist_ok=True)
|
||||
|
||||
self._validate_api_keys()
|
||||
|
||||
def _validate_api_keys(self):
|
||||
"""Validate API keys at startup and issue warnings for missing keys"""
|
||||
api_keys = [
|
||||
"DEEPSEEK_API_KEY",
|
||||
"OPENAI_API_KEY",
|
||||
"ANTHROPIC_API_KEY",
|
||||
"GEMINI_API_KEY",
|
||||
"OPENROUTER_API_KEY",
|
||||
]
|
||||
|
||||
for key in api_keys:
|
||||
value = super().__getattribute__(key)
|
||||
if not value or (isinstance(value, str) and len(value) == 0):
|
||||
warnings.warn(f"API key '{key}' is not set or is empty", UserWarning)
|
||||
|
||||
def __getattribute__(self, name):
|
||||
"""Override to check for empty API keys at access time"""
|
||||
value = super().__getattribute__(name)
|
||||
|
||||
if name.endswith("_KEY") and (
|
||||
not value or (isinstance(value, str) and len(value) == 0)
|
||||
):
|
||||
raise ValueError(
|
||||
f"API key '{name}' is not set or is empty. Please configure it before use."
|
||||
)
|
||||
|
||||
return value
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue