Skip to content

Commit

Permalink
Merge pull request #2426 from hlohaus/model
Browse files Browse the repository at this point in the history
Fix start api without port argument
  • Loading branch information
hlohaus authored Nov 25, 2024
2 parents f01f679 + 0eb1d3e commit f0308ab
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion g4f/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class Annotated:

logger = logging.getLogger(__name__)

DEFAULT_PORT = 1337

def create_app(g4f_api_key: str = None):
app = FastAPI()

Expand Down Expand Up @@ -493,7 +495,7 @@ def format_exception(e: Union[Exception, str], config: Union[ChatCompletionsConf

def run_api(
host: str = '0.0.0.0',
port: int = 1337,
port: int = None,
bind: str = None,
debug: bool = False,
workers: int = None,
Expand All @@ -505,6 +507,8 @@ def run_api(
use_colors = debug
if bind is not None:
host, port = bind.split(":")
if port is None:
port = DEFAULT_PORT
uvicorn.run(
f"g4f.api:create_app{'_debug' if debug else ''}",
host=host,
Expand Down

0 comments on commit f0308ab

Please sign in to comment.