Spaces:
Runtime error
Runtime error
Update server.py
Browse files
server.py
CHANGED
|
@@ -6,18 +6,10 @@ import torch
|
|
| 6 |
|
| 7 |
app = FastAPI()
|
| 8 |
|
| 9 |
-
# β
Fix: Set writable cache directory for Hugging Face models
|
| 10 |
-
os.environ["TRANSFORMERS_CACHE"] = "/tmp"
|
| 11 |
-
os.environ["HF_HOME"] = "/tmp"
|
| 12 |
-
|
| 13 |
-
# β
Ensure cache directory exists
|
| 14 |
-
if not os.path.exists("/tmp"):
|
| 15 |
-
os.makedirs("/tmp")
|
| 16 |
-
|
| 17 |
# β
Load DeepSeek-Coder-V2-Base Model with `trust_remote_code=True`
|
| 18 |
model_name = "deepseek-ai/DeepSeek-Coder-V2-Base"
|
| 19 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name,
|
| 20 |
-
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, device_map="auto",
|
| 21 |
|
| 22 |
class CodeRequest(BaseModel):
|
| 23 |
user_story: str
|
|
|
|
| 6 |
|
| 7 |
app = FastAPI()
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
# β
Load DeepSeek-Coder-V2-Base Model with `trust_remote_code=True`
|
| 10 |
model_name = "deepseek-ai/DeepSeek-Coder-V2-Base"
|
| 11 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
| 12 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, device_map="auto", trust_remote_code=True)
|
| 13 |
|
| 14 |
class CodeRequest(BaseModel):
|
| 15 |
user_story: str
|