Spaces:
Sleeping
Sleeping
KrSharangrav
commited on
Commit
·
b83a640
1
Parent(s):
472c7aa
changes made to chatbot and db
Browse files- chatbot.py +3 -0
- db.py +2 -2
chatbot.py
CHANGED
@@ -3,6 +3,9 @@ import streamlit as st
|
|
3 |
import google.generativeai as genai
|
4 |
from transformers import pipeline, AutoModelForSequenceClassification, AutoTokenizer
|
5 |
|
|
|
|
|
|
|
6 |
# 🔑 Fetch API key from Hugging Face Secrets
|
7 |
GEMINI_API_KEY = os.getenv("gemini_api")
|
8 |
|
|
|
3 |
import google.generativeai as genai
|
4 |
from transformers import pipeline, AutoModelForSequenceClassification, AutoTokenizer
|
5 |
|
6 |
+
# Disable HF transfer mechanism to avoid rate limiting errors
|
7 |
+
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "0"
|
8 |
+
|
9 |
# 🔑 Fetch API key from Hugging Face Secrets
|
10 |
GEMINI_API_KEY = os.getenv("gemini_api")
|
11 |
|
db.py
CHANGED
@@ -3,13 +3,13 @@ import requests
|
|
3 |
import io
|
4 |
from pymongo import MongoClient
|
5 |
|
6 |
-
|
7 |
def get_mongo_client():
|
8 |
client = MongoClient("mongodb+srv://groupA:[email protected]/?retryWrites=true&w=majority&appName=SentimentCluster")
|
9 |
db = client["sentiment_db"]
|
10 |
return db["tweets"]
|
11 |
|
12 |
-
|
13 |
def insert_data_if_empty():
|
14 |
collection = get_mongo_client()
|
15 |
|
|
|
3 |
import io
|
4 |
from pymongo import MongoClient
|
5 |
|
6 |
+
# 1. MongoDB Connection
|
7 |
def get_mongo_client():
|
8 |
client = MongoClient("mongodb+srv://groupA:[email protected]/?retryWrites=true&w=majority&appName=SentimentCluster")
|
9 |
db = client["sentiment_db"]
|
10 |
return db["tweets"]
|
11 |
|
12 |
+
# 2. Insert Data If Collection is Empty
|
13 |
def insert_data_if_empty():
|
14 |
collection = get_mongo_client()
|
15 |
|