-
Notifications
You must be signed in to change notification settings - Fork 95
Expand file tree
/
Copy pathmain.py
More file actions
40 lines (31 loc) · 962 Bytes
/
main.py
File metadata and controls
40 lines (31 loc) · 962 Bytes
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
"""
架构入口:启动 FastAPI 服务,baseUrl 为 http://ip:port/{type}/v1/...
示例:http://127.0.0.1:8000/claude/v1/chat/completions
"""
# 尽早设置,让 Chromium 派生的 Node 子进程继承,抑制 url.parse 等 DeprecationWarning
import os
import logging
import sys
import uvicorn
from core.config.settings import get, load_config
load_config()
_opt = os.environ.get("NODE_OPTIONS", "").strip()
if "--no-deprecation" not in _opt:
os.environ["NODE_OPTIONS"] = (_opt + " --no-deprecation").strip()
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(message)s",
datefmt="%H:%M:%S",
)
def main() -> int:
host = str(get("server", "host") or "127.0.0.1").strip() or "127.0.0.1"
port = int(get("server", "port") or 9000)
uvicorn.run(
"core.app:app",
host=host,
port=port,
reload=False,
)
return 0
if __name__ == "__main__":
sys.exit(main())