11import os
22import uuid
33import yaml
4- from fastapi import FastAPI , Request , HTTPException , File , Form , UploadFile
5- from fastapi .responses import JSONResponse , StreamingResponse
64import logging
7- from slowapi import Limiter
8- from slowapi .util import get_remote_address
95import time
106import json
117import asyncio
128
9+ from fastapi import FastAPI , Request , HTTPException , File , Form , UploadFile
10+ from fastapi .responses import JSONResponse , StreamingResponse
1311from backend import (
14- TestBackend ,
1512 OpenAIProxyBackend ,
1613 LlmClientBackend ,
1714 VisionModelBackend ,
3431logger = logging .getLogger ("api" )
3532
3633app = FastAPI (title = "OpenAI Compatible API Server" )
37- limiter = Limiter (key_func = get_remote_address )
3834
3935class Config :
4036 def __init__ (self ):
@@ -113,9 +109,7 @@ async def chat_completions(request: Request, body: ChatCompletionRequest):
113109 detail = f"Unsupported model: { body .model } "
114110 )
115111
116- try :
117- print (f"Received request: { body .model_dump ()} " )
118-
112+ try :
119113 if body .stream :
120114 chunk_generator = await backend .generate (body )
121115 if not chunk_generator :
@@ -133,7 +127,6 @@ async def format_stream():
133127 chunk_dict = chunk .model_dump ()
134128
135129 json_chunk = json .dumps (chunk_dict , ensure_ascii = False )
136- print (f"Sending chunk: { json_chunk } " )
137130 yield f"data: { json_chunk } \n \n "
138131 except asyncio .CancelledError :
139132 logger .warning ("Client disconnected early, terminating inference..." )
@@ -150,7 +143,6 @@ async def format_stream():
150143 )
151144 else :
152145 response = await backend .generate (body )
153- print (f"Sending response: { response } " )
154146 return JSONResponse (content = response )
155147
156148 except HTTPException as he :
0 commit comments