Spaces:
Paused
Paused
Nada commited on
Commit ·
5499036
1
Parent(s): 6d4aad7
up
Browse files- chatbot.py +12 -3
chatbot.py
CHANGED
|
@@ -49,14 +49,19 @@ def setup_cache_dirs():
|
|
| 49 |
is_spaces = os.environ.get('SPACE_ID') is not None
|
| 50 |
|
| 51 |
if is_spaces:
|
| 52 |
-
# Use /tmp for Hugging Face Spaces
|
| 53 |
cache_dir = '/tmp/huggingface'
|
| 54 |
os.environ.update({
|
| 55 |
'TRANSFORMERS_CACHE': cache_dir,
|
| 56 |
'HF_HOME': cache_dir,
|
| 57 |
'TOKENIZERS_PARALLELISM': 'false',
|
| 58 |
'TRANSFORMERS_VERBOSITY': 'error',
|
| 59 |
-
'BITSANDBYTES_NOWELCOME': '1'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
})
|
| 61 |
else:
|
| 62 |
# Use default cache for local development
|
|
@@ -67,8 +72,12 @@ def setup_cache_dirs():
|
|
| 67 |
'BITSANDBYTES_NOWELCOME': '1'
|
| 68 |
})
|
| 69 |
|
| 70 |
-
# Create cache directory
|
| 71 |
os.makedirs(cache_dir, exist_ok=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
return cache_dir
|
| 73 |
|
| 74 |
# Set up cache directories
|
|
|
|
| 49 |
is_spaces = os.environ.get('SPACE_ID') is not None
|
| 50 |
|
| 51 |
if is_spaces:
|
| 52 |
+
# Use /tmp for Hugging Face Spaces with proper permissions
|
| 53 |
cache_dir = '/tmp/huggingface'
|
| 54 |
os.environ.update({
|
| 55 |
'TRANSFORMERS_CACHE': cache_dir,
|
| 56 |
'HF_HOME': cache_dir,
|
| 57 |
'TOKENIZERS_PARALLELISM': 'false',
|
| 58 |
'TRANSFORMERS_VERBOSITY': 'error',
|
| 59 |
+
'BITSANDBYTES_NOWELCOME': '1',
|
| 60 |
+
'HF_DATASETS_CACHE': cache_dir,
|
| 61 |
+
'HF_METRICS_CACHE': cache_dir,
|
| 62 |
+
'HF_MODULES_CACHE': cache_dir,
|
| 63 |
+
'HUGGING_FACE_HUB_TOKEN': os.environ.get('HF_TOKEN', ''),
|
| 64 |
+
'HF_TOKEN': os.environ.get('HF_TOKEN', '')
|
| 65 |
})
|
| 66 |
else:
|
| 67 |
# Use default cache for local development
|
|
|
|
| 72 |
'BITSANDBYTES_NOWELCOME': '1'
|
| 73 |
})
|
| 74 |
|
| 75 |
+
# Create cache directory with proper permissions
|
| 76 |
os.makedirs(cache_dir, exist_ok=True)
|
| 77 |
+
if is_spaces:
|
| 78 |
+
# Ensure directory is writable
|
| 79 |
+
os.chmod(cache_dir, 0o777)
|
| 80 |
+
|
| 81 |
return cache_dir
|
| 82 |
|
| 83 |
# Set up cache directories
|