Spaces:
Runtime error
Runtime error
bug
Browse files
app.py
CHANGED
|
@@ -16,10 +16,7 @@ load_dotenv()
|
|
| 16 |
app = FastAPI()
|
| 17 |
|
| 18 |
os.environ["HF_HOME"] = "/tmp/huggingface_cache"
|
| 19 |
-
|
| 20 |
-
cache_dir = os.environ["TRANSFORMERS_CACHE"]
|
| 21 |
-
if not os.path.exists(cache_dir):
|
| 22 |
-
os.makedirs(cache_dir)
|
| 23 |
|
| 24 |
# Ensure the cache directory exists
|
| 25 |
cache_dir = os.environ["HF_HOME"]
|
|
@@ -32,16 +29,11 @@ logging.basicConfig(level=logging.INFO)
|
|
| 32 |
# Load Hugging Face token from environment variable
|
| 33 |
huggingface_token = os.getenv('HUGGINGFACE_HUB_TOKEN')
|
| 34 |
if huggingface_token:
|
| 35 |
-
|
| 36 |
-
# Log in to Hugging Face without adding credentials to Git
|
| 37 |
-
login(token=huggingface_token, add_to_git_credential=False)
|
| 38 |
-
logging.info("Successfully logged into Hugging Face Hub.")
|
| 39 |
-
except Exception as e:
|
| 40 |
-
logging.error(f"Failed to log into Hugging Face Hub: {e}")
|
| 41 |
-
raise HTTPException(status_code=500, detail="Failed to log into Hugging Face Hub.")
|
| 42 |
else:
|
| 43 |
raise ValueError("Hugging Face token is not set. Please set the HUGGINGFACE_HUB_TOKEN environment variable.")
|
| 44 |
|
|
|
|
| 45 |
# Initialize the Qdrant searcher
|
| 46 |
qdrant_url = os.getenv('QDRANT_URL')
|
| 47 |
access_token = os.getenv('QDRANT_ACCESS_TOKEN')
|
|
|
|
| 16 |
app = FastAPI()
|
| 17 |
|
| 18 |
os.environ["HF_HOME"] = "/tmp/huggingface_cache"
|
| 19 |
+
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
# Ensure the cache directory exists
|
| 22 |
cache_dir = os.environ["HF_HOME"]
|
|
|
|
| 29 |
# Load Hugging Face token from environment variable
|
| 30 |
huggingface_token = os.getenv('HUGGINGFACE_HUB_TOKEN')
|
| 31 |
if huggingface_token:
|
| 32 |
+
login(token=huggingface_token, add_to_git_credential=True, write_permission=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
else:
|
| 34 |
raise ValueError("Hugging Face token is not set. Please set the HUGGINGFACE_HUB_TOKEN environment variable.")
|
| 35 |
|
| 36 |
+
|
| 37 |
# Initialize the Qdrant searcher
|
| 38 |
qdrant_url = os.getenv('QDRANT_URL')
|
| 39 |
access_token = os.getenv('QDRANT_ACCESS_TOKEN')
|