Spaces:
Build error
Build error
File size: 1,053 Bytes
39cc8a5 823c760 9797205 a5b1f33 5c8939c 97917f4 7d3a416 9797205 7d3a416 39cc8a5 a5b1f33 c6cb00e 65f1222 9797205 97917f4 9797205 97917f4 8a5a310 823c760 73fcf85 |
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 33 34 35 36 37 38 39 40 41 |
from fastapi import FastAPI
import uvicorn
from awq import AutoAWQForCausalLM
from transformers import AutoTokenizer
model_name = "TheBloke/Guanaco-7B-Uncensored-AWQ"
model = AutoAWQForCausalLM.from_quantized(model_name, fuse_layers=True,
trust_remote_code=False, safetensors=True)
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=False)
app = FastAPI()
@app.get("/")
def greet_json():
return {"Hello": "World!"}
@app.get("/message")
async def message(input: str):
prompt=f'''### Human: {input}
### Assistant:
'''
inputs = tokenizer(prompt, return_tensors="pt", padding=True, truncation=True).input_ids.cpu()
output = model.generate(
inputs,
do_sample=True,
temperature=0.7,
top_p=0.95,
top_k=40,
max_new_tokens=512
)
response = tokenizer.decode(output[0], skip_special_tokens=True)
return response
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=7860) |