Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch
|
| 3 |
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
|
| 4 |
from threading import Thread
|
| 5 |
|
|
|
|
|
|
|
|
|
|
| 6 |
model_id = "ZyperAI/Z-AI-0.1-1.1B-Code.web"
|
| 7 |
-
|
|
|
|
|
|
|
| 8 |
model = AutoModelForCausalLM.from_pretrained(
|
| 9 |
model_id,
|
| 10 |
torch_dtype=torch.float32,
|
| 11 |
-
device_map="cpu"
|
|
|
|
| 12 |
)
|
| 13 |
|
| 14 |
def generate_code(prompt, history):
|
|
|
|
| 1 |
+
import os
|
| 2 |
import gradio as gr
|
| 3 |
import torch
|
| 4 |
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
|
| 5 |
from threading import Thread
|
| 6 |
|
| 7 |
+
# This pulls the token you just saved in the Space settings
|
| 8 |
+
hf_token = os.getenv("HF_TOKEN")
|
| 9 |
+
|
| 10 |
model_id = "ZyperAI/Z-AI-0.1-1.1B-Code.web"
|
| 11 |
+
|
| 12 |
+
# We pass the token to both the tokenizer and the model
|
| 13 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id, token=hf_token)
|
| 14 |
model = AutoModelForCausalLM.from_pretrained(
|
| 15 |
model_id,
|
| 16 |
torch_dtype=torch.float32,
|
| 17 |
+
device_map="cpu",
|
| 18 |
+
token=hf_token
|
| 19 |
)
|
| 20 |
|
| 21 |
def generate_code(prompt, history):
|