Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,30 +3,31 @@ import torch
|
|
| 3 |
import ai_thingy
|
| 4 |
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
print("[SYSTEM] Loading Aoban 1.1A-Refined...")
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
|
| 15 |
-
initial_train=True,
|
| 16 |
-
use_live_data=False,
|
| 17 |
-
epochs=0
|
| 18 |
-
)
|
| 19 |
|
| 20 |
-
print("[SYSTEM] Aoban 1.1A-Refined loaded.")
|
| 21 |
|
| 22 |
-
|
|
|
|
| 23 |
full_prompt = (
|
| 24 |
f"{system_message}\n"
|
| 25 |
f"User: {message}\n"
|
| 26 |
f"Assistant:"
|
| 27 |
)
|
| 28 |
|
| 29 |
-
# --- GENERATION ---
|
| 30 |
response = ai_thingy.generate_text(
|
| 31 |
model=ai_thingy.current_model,
|
| 32 |
tokenizer=ai_thingy.current_tokenizer,
|
|
@@ -48,22 +49,25 @@ demo = gr.ChatInterface(
|
|
| 48 |
additional_inputs=[
|
| 49 |
gr.Textbox(
|
| 50 |
value="You are a helpful but not really helpful AobanCorp™ assistant.",
|
| 51 |
-
label="
|
| 52 |
),
|
| 53 |
gr.Slider(
|
| 54 |
-
10,
|
|
|
|
| 55 |
value=50,
|
| 56 |
step=1,
|
| 57 |
label="Response Length"
|
| 58 |
),
|
| 59 |
gr.Slider(
|
| 60 |
-
0.1,
|
|
|
|
| 61 |
value=1.0,
|
| 62 |
step=0.1,
|
| 63 |
-
label="Creativity (
|
| 64 |
),
|
| 65 |
gr.Slider(
|
| 66 |
-
1,
|
|
|
|
| 67 |
value=40,
|
| 68 |
step=1,
|
| 69 |
label="Focus (Top-K)"
|
|
|
|
| 3 |
import ai_thingy
|
| 4 |
|
| 5 |
|
| 6 |
+
# Hugging Face Spaces can use CPU unless you've
|
| 7 |
+
# explicitly enabled a GPU.
|
| 8 |
+
ai_thingy.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 9 |
+
|
| 10 |
|
| 11 |
+
print("[SYSTEM] Initializing Aoban 1.1A-Refined...")
|
| 12 |
+
print(f"[SYSTEM] Device: {ai_thingy.device}")
|
|
|
|
| 13 |
|
| 14 |
+
ai_thingy.initialize_or_retrain(
|
| 15 |
+
initial_train=True,
|
| 16 |
+
use_live_data=False,
|
| 17 |
+
epochs=0
|
| 18 |
+
)
|
| 19 |
|
| 20 |
+
print("[SYSTEM] Aoban 1.1A-Refined is ready.")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
|
|
|
| 22 |
|
| 23 |
+
def respond(message, history, system_message, max_tokens, temperature, top_k):
|
| 24 |
+
|
| 25 |
full_prompt = (
|
| 26 |
f"{system_message}\n"
|
| 27 |
f"User: {message}\n"
|
| 28 |
f"Assistant:"
|
| 29 |
)
|
| 30 |
|
|
|
|
| 31 |
response = ai_thingy.generate_text(
|
| 32 |
model=ai_thingy.current_model,
|
| 33 |
tokenizer=ai_thingy.current_tokenizer,
|
|
|
|
| 49 |
additional_inputs=[
|
| 50 |
gr.Textbox(
|
| 51 |
value="You are a helpful but not really helpful AobanCorp™ assistant.",
|
| 52 |
+
label="Aoban System Prompt"
|
| 53 |
),
|
| 54 |
gr.Slider(
|
| 55 |
+
minimum=10,
|
| 56 |
+
maximum=100,
|
| 57 |
value=50,
|
| 58 |
step=1,
|
| 59 |
label="Response Length"
|
| 60 |
),
|
| 61 |
gr.Slider(
|
| 62 |
+
minimum=0.1,
|
| 63 |
+
maximum=2.0,
|
| 64 |
value=1.0,
|
| 65 |
step=0.1,
|
| 66 |
+
label="Creativity (Temperature)"
|
| 67 |
),
|
| 68 |
gr.Slider(
|
| 69 |
+
minimum=1,
|
| 70 |
+
maximum=100,
|
| 71 |
value=40,
|
| 72 |
step=1,
|
| 73 |
label="Focus (Top-K)"
|