Spaces:
Runtime error
Runtime error
macrdel
commited on
Commit
·
2d22f21
1
Parent(s):
593cc35
update api.py
Browse files- app/api.py +3 -3
app/api.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from config import config
|
| 2 |
from app.src.src import pipeline_sentiment, pipeline_stats, pipeline_summarize
|
| 3 |
|
| 4 |
from fastapi import FastAPI
|
|
@@ -10,7 +10,7 @@ import os
|
|
| 10 |
|
| 11 |
# sentiment_model = pipeline(model=config.sentiment_model)
|
| 12 |
# sum_model = pipeline(model=config.sum_model, use_fast=True)
|
| 13 |
-
headers = {"Authorization": f"Bearer {
|
| 14 |
SENT_API_URL = f"https://api-inference.huggingface.co/models/{config.sentiment_model}"
|
| 15 |
SUM_API_URL = f"https://api-inference.huggingface.co/models/{config.sum_model}"
|
| 16 |
|
|
@@ -25,7 +25,7 @@ def read_root():
|
|
| 25 |
|
| 26 |
@app.post('/comments')
|
| 27 |
def get_comments(url_video: YouTubeUrl):
|
| 28 |
-
data = pipeline_sentiment(url_video.url_video,
|
| 29 |
data.to_csv(f"{config.DATA_FILE}", index=False)
|
| 30 |
return data # {'message': 'Success'}
|
| 31 |
|
|
|
|
| 1 |
+
from config import config
|
| 2 |
from app.src.src import pipeline_sentiment, pipeline_stats, pipeline_summarize
|
| 3 |
|
| 4 |
from fastapi import FastAPI
|
|
|
|
| 10 |
|
| 11 |
# sentiment_model = pipeline(model=config.sentiment_model)
|
| 12 |
# sum_model = pipeline(model=config.sum_model, use_fast=True)
|
| 13 |
+
headers = {"Authorization": f"Bearer {os.environ.get('API_TOKEN')}"}
|
| 14 |
SENT_API_URL = f"https://api-inference.huggingface.co/models/{config.sentiment_model}"
|
| 15 |
SUM_API_URL = f"https://api-inference.huggingface.co/models/{config.sum_model}"
|
| 16 |
|
|
|
|
| 25 |
|
| 26 |
@app.post('/comments')
|
| 27 |
def get_comments(url_video: YouTubeUrl):
|
| 28 |
+
data = pipeline_sentiment(url_video.url_video, os.environ.get("API_KEY"), headers, SENT_API_URL)
|
| 29 |
data.to_csv(f"{config.DATA_FILE}", index=False)
|
| 30 |
return data # {'message': 'Success'}
|
| 31 |
|