Mr-Geo commited on
Commit
396bf0d
·
verified ·
1 Parent(s): 16f9d37

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -7,7 +7,7 @@ import torch
7
  from sentence_transformers import CrossEncoder
8
  import gradio as gr
9
  from datetime import datetime
10
- from huggingface_hub import hf_hub_download
11
 
12
  # Load environment variables and initialize clients
13
  load_dotenv()
@@ -15,11 +15,14 @@ GROQ_API_KEY = os.getenv("GROQ_API_KEY")
15
  client = Groq(api_key=GROQ_API_KEY)
16
  DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
17
 
 
 
 
18
  def load_chroma_db():
19
  # Load from Hugging Face dataset
20
  print("Using ChromaDB from Hugging Face dataset...")
21
- # Download the database file from Hugging Face
22
- db_file_path = hf_hub_download(repo_id="Mr-Geo/chroma_db", filename="chroma.sqlite3")
23
  # Initialize your ChromaDB with the downloaded file
24
  db = chromadb.Client(path=db_file_path)
25
  return db
 
7
  from sentence_transformers import CrossEncoder
8
  import gradio as gr
9
  from datetime import datetime
10
+ from huggingface_hub import hf_hub_download, HfApi
11
 
12
  # Load environment variables and initialize clients
13
  load_dotenv()
 
15
  client = Groq(api_key=GROQ_API_KEY)
16
  DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
17
 
18
+ # Get the token from environment variables
19
+ hf_token = os.getenv("HF_TOKEN")
20
+
21
  def load_chroma_db():
22
  # Load from Hugging Face dataset
23
  print("Using ChromaDB from Hugging Face dataset...")
24
+ # Download the database file from Hugging Face with authentication
25
+ db_file_path = hf_hub_download(repo_id="Mr-Geo/chroma_db", filename="chroma.sqlite3", use_auth_token=hf_token)
26
  # Initialize your ChromaDB with the downloaded file
27
  db = chromadb.Client(path=db_file_path)
28
  return db