File size: 572 Bytes
afbf5e5 df3e017 afbf5e5 edbe376 afbf5e5 25fd5a7 afbf5e5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import configparser
from fastapi import FastAPI
from pydantic import BaseModel
from .SentimentAndIntentionAnalysis import ZeroShotClassifier
# Initialize FastAPI app
app = FastAPI()
# Create Analzer
analyzer = ZeroShotClassifier(model_name='facebook/bart-large-mnli')
class AnalysisResult(BaseModel):
sentiment: str
intention: str
class Text(BaseModel):
text: str
@app.post("/analyze/")
def analyze_text(data: Text):
result = analyzer.analyze_text(data.text)
return AnalysisResult(sentiment=result["sentiment"], intention=result["intention"])
|