Abineshkumar77 commited on
Commit
cd2e477
·
1 Parent(s): 4a4f343

Add application file

Browse files
Files changed (1) hide show
  1. app.py +3 -5
app.py CHANGED
@@ -5,7 +5,9 @@ from scipy.special import softmax
5
  from typing import Dict
6
 
7
  # Set the TRANSFORMERS_CACHE environment variable to a writable directory
8
- os.environ["TRANSFORMERS_CACHE"] = "/tmp/.cache"
 
 
9
 
10
  app = FastAPI()
11
 
@@ -38,7 +40,3 @@ def analyze_sentiment(tweet: str) -> Dict[str, float]:
38
  async def analyze_sentiment_endpoint(tweet: str = Query(..., description="The tweet to analyze")):
39
  sentiment_scores = analyze_sentiment(tweet)
40
  return {"sentiment": sentiment_scores}
41
-
42
- # To run the application:
43
- # 1. Save this code as `main.py`.
44
- # 2. Run the command `uvicorn main:app --reload`.
 
5
  from typing import Dict
6
 
7
  # Set the TRANSFORMERS_CACHE environment variable to a writable directory
8
+ cache_dir = "./.cache"
9
+ os.makedirs(cache_dir, exist_ok=True)
10
+ os.environ["TRANSFORMERS_CACHE"] = cache_dir
11
 
12
  app = FastAPI()
13
 
 
40
  async def analyze_sentiment_endpoint(tweet: str = Query(..., description="The tweet to analyze")):
41
  sentiment_scores = analyze_sentiment(tweet)
42
  return {"sentiment": sentiment_scores}