Spaces:
Runtime error
Runtime error
Commit ·
9ac318d
1
Parent(s): fd2fe27
small cleanups
Browse files- .gitattributes +0 -1
- src/compassia.py +9 -10
.gitattributes
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
documents/*.pdf filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
src/compassia.py
CHANGED
|
@@ -30,6 +30,13 @@ import pytesseract
|
|
| 30 |
from FlagEmbedding import BGEM3FlagModel
|
| 31 |
import chromadb
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
# Import configurations and prompt from local modules
|
| 34 |
from config import (
|
| 35 |
DEEPSEEK_API_URL, DEEPSEEK_HEADERS,
|
|
@@ -57,12 +64,11 @@ def initialize_firebase_client():
|
|
| 57 |
if not firebase_admin._apps: # Check if Firebase Admin SDK is already initialized
|
| 58 |
# Determine Firebase config. In deployment, it comes from env vars.
|
| 59 |
# For local __main__ testing, it also uses env vars.
|
| 60 |
-
firebase_config_b64 = os.getenv("FIREBASE_CONFIG_BASE64") # Get from env for both cases
|
| 61 |
|
| 62 |
-
if
|
| 63 |
try:
|
| 64 |
# Decode the Base64-encoded Firebase Service Account JSON
|
| 65 |
-
cred_json = base64.b64decode(
|
| 66 |
cred_dict = json.loads(cred_json)
|
| 67 |
cred = credentials.Certificate(cred_dict)
|
| 68 |
firebase_admin.initialize_app(cred)
|
|
@@ -410,13 +416,6 @@ class DocumentRAG:
|
|
| 410 |
|
| 411 |
# --- Main execution logic for local testing (only runs when script is executed directly) ---
|
| 412 |
if __name__ == "__main__":
|
| 413 |
-
from dotenv import load_dotenv # Import load_dotenv for local execution
|
| 414 |
-
# CRITICAL FIX: Load environment variables for local testing
|
| 415 |
-
load_dotenv(dotenv_path=os.path.join(os.path.dirname(os.path.dirname(__file__)), '.env.local'))
|
| 416 |
-
|
| 417 |
-
# Retrieve FIREBASE_CONFIG_BASE64 after loading dotenv (for local testing only)
|
| 418 |
-
# This value is read from config.py, which in turn reads from .env.local
|
| 419 |
-
from config import FIREBASE_CONFIG_BASE64
|
| 420 |
|
| 421 |
# For local testing, initialize Firebase and capture the instance
|
| 422 |
local_firestore_instance = initialize_firebase_client()
|
|
|
|
| 30 |
from FlagEmbedding import BGEM3FlagModel
|
| 31 |
import chromadb
|
| 32 |
|
| 33 |
+
from dotenv import load_dotenv # Import load_dotenv for local execution
|
| 34 |
+
# CRITICAL FIX: Load environment variables for local testing
|
| 35 |
+
load_dotenv(dotenv_path=os.path.join(os.path.dirname(os.path.dirname(__file__)), '.env.local'))
|
| 36 |
+
|
| 37 |
+
# Retrieve FIREBASE_CONFIG_BASE64 after loading dotenv (for local testing only)
|
| 38 |
+
# This value is read from config.py, which in turn reads from .env.local
|
| 39 |
+
|
| 40 |
# Import configurations and prompt from local modules
|
| 41 |
from config import (
|
| 42 |
DEEPSEEK_API_URL, DEEPSEEK_HEADERS,
|
|
|
|
| 64 |
if not firebase_admin._apps: # Check if Firebase Admin SDK is already initialized
|
| 65 |
# Determine Firebase config. In deployment, it comes from env vars.
|
| 66 |
# For local __main__ testing, it also uses env vars.
|
|
|
|
| 67 |
|
| 68 |
+
if FIREBASE_CONFIG_BASE64:
|
| 69 |
try:
|
| 70 |
# Decode the Base64-encoded Firebase Service Account JSON
|
| 71 |
+
cred_json = base64.b64decode(FIREBASE_CONFIG_BASE64).decode('utf-8')
|
| 72 |
cred_dict = json.loads(cred_json)
|
| 73 |
cred = credentials.Certificate(cred_dict)
|
| 74 |
firebase_admin.initialize_app(cred)
|
|
|
|
| 416 |
|
| 417 |
# --- Main execution logic for local testing (only runs when script is executed directly) ---
|
| 418 |
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 419 |
|
| 420 |
# For local testing, initialize Firebase and capture the instance
|
| 421 |
local_firestore_instance = initialize_firebase_client()
|