File size: 710 Bytes
39cc8a5
a5dd7cf
823c760
a5b1f33
a5dd7cf
 
39cc8a5
 
 
 
 
 
a5b1f33
65f1222
 
 
a5dd7cf
 
 
 
 
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
from fastapi import FastAPI
from transformers import AutoModel, AutoTokenizer
import uvicorn

tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-0.6B")
model = AutoModel.from_pretrained("Qwen/Qwen3-0.6B")

app = FastAPI()

@app.get("/")
def greet_json():
    return {"Hello": "World!"}

@app.get("/message)
async def message(input: str):
    inputs = tokenizer(input, return_tensors="pt", padding=True, truncation=True)
    output = model.generate(
        input_ids=inputs["input_ids"],
        attention_mask=inputs["attention_mask"],
        temperature=0.3
    )
    return tokenizer.decode(output[0], skip_special_tokens=True)

if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=7860)