-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
97 lines (81 loc) · 2.6 KB
/
main.py
File metadata and controls
97 lines (81 loc) · 2.6 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
"""
Main entry point for the 3D Scene Agent.
Supports both CLI and API modes.
"""
import argparse
import sys
from scene_agent.env import load_project_dotenv
def main():
"""
Parse arguments and launch the appropriate interface.
"""
load_project_dotenv()
parser = argparse.ArgumentParser(
description="3D Scene Agent - LangGraph-based Blender scene manipulation",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
Examples:
# Run CLI interface
python main.py --mode cli
# Run API server
python main.py --mode api --port 8000
# Run API with custom host
python main.py --mode api --host 0.0.0.0 --port 8080
Requirements:
- Create a .env file with VLM_API_KEY set
- Start the Blender MCP server (localhost:6274)
- Optionally: Start 3D asset retrieval API (localhost:8001)
"""
)
parser.add_argument(
"--mode",
choices=["cli", "api"],
default="cli",
help="Interface mode: 'cli' for command-line or 'api' for REST server (default: cli)"
)
parser.add_argument(
"--host",
default="0.0.0.0",
help="API server host (default: 0.0.0.0, only for api mode)"
)
parser.add_argument(
"--port",
type=int,
default=None,
help="API server port (default: uses API_PORT env var or 8000, only for api mode)"
)
parser.add_argument(
"--workers",
type=int,
default=None,
help="API worker processes (default: uses API_WORKERS env var or 1)"
)
args = parser.parse_args()
# Check for .env file
import os
if not os.path.exists(".env"):
print("⚠️ Warning: .env file not found!")
print(" Create a .env file with VLM_API_KEY set.")
print(" See .env.example for reference.")
print()
# Launch the selected mode
if args.mode == "cli":
print("Starting CLI interface...")
from scene_agent.interfaces.cli import main as cli_main
cli_main()
else:
from scene_agent.config import get_settings
settings = get_settings()
port = args.port if args.port is not None else settings.api_port
print(f"Starting API server on {args.host}:{port}...")
from scene_agent.interfaces.api import run_api
run_api(host=args.host, port=port, workers=args.workers)
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print("\n\nInterrupted by user. Goodbye!")
sys.exit(0)
except Exception as e:
print(f"\n\nFatal error: {e}")
sys.exit(1)