Spaces:
Running
Running
Wimmboo commited on
Commit ·
10aa100
1
Parent(s): 7abc37b
change API prefix to /api/v1 to avoid HF routing conflict
Browse files- proxy/router.py +5 -5
proxy/router.py
CHANGED
|
@@ -36,7 +36,7 @@ MODELS = {
|
|
| 36 |
}
|
| 37 |
|
| 38 |
|
| 39 |
-
@api.get("/v1/models")
|
| 40 |
async def list_models() -> JSONResponse:
|
| 41 |
data = {
|
| 42 |
"object": "list",
|
|
@@ -53,7 +53,7 @@ async def list_models() -> JSONResponse:
|
|
| 53 |
return JSONResponse(content=data)
|
| 54 |
|
| 55 |
|
| 56 |
-
@api.post("/v1/chat/completions")
|
| 57 |
async def chat_completions(request: Request) -> Response:
|
| 58 |
provider = resolve_provider(request)
|
| 59 |
real_key = get_real_key(provider)
|
|
@@ -80,12 +80,12 @@ async def chat_completions(request: Request) -> Response:
|
|
| 80 |
)
|
| 81 |
|
| 82 |
|
| 83 |
-
@api.get("/v1/health")
|
| 84 |
async def health() -> JSONResponse:
|
| 85 |
return JSONResponse({"status": "ok", "providers": list(PROVIDERS.keys())})
|
| 86 |
|
| 87 |
|
| 88 |
-
@api.get("/v1/keys")
|
| 89 |
async def proxy_keys() -> JSONResponse:
|
| 90 |
masked = {}
|
| 91 |
for name, key in PROVIDER_KEYS.items():
|
|
@@ -101,7 +101,7 @@ def create_app() -> FastAPI:
|
|
| 101 |
|
| 102 |
@app.get("/")
|
| 103 |
async def root():
|
| 104 |
-
return {"message": "OpenAI API Proxy", "docs": "/v1/health"}
|
| 105 |
|
| 106 |
@app.exception_handler(StarletteHTTPException)
|
| 107 |
async def http_exception_handler(_request: Request, exc: StarletteHTTPException) -> JSONResponse:
|
|
|
|
| 36 |
}
|
| 37 |
|
| 38 |
|
| 39 |
+
@api.get("/api/v1/models")
|
| 40 |
async def list_models() -> JSONResponse:
|
| 41 |
data = {
|
| 42 |
"object": "list",
|
|
|
|
| 53 |
return JSONResponse(content=data)
|
| 54 |
|
| 55 |
|
| 56 |
+
@api.post("/api/v1/chat/completions")
|
| 57 |
async def chat_completions(request: Request) -> Response:
|
| 58 |
provider = resolve_provider(request)
|
| 59 |
real_key = get_real_key(provider)
|
|
|
|
| 80 |
)
|
| 81 |
|
| 82 |
|
| 83 |
+
@api.get("/api/v1/health")
|
| 84 |
async def health() -> JSONResponse:
|
| 85 |
return JSONResponse({"status": "ok", "providers": list(PROVIDERS.keys())})
|
| 86 |
|
| 87 |
|
| 88 |
+
@api.get("/api/v1/keys")
|
| 89 |
async def proxy_keys() -> JSONResponse:
|
| 90 |
masked = {}
|
| 91 |
for name, key in PROVIDER_KEYS.items():
|
|
|
|
| 101 |
|
| 102 |
@app.get("/")
|
| 103 |
async def root():
|
| 104 |
+
return {"message": "OpenAI API Proxy", "docs": "/api/v1/health"}
|
| 105 |
|
| 106 |
@app.exception_handler(StarletteHTTPException)
|
| 107 |
async def http_exception_handler(_request: Request, exc: StarletteHTTPException) -> JSONResponse:
|