kubrabuzlu commited on
Commit
55e4bcb
·
verified ·
1 Parent(s): 87d4800

Delete api.py

Browse files
Files changed (1) hide show
  1. api.py +0 -37
api.py DELETED
@@ -1,37 +0,0 @@
1
- import configparser
2
-
3
- from fastapi import FastAPI
4
- from fastapi.middleware.cors import CORSMiddleware
5
- from pydantic import BaseModel
6
- from SentimentAndIntentionAnalysis import ZeroShotClassifier
7
- from data_loader import *
8
-
9
- # Initialize FastAPI app
10
- app = FastAPI()
11
- app.add_middleware(CORSMiddleware,
12
- allow_origins=["http://localhost:8501"],
13
- allow_credentials=True,
14
- allow_methods=["*"],
15
- allow_headers=["*"],)
16
- #Get model_name, data_path and labels_path
17
- model_name, data_path, labels_path = get_config()
18
-
19
- # Load sentiment labels and intention labels
20
- sentiment_labels, intention_labels = load_labels(labels_path)
21
- # Create Analzer
22
- analyzer = ZeroShotClassifier(model_name=model_name, sentiment_labels=sentiment_labels, intention_labels=intention_labels)
23
-
24
- class AnalysisResult(BaseModel):
25
- sentiment: str
26
- intention: str
27
-
28
- class Text(BaseModel):
29
- text: str
30
-
31
- @app.post("/analyze/")
32
- def analyze_text(data: Text):
33
- result = analyzer.analyze_text(data.text)
34
- return AnalysisResult(sentiment=result["sentiment"], intention=result["intention"])
35
-
36
-
37
-