Spaces:
Build error
Build error
File size: 971 Bytes
d53389b 3481f63 d53389b f7a3082 d53389b f7a3082 d53389b f7a3082 d53389b |
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 |
import fastapi
import uvicorn
from fastapi.middleware.cors import CORSMiddleware
from ctransformers import AutoModelForCausalLM
from pydantic import BaseModel
llm = AutoModelForCausalLM.from_pretrained("TheBloke/WizardLM-7B-V1.0-Uncensored-GGML",
model_file="wizardlm-7b-v1.0-uncensored.ggmlv3.q2_K.bin",
model_type="llama")
app = fastapi.FastAPI(title="WizardLM-7B-V1.0-Uncensored")
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/")
async def index():
return {"message": "Hello World"}
class InferenceRequest(BaseModel):
input: str
@app.post("/inference")
async def inference(request: InferenceRequest):
generated_text = llm(request.input)
return {"generated_text": generated_text}
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000) |