Spaces:
Runtime error
Runtime error
Kaan
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -8,8 +8,11 @@ app = FastAPI()
|
|
8 |
@app.get("/")
|
9 |
async def generate_text():
|
10 |
try:
|
|
|
|
|
|
|
11 |
# Specify the directory for model download within the Docker container
|
12 |
-
model_dir = "/
|
13 |
os.makedirs(model_dir, exist_ok=True)
|
14 |
|
15 |
hf_hub_download(repo_id="TheBloke/Mistral-7B-v0.1-GGUF", filename="mistral-7b-v0.1.Q4_K_M.gguf", local_dir=model_dir)
|
@@ -23,4 +26,4 @@ async def generate_text():
|
|
23 |
generated_texts = tokenizer.batch_decode(output, skip_special_tokens=True)
|
24 |
return generated_texts
|
25 |
except Exception as e:
|
26 |
-
raise HTTPException(status_code=500, detail=str(e))
|
|
|
8 |
@app.get("/")
|
9 |
async def generate_text():
|
10 |
try:
|
11 |
+
# Get the cache directory from the environment variable
|
12 |
+
cache_dir = os.getenv("TRANSFORMERS_CACHE", "/code/cache")
|
13 |
+
|
14 |
# Specify the directory for model download within the Docker container
|
15 |
+
model_dir = os.path.join(cache_dir, "TheBloke/Mistral-7B-v0.1-GGUF")
|
16 |
os.makedirs(model_dir, exist_ok=True)
|
17 |
|
18 |
hf_hub_download(repo_id="TheBloke/Mistral-7B-v0.1-GGUF", filename="mistral-7b-v0.1.Q4_K_M.gguf", local_dir=model_dir)
|
|
|
26 |
generated_texts = tokenizer.batch_decode(output, skip_special_tokens=True)
|
27 |
return generated_texts
|
28 |
except Exception as e:
|
29 |
+
raise HTTPException(status_code=500, detail=str(e))
|