Spaces:
Sleeping
Sleeping
Delete main.py
Browse files
main.py
DELETED
@@ -1,37 +0,0 @@
|
|
1 |
-
from fastapi import FastAPI
|
2 |
-
from fastapi.middleware.cors import CORSMiddleware
|
3 |
-
from src.TinyLLama import text_generation
|
4 |
-
from src.classmodels.inputforgeneration import InputForGeneration
|
5 |
-
from src.classmodels.generatedoutput import GeneratedOutput
|
6 |
-
import uvicorn
|
7 |
-
|
8 |
-
app = FastAPI()
|
9 |
-
|
10 |
-
origins = ["*"]
|
11 |
-
|
12 |
-
app.add_middleware(
|
13 |
-
CORSMiddleware,
|
14 |
-
allow_origins=origins,
|
15 |
-
allow_credentials=True,
|
16 |
-
allow_methods=["*"],
|
17 |
-
allow_headers=["*"]
|
18 |
-
)
|
19 |
-
|
20 |
-
@app.get("/cmsai/warmuptextgenerationmodel")
|
21 |
-
def warmupGenerationModel():
|
22 |
-
warmupModelMessage = text_generation.warmupTextGenerationModel()
|
23 |
-
return warmupModelMessage
|
24 |
-
|
25 |
-
@app.post("/cmsai/generatetext")
|
26 |
-
async def generateTextUsingLLama(inputSettings:InputForGeneration) -> GeneratedOutput:
|
27 |
-
try:
|
28 |
-
output = text_generation.generateText(inputSettings)
|
29 |
-
if output is not None:
|
30 |
-
return GeneratedOutput(status_code=200, generated_text=output)
|
31 |
-
else:
|
32 |
-
return GeneratedOutput(status_code=400, message="error when generating text")
|
33 |
-
except Exception as e:
|
34 |
-
return GeneratedOutput(status_code=500, message=str(e))
|
35 |
-
|
36 |
-
if __name__ == "__main__":
|
37 |
-
uvicorn.run(app=app)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|