-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.py
More file actions
56 lines (39 loc) · 1.33 KB
/
main.py
File metadata and controls
56 lines (39 loc) · 1.33 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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
from pathlib import Path
from typing import TYPE_CHECKING
from gevent import monkey
monkey.patch_all()
import urllib3 # noqa: E402
# 禁用 HTTPS 证书告警
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
if TYPE_CHECKING:
from src.application import Application
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description="LLM Proxy Service")
parser.add_argument(
"--config", type=str, default=None, help="Configuration file path"
)
return parser.parse_args()
def app() -> "Application":
from src.application import Application
args = parse_args()
config_path = args.config
project_root = Path(__file__).resolve().parent
if config_path is None:
resolved_config_path = project_root / "config.yaml"
else:
config_candidate = Path(config_path)
resolved_config_path = (
config_candidate
if config_candidate.is_absolute()
else (Path.cwd() / config_candidate).resolve()
)
if not resolved_config_path.exists():
raise FileNotFoundError(f"Configuration file not found: {resolved_config_path}")
return Application(resolved_config_path)
def main() -> None:
app().run()
if __name__ == "__main__":
main()