返回提交历史
Modified
g4f/api/__init__.py
+5
-1
XFEstudio/gpt4free
Fix start api without port argument
0eb1d3ed
代码差异
1 个文件
+5
-1
@@ -48,6 +48,8 @@ from g4f.gui import get_gui_app
48
48
49
49
logger = logging.getLogger(__name__)
50
50
51
DEFAULT_PORT = 1337
52
51
53
def create_app(g4f_api_key: str = None):
52
54
app = FastAPI()
53
55
@@ -493,7 +495,7 @@ def format_exception(e: Union[Exception, str], config: Union[ChatCompletionsConf
493
495
494
496
def run_api(
495
497
host: str = '0.0.0.0',
496
port: int = 1337,
498
port: int = None,
497
499
bind: str = None,
498
500
debug: bool = False,
499
501
workers: int = None,
@@ -505,6 +507,8 @@ def run_api(
505
507
use_colors = debug
506
508
if bind is not None:
507
509
host, port = bind.split(":")
510
if port is None:
511
port = DEFAULT_PORT
508
512
uvicorn.run(
509
513
f"g4f.api:create_app{'_debug' if debug else ''}",
510
514
host=host,