File size: 717 Bytes
106db30 fb5554d 25a22d9 106db30 ad8faaf 106db30 883ba9d ad8faaf ab7097f 106db30 fb5554d 25a22d9 106db30 25a22d9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
from llama_cpp.server.app import create_app, Settings
from fastapi.responses import HTMLResponse
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import RedirectResponse
import os
model_path = "/home/user/model/gguf-model.gguf"
app = create_app(
Settings(
n_threads=4,
model=model_path,
embedding=True,
n_gpu_layers=33
)
)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/")
async def redirect_root_to_docs():
return RedirectResponse("/docs")
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=7860)
|