mirror of
https://github.com/theroyallab/tabbyAPI.git
synced 2026-04-20 22:38:55 +00:00
API: Add log options for initialization
Make each API log their respective URLs to help inform users. Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import asyncio
|
||||
from typing import Optional
|
||||
import uvicorn
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
@@ -8,12 +9,12 @@ from common import config
|
||||
from common.logger import UVICORN_LOG_CONFIG
|
||||
from common.networking import get_global_depends
|
||||
from common.utils import unwrap
|
||||
from endpoints.Kobold import router as KoboldRouter
|
||||
from endpoints.OAI import router as OAIRouter
|
||||
from endpoints.core.router import router as CoreRouter
|
||||
from endpoints.Kobold.router import router as KoboldRouter
|
||||
from endpoints.OAI.router import router as OAIRouter
|
||||
|
||||
|
||||
def setup_app():
|
||||
def setup_app(host: Optional[str] = None, port: Optional[int] = None):
|
||||
"""Includes the correct routers for startup"""
|
||||
|
||||
app = FastAPI(
|
||||
@@ -43,11 +44,20 @@ def setup_app():
|
||||
# Include the OAI api by default
|
||||
if api_servers:
|
||||
for server in api_servers:
|
||||
server_name = server.lower()
|
||||
if server_name in router_mapping:
|
||||
app.include_router(router_mapping[server_name])
|
||||
selected_server = router_mapping.get(server.lower())
|
||||
|
||||
if selected_server:
|
||||
app.include_router(selected_server.router)
|
||||
|
||||
logger.info(f"Starting {selected_server.api_name} API")
|
||||
for path, url in selected_server.urls.items():
|
||||
formatted_url = url.format(host=host, port=port)
|
||||
logger.info(f"{path}: {formatted_url}")
|
||||
else:
|
||||
app.include_router(OAIRouter)
|
||||
app.include_router(OAIRouter.router)
|
||||
for path, url in OAIRouter.urls.items():
|
||||
formatted_url = url.format(host=host, port=port)
|
||||
logger.info(f"{path}: {formatted_url}")
|
||||
|
||||
# Include core API request paths
|
||||
app.include_router(CoreRouter)
|
||||
@@ -67,11 +77,11 @@ async def start_api(host: str, port: int):
|
||||
|
||||
# TODO: Move OAI API to a separate folder
|
||||
logger.info(f"Developer documentation: http://{host}:{port}/redoc")
|
||||
logger.info(f"Completions: http://{host}:{port}/v1/completions")
|
||||
logger.info(f"Chat completions: http://{host}:{port}/v1/chat/completions")
|
||||
# logger.info(f"Completions: http://{host}:{port}/v1/completions")
|
||||
# logger.info(f"Chat completions: http://{host}:{port}/v1/chat/completions")
|
||||
|
||||
# Setup app
|
||||
app = setup_app()
|
||||
app = setup_app(host, port)
|
||||
|
||||
# Get the current event loop
|
||||
loop = asyncio.get_running_loop()
|
||||
|
||||
Reference in New Issue
Block a user