Update app.py
Browse files
app.py
CHANGED
|
@@ -113,7 +113,23 @@ async def lifespan(app: FastAPI):
|
|
| 113 |
for w in workers: w.cancel()
|
| 114 |
|
| 115 |
app = FastAPI(lifespan=lifespan)
|
| 116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
|
| 118 |
@app.post("/v1/chat/completions")
|
| 119 |
async def chat(request: Request):
|
|
|
|
| 113 |
for w in workers: w.cancel()
|
| 114 |
|
| 115 |
app = FastAPI(lifespan=lifespan)
|
| 116 |
+
# Tambahkan Middleware CORS dengan benar
|
| 117 |
+
app.add_middleware(
|
| 118 |
+
CORSMiddleware,
|
| 119 |
+
allow_origins=["*"],
|
| 120 |
+
allow_credentials=True,
|
| 121 |
+
allow_methods=["*"],
|
| 122 |
+
allow_headers=["*"],
|
| 123 |
+
)
|
| 124 |
+
|
| 125 |
+
# Endpoint Root untuk Cek Status
|
| 126 |
+
@app.get("/")
|
| 127 |
+
async def root():
|
| 128 |
+
return {
|
| 129 |
+
"status": "AI Gateway Running",
|
| 130 |
+
"models": ["DeepSeek-R1:7b", "Whisper-Tiny"],
|
| 131 |
+
"timestamp": int(time.time())
|
| 132 |
+
}
|
| 133 |
|
| 134 |
@app.post("/v1/chat/completions")
|
| 135 |
async def chat(request: Request):
|