File size: 495 Bytes
6f871b6
 
 
283e868
6f871b6
f2ba221
6f871b6
 
f2ba221
6f871b6
 
f2ba221
6f871b6
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from fastapi import FastAPI
from pydantic import BaseModel
from transformers import pipeline

app = FastAPI()

# Charger le modèle hébergé sur Hugging Face
chatbot = pipeline("text-generation", model="fatmata/psybot")  # Remplace par ton modèle

class UserInput(BaseModel):
    text: str

@app.post("/chatbot/")
async def generate_response(user_input: UserInput):
    response = chatbot(user_input.text, max_length=100, do_sample=True)[0]["generated_text"]
    return {"response": response}