bhagyabonam commited on
Commit
7d67939
·
verified ·
1 Parent(s): ec64d06

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
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
- # Initialize components
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
- huggingface_api_key= os.getenv("HUGGINGFACE_TOKEN")
87
- if not huggingface_api_key:
88
- st.error("Hugging Face API key not found. Please set the HUGGINGFACE_TOKEN environment variable.")
89
- st.stop()
 
 
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
- # Map raw labels to sentiments
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",