-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
41 lines (36 loc) · 1.47 KB
/
server.py
File metadata and controls
41 lines (36 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import logging
import os
import sys
from agentuity import autostart
from config import config
if __name__ == "__main__":
# Check if AGENTUITY_API_KEY is set
if not os.environ.get("AGENTUITY_API_KEY") and not os.environ.get("AGENTUITY_SDK_KEY"):
print(
"\033[31m[ERROR] AGENTUITY_API_KEY or AGENTUITY_SDK_KEY is not set. This should have been set automatically by the Agentuity CLI or picked up from the .env file.\033[0m"
)
if os.environ.get("_", "").endswith("uv") and os.path.exists(".env"):
print(
"\033[31m[ERROR] Re-run the command with `uv run --env-file .env server.py`\033[0m"
)
sys.exit(1)
# Check if AGENTUITY_URL is set
if not os.environ.get("AGENTUITY_URL"):
print(
"\033[31m[WARN] You are running this agent outside of the Agentuity environment. Any automatic Agentuity features will be disabled.\033[0m"
)
print(
"\033[31m[WARN] Recommend running `agentuity dev` to run your project locally instead of python script.\033[0m"
)
logging.basicConfig(
level=logging.INFO,
format="[%(levelname)-5.5s] %(message)s",
)
# Validate DMARC-specific configuration
config_errors = config.validate()
if config_errors:
print("\033[31m[ERROR] Configuration validation failed:\033[0m")
for error in config_errors:
print(f" - {error}")
sys.exit(1)
autostart()