Mlaana commited on
Commit
d44c8ed
·
1 Parent(s): 8666fde

change id model from drive

Browse files
Files changed (1) hide show
  1. app.py +1 -6
app.py CHANGED
@@ -4,10 +4,9 @@ import torch
4
  from transformers import AutoTokenizer, AutoModelForCausalLM, TextStreamer
5
  import gradio as gr
6
 
7
- # ==== STEP 1: Download model (kalau belum ada) ====
8
  os.makedirs("model", exist_ok=True)
9
 
10
- MODEL_URL = "https://drive.google.com/uc?id=1I9cM5OlZ1oBTPaJUY1pRzdhEGpZCpaL5" # <- Ganti file ID-nya
11
  MODEL_PATH = "model/model.safetensors"
12
 
13
  if not os.path.exists(MODEL_PATH):
@@ -16,18 +15,14 @@ if not os.path.exists(MODEL_PATH):
16
  else:
17
  print("✅ Model file already exists")
18
 
19
- # ==== STEP 2: Load tokenizer & model ====
20
  print("🔧 Loading model & tokenizer...")
21
  tokenizer = AutoTokenizer.from_pretrained("model")
22
  model = AutoModelForCausalLM.from_pretrained("model", torch_dtype=torch.float16)
23
 
24
- # Gunakan CUDA kalau tersedia
25
  device = "cuda" if torch.cuda.is_available() else "cpu"
26
  model.to(device)
27
- # Optional: streaming token
28
  streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
29
 
30
- # ==== STEP 3: Define response logic ====
31
  def respond(message, history, max_tokens, temperature, top_p):
32
  input_ids = tokenizer.encode(message, return_tensors="pt").to(device)
33
  history_text = ""
 
4
  from transformers import AutoTokenizer, AutoModelForCausalLM, TextStreamer
5
  import gradio as gr
6
 
 
7
  os.makedirs("model", exist_ok=True)
8
 
9
+ MODEL_URL = "https://drive.google.com/uc?id=1Kg8KSGIgjBopeOKSbYbFWEgUlYOcqyXX" # <- Ganti file ID-nya
10
  MODEL_PATH = "model/model.safetensors"
11
 
12
  if not os.path.exists(MODEL_PATH):
 
15
  else:
16
  print("✅ Model file already exists")
17
 
 
18
  print("🔧 Loading model & tokenizer...")
19
  tokenizer = AutoTokenizer.from_pretrained("model")
20
  model = AutoModelForCausalLM.from_pretrained("model", torch_dtype=torch.float16)
21
 
 
22
  device = "cuda" if torch.cuda.is_available() else "cpu"
23
  model.to(device)
 
24
  streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
25
 
 
26
  def respond(message, history, max_tokens, temperature, top_p):
27
  input_ids = tokenizer.encode(message, return_tensors="pt").to(device)
28
  history_text = ""