Spaces:
Runtime error
Runtime error
Delete server.py
Browse files
server.py
DELETED
|
@@ -1,21 +0,0 @@
|
|
| 1 |
-
from fastapi import FastAPI
|
| 2 |
-
from pydantic import BaseModel
|
| 3 |
-
import torch
|
| 4 |
-
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 5 |
-
|
| 6 |
-
app = FastAPI()
|
| 7 |
-
|
| 8 |
-
# Charge le modèle
|
| 9 |
-
model_name = "fatmata/psybot/psybot_model" # Remplace par ton repo si différent
|
| 10 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 11 |
-
model = AutoModelForCausalLM.from_pretrained(model_name)
|
| 12 |
-
|
| 13 |
-
class Message(BaseModel):
|
| 14 |
-
text: str
|
| 15 |
-
|
| 16 |
-
@app.post("/chat")
|
| 17 |
-
def chat(message: Message):
|
| 18 |
-
inputs = tokenizer(message.text, return_tensors="pt")
|
| 19 |
-
output = model.generate(**inputs, max_length=100)
|
| 20 |
-
response = tokenizer.decode(output[0], skip_special_tokens=True)
|
| 21 |
-
return {"response": response}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|