Spaces:
Sleeping
Sleeping
Add Swagger UI static files and update api.py to serve them
Browse files- api.py +5 -2
- config.yaml +1 -1
- swagger/swagger-ui-bundle.js +2 -0
- swagger/swagger-ui.css +2 -0
api.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
from fastapi import FastAPI
|
|
|
2 |
from fastapi.middleware.cors import CORSMiddleware
|
3 |
from litellm.proxy.proxy_server import app as proxy_app
|
4 |
|
5 |
-
# Create FastAPI app
|
6 |
app = FastAPI(
|
7 |
title="LiteLLM API",
|
8 |
version="1.0.0",
|
@@ -18,7 +18,10 @@ app.add_middleware(
|
|
18 |
allow_headers=["*"],
|
19 |
)
|
20 |
|
21 |
-
# Mount
|
|
|
|
|
|
|
22 |
app.mount("/proxy", proxy_app)
|
23 |
|
24 |
@app.get("/health")
|
|
|
1 |
from fastapi import FastAPI
|
2 |
+
from fastapi.staticfiles import StaticFiles
|
3 |
from fastapi.middleware.cors import CORSMiddleware
|
4 |
from litellm.proxy.proxy_server import app as proxy_app
|
5 |
|
|
|
6 |
app = FastAPI(
|
7 |
title="LiteLLM API",
|
8 |
version="1.0.0",
|
|
|
18 |
allow_headers=["*"],
|
19 |
)
|
20 |
|
21 |
+
# Mount static files
|
22 |
+
app.mount("/swagger", StaticFiles(directory="swagger"), name="swagger")
|
23 |
+
|
24 |
+
# Mount the LiteLLM Proxy server at /proxy path
|
25 |
app.mount("/proxy", proxy_app)
|
26 |
|
27 |
@app.get("/health")
|
config.yaml
CHANGED
@@ -5,7 +5,7 @@ model_list:
|
|
5 |
|
6 |
general_settings:
|
7 |
master_key: "sk-1234"
|
8 |
-
port:
|
9 |
# Enable UI dashboard
|
10 |
ui_features:
|
11 |
analytics_dashboard: true
|
|
|
5 |
|
6 |
general_settings:
|
7 |
master_key: "sk-1234"
|
8 |
+
port: 8000 # Changed to 8080 for Hugging Face spaces
|
9 |
# Enable UI dashboard
|
10 |
ui_features:
|
11 |
analytics_dashboard: true
|
swagger/swagger-ui-bundle.js
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
/* swagger-ui-bundle.js */
|
2 |
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.SwaggerUIBundle=t():e.SwaggerUIBundle=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t){"use strict"}])});
|
swagger/swagger-ui.css
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
/* swagger-ui.css */
|
2 |
+
.swagger-ui{-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:rgba(0,0,0,0);box-sizing:border-box;color:#3b4151;font-family:sans-serif;font-size:14px;line-height:1.42857143}.swagger-ui *,.swagger-ui :after,.swagger-ui :before{box-sizing:inherit}.swagger-ui a{background-color:transparent;color:#4990e2;text-decoration:none}.swagger-ui a:active,.swagger-ui a:hover{outline:0}.swagger-ui strong{font-weight:700}.swagger-ui img{border:0;vertical-align:middle}.swagger-ui button,.swagger-ui input,.swagger-ui optgroup,.swagger-ui select,.swagger-ui textarea{color:inherit;font:inherit;margin:0}.swagger-ui button{overflow:visible}.swagger-ui button,.swagger-ui select{text-transform:none}.swagger-ui button,.swagger-ui html input[type=button],.swagger-ui input[type=reset],.swagger-ui input[type=submit]{-webkit-appearance:button;cursor:pointer}.swagger-ui button[disabled],.swagger-ui html input[disabled]{cursor:default}.swagger-ui button::-moz-focus-inner,.swagger-ui input::-moz-focus-inner{border:0;padding:0}.swagger-ui input{line-height:normal}.swagger-ui input[type=checkbox],.swagger-ui input[type=radio]{box-sizing:border-box;padding:0}.swagger-ui input[type=number]::-webkit-inner-spin-button,.swagger-ui input[type=number]::-webkit-outer-spin-button{height:auto}.swagger-ui input[type=search]{-webkit-appearance:textfield;box-sizing:content-box}.swagger-ui input[type=search]::-webkit-search-cancel-button,.swagger-ui input[type=search]::-webkit-search-decoration{-webkit-appearance:none}.swagger-ui textarea{overflow:auto}.swagger-ui optgroup{font-weight:700}.swagger-ui table{border-collapse:collapse;border-spacing:0}.swagger-ui td,.swagger-ui th{padding:0}
|