Update app.py
Browse files
app.py
CHANGED
@@ -37,7 +37,7 @@ class CustomEmbeddingFunction:
|
|
37 |
embeddings = outputs.last_hidden_state.mean(dim=1).squeeze().numpy()
|
38 |
return embeddings
|
39 |
|
40 |
-
|
41 |
sentiment_pipeline = pipeline("sentiment-analysis")
|
42 |
chroma_client = Client(Settings(persist_directory="chromadb_storage"))
|
43 |
embedding_fn = CustomEmbeddingFunction()
|
@@ -83,10 +83,12 @@ def update_google_sheet(transcribed_text, sentiment,objection, recommendations,o
|
|
83 |
st.error(f"Failed to update Google Sheets: {e}")
|
84 |
|
85 |
load_dotenv()
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
|
|
|
|
90 |
model_name = "tabularisai/multilingual-sentiment-analysis"
|
91 |
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
92 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
@@ -104,7 +106,7 @@ def analyze_sentiment(text):
|
|
104 |
|
105 |
print(f"Sentiment Analysis Result: {result}")
|
106 |
|
107 |
-
|
108 |
sentiment_map = {
|
109 |
'Very Negative': "NEGATIVE",
|
110 |
'Negative': "NEGATIVE",
|
|
|
37 |
embeddings = outputs.last_hidden_state.mean(dim=1).squeeze().numpy()
|
38 |
return embeddings
|
39 |
|
40 |
+
|
41 |
sentiment_pipeline = pipeline("sentiment-analysis")
|
42 |
chroma_client = Client(Settings(persist_directory="chromadb_storage"))
|
43 |
embedding_fn = CustomEmbeddingFunction()
|
|
|
83 |
st.error(f"Failed to update Google Sheets: {e}")
|
84 |
|
85 |
load_dotenv()
|
86 |
+
hf_token= os.getenv("huggingface_api_key")
|
87 |
+
# login(token=huggingface_api_key)
|
88 |
+
if not hf_token:
|
89 |
+
raise ValueError("Hugging Face API key not found! Please set the HUGGINGFACE_TOKEN variable.")
|
90 |
+
print(f"API Key Loaded: {hf_token[:5]}****")
|
91 |
+
|
92 |
model_name = "tabularisai/multilingual-sentiment-analysis"
|
93 |
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
94 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
|
|
106 |
|
107 |
print(f"Sentiment Analysis Result: {result}")
|
108 |
|
109 |
+
|
110 |
sentiment_map = {
|
111 |
'Very Negative': "NEGATIVE",
|
112 |
'Negative': "NEGATIVE",
|