Spaces:
Build error
Build error
File size: 656 Bytes
39cc8a5 9481fa2 823c760 a5b1f33 a5dd7cf 9481fa2 39cc8a5 a5b1f33 c6cb00e 65f1222 9481fa2 823c760 73fcf85 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
from fastapi import FastAPI
from transformers import AutoModelForCausalLM, AutoTokenizer
import uvicorn
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-0.6B")
model = AutoModelForCausalLM.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(**inputs, max_length=50, 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) |