Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,11 @@
|
|
1 |
from fastapi import FastAPI
|
2 |
import uvicorn
|
3 |
-
from
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
)
|
10 |
|
11 |
app = FastAPI()
|
12 |
|
@@ -16,8 +15,17 @@ def greet_json():
|
|
16 |
|
17 |
@app.get("/message")
|
18 |
async def message(input: str):
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
return response
|
23 |
|
|
|
1 |
from fastapi import FastAPI
|
2 |
import uvicorn
|
3 |
+
from transformers import AutoTokenizer, AutoModel
|
4 |
|
5 |
+
model_name = "TheBloke/Wizard-Vicuna-13B-Uncensored-GPTQ"
|
6 |
+
|
7 |
+
model = AutoModel.from_pretrained(model_name)
|
8 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
|
|
9 |
|
10 |
app = FastAPI()
|
11 |
|
|
|
15 |
|
16 |
@app.get("/message")
|
17 |
async def message(input: str):
|
18 |
+
inputs = tokenizer(input_text, return_tensors="pt", padding=True, truncation=True)
|
19 |
+
|
20 |
+
output = model.generate(
|
21 |
+
input_ids=inputs["input_ids"],
|
22 |
+
attention_mask=inputs["attention_mask"], # Pass attention_mask!
|
23 |
+
max_new_tokens=100,
|
24 |
+
temperature=0.0, # Disables randomness
|
25 |
+
do_sample=False # Greedy decoding
|
26 |
+
)
|
27 |
+
|
28 |
+
response = tokenizer.decode(output[0], skip_special_tokens=True)
|
29 |
|
30 |
return response
|
31 |
|