Neon-AI commited on
Commit
a51ee55
Β·
verified Β·
1 Parent(s): 3453232

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -17
app.py CHANGED
@@ -29,22 +29,20 @@ def load_model():
29
 
30
  base_model = AutoModelForCausalLM.from_pretrained(
31
  MODEL_ID,
32
- torch_dtype=torch.float32
 
33
  )
34
 
35
- # Load LoRA from /lora (FAIL if missing β€” no silent fallback)
36
- model = PeftModel.from_pretrained(
37
- base_model,
38
- f"{MODEL_ID}/lora",
39
- is_trainable=False
40
- )
41
 
42
  print(model.peft_config)
43
 
44
- model.set_adapter("default") # ensure adapter is active
45
  model.to("cpu")
46
  model.eval()
47
-
48
  return tokenizer, model
49
 
50
 
@@ -61,9 +59,7 @@ if st.button("Send") and prompt.strip():
61
  st.session_state.history.append(("You", prompt))
62
 
63
  system_instructions = """You are Kushina.
64
-
65
  You operate in exactly ONE of two modes.
66
-
67
  ====================
68
  MODE: CHAT
69
  ====================
@@ -73,12 +69,11 @@ Rules:
73
  - Neutral β†’ neutral.
74
  - Serious β†’ serious.
75
  - Rude β†’ curt or dismissive.
76
- - Mirroring of emotions is very important and myst be talen as priority
77
  - No enthusiasm by default.
78
  - No emojis unless the user uses them first.
79
  - Replies must be short (1–3 sentences).
80
  - No explanations unless explicitly asked.
81
-
82
  ====================
83
  MODE: CODE
84
  ====================
@@ -92,7 +87,6 @@ Rules:
92
  - Follow standard best practices.
93
  - Be deterministic and professional.
94
  - Finish the task completely.
95
-
96
  ====================
97
  MODE SELECTION
98
  ====================
@@ -105,9 +99,7 @@ Automatically switch to MODE: CODE if the user requests:
105
  - API
106
  - algorithm
107
  - app
108
-
109
  Otherwise, use MODE: CHAT.
110
-
111
  ====================
112
  IDENTITY
113
  ====================
@@ -163,4 +155,4 @@ for speaker, text in st.session_state.history:
163
  if speaker == "You":
164
  st.markdown(f"**You:** {text}")
165
  else:
166
- st.markdown(f"**Niche:** {text}")
 
29
 
30
  base_model = AutoModelForCausalLM.from_pretrained(
31
  MODEL_ID,
32
+ torch_dtype=torch.float32,
33
+ device_map=None
34
  )
35
 
36
+ # Load LoRA if present
37
+ try:
38
+ model = PeftModel.from_pretrained(base_model, MODEL_ID)
39
+ except Exception:
40
+ model = base_model
 
41
 
42
  print(model.peft_config)
43
 
 
44
  model.to("cpu")
45
  model.eval()
 
46
  return tokenizer, model
47
 
48
 
 
59
  st.session_state.history.append(("You", prompt))
60
 
61
  system_instructions = """You are Kushina.
 
62
  You operate in exactly ONE of two modes.
 
63
  ====================
64
  MODE: CHAT
65
  ====================
 
69
  - Neutral β†’ neutral.
70
  - Serious β†’ serious.
71
  - Rude β†’ curt or dismissive.
72
+ - Mirroring of emotions is very important and must be talen as priority
73
  - No enthusiasm by default.
74
  - No emojis unless the user uses them first.
75
  - Replies must be short (1–3 sentences).
76
  - No explanations unless explicitly asked.
 
77
  ====================
78
  MODE: CODE
79
  ====================
 
87
  - Follow standard best practices.
88
  - Be deterministic and professional.
89
  - Finish the task completely.
 
90
  ====================
91
  MODE SELECTION
92
  ====================
 
99
  - API
100
  - algorithm
101
  - app
 
102
  Otherwise, use MODE: CHAT.
 
103
  ====================
104
  IDENTITY
105
  ====================
 
155
  if speaker == "You":
156
  st.markdown(f"**You:** {text}")
157
  else:
158
+ st.markdown(f"**Niche:** {text}")