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}