mirror of
https://git.mirrors.martin98.com/https://github.com/bytedance/deer-flow
synced 2025-08-20 07:59:07 +08:00
66 lines
1.5 KiB
Python
66 lines
1.5 KiB
Python
# Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
"""
|
|
Server script for running the DeerFlow API.
|
|
"""
|
|
|
|
import argparse
|
|
import logging
|
|
|
|
import uvicorn
|
|
|
|
# Configure logging
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
|
)
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
if __name__ == "__main__":
|
|
# Parse command line arguments
|
|
parser = argparse.ArgumentParser(description="Run the DeerFlow API server")
|
|
parser.add_argument(
|
|
"--reload",
|
|
action="store_true",
|
|
help="Enable auto-reload (default: True except on Windows)",
|
|
)
|
|
parser.add_argument(
|
|
"--host",
|
|
type=str,
|
|
default="localhost",
|
|
help="Host to bind the server to (default: localhost)",
|
|
)
|
|
parser.add_argument(
|
|
"--port",
|
|
type=int,
|
|
default=8000,
|
|
help="Port to bind the server to (default: 8000)",
|
|
)
|
|
parser.add_argument(
|
|
"--log-level",
|
|
type=str,
|
|
default="info",
|
|
choices=["debug", "info", "warning", "error", "critical"],
|
|
help="Log level (default: info)",
|
|
)
|
|
|
|
args = parser.parse_args()
|
|
|
|
# Determine reload setting
|
|
reload = False
|
|
|
|
# Command line arguments override defaults
|
|
if args.reload:
|
|
reload = True
|
|
|
|
logger.info("Starting DeerFlow API server")
|
|
uvicorn.run(
|
|
"src.server:app",
|
|
host=args.host,
|
|
port=args.port,
|
|
reload=reload,
|
|
log_level=args.log_level,
|
|
)
|