tabby/server/app.py

25 lines
638 B
Python
Raw Normal View History

2023-03-20 14:57:29 +00:00
import os
2023-03-20 14:12:05 +00:00
import uvicorn
from fastapi import FastAPI, Response
from fastapi.responses import JSONResponse
from models import CompletionsRequest, CompletionsResponse
2023-03-20 14:57:29 +00:00
from triton import TritonService
2023-03-20 14:12:05 +00:00
app = FastAPI(
title="TabbyServer",
description="TabbyServer is the backend for tabby, serving code completion requests from code editor / IDE.",
docs_url="/",
)
2023-03-20 14:57:29 +00:00
triton = TritonService(os.environ["TOKENIZER_NAME"])
2023-03-20 14:12:05 +00:00
@app.post("/v1/completions")
async def completions(data: CompletionsRequest) -> CompletionsResponse:
2023-03-20 14:57:29 +00:00
return triton(data)
2023-03-20 14:12:05 +00:00
if __name__ == "__main__":
uvicorn.run("app:app", host="0.0.0.0", port=5000)