Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
from fastapi import FastAPI
|
2 |
-
|
3 |
|
4 |
-
|
5 |
-
|
6 |
|
7 |
app = FastAPI()
|
8 |
|
@@ -12,4 +12,10 @@ def greet_json():
|
|
12 |
|
13 |
@app.get("/message?input={0}")
|
14 |
def message(req):
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from fastapi import FastAPI
|
2 |
+
from transformers import AutoModel, AutoTokenizer
|
3 |
|
4 |
+
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-0.6B")
|
5 |
+
model = AutoModel.from_pretrained("Qwen/Qwen3-0.6B")
|
6 |
|
7 |
app = FastAPI()
|
8 |
|
|
|
12 |
|
13 |
@app.get("/message?input={0}")
|
14 |
def message(req):
|
15 |
+
inputs = tokenizer(req.query.input, return_tensors="pt", padding=True, truncation=True)
|
16 |
+
output = model.generate(
|
17 |
+
input_ids=inputs["input_ids"],
|
18 |
+
attention_mask=inputs["attention_mask"],
|
19 |
+
temperature=0.3
|
20 |
+
)
|
21 |
+
return tokenizer.decode(output[0], skip_special_tokens=True)
|