File size: 651 Bytes
38c936b d034337 ff740be 38c936b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#pip install fastapi
#uvicorn main:app --reload
#import gradio as gr
from transformers import pipeline
from fastapi import FastAPI
app = FastAPI()
#generator = pipeline('text-generation',model='gpt2')
#generator = pipeline('text-generation',model='Open-Orca/Mistral-7B-OpenOrca')
generator = pipeline("text-generation", model="lmsys/vicuna-7b-v1.5")
@app.get("/")
async def root():
return {"message": "Hello World"}
#return generator('What is love',max_length=100, num_return_sequences=1)
@app.post("/predict")
async def root(text):
#return {"message": "Hello World"}
return generator(text,max_length=100, num_return_sequences=1) |