Spaces:
Build error
Build error
File size: 593 Bytes
695f082 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# app.py
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from chatbot_model import ChatbotModel
# Initialize FastAPI
app = FastAPI()
# Load your model (e.g., "gpt2")
chatbot_model = ChatbotModel("gpt2") # Modify this based on the model you want to use
class ChatRequest(BaseModel):
message: str
@app.post("/chat/")
async def chat(request: ChatRequest):
try:
bot_response = chatbot_model.get_response(request.message)
return {"response": bot_response}
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
|