Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,12 +21,8 @@ def load_model(model_name):
|
|
| 21 |
# Initialize default model
|
| 22 |
load_model("LeCarnet-8M")
|
| 23 |
|
| 24 |
-
# Streamer for real-time generation
|
| 25 |
-
streamer = None
|
| 26 |
-
|
| 27 |
# Streaming generation function
|
| 28 |
def respond(message, max_tokens, temperature, top_p):
|
| 29 |
-
global streamer
|
| 30 |
inputs = tokenizer(message, return_tensors="pt")
|
| 31 |
streamer = TextIteratorStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
|
| 32 |
|
|
@@ -68,10 +64,23 @@ def update_model(model_name):
|
|
| 68 |
|
| 69 |
# Gradio UI
|
| 70 |
with gr.Blocks(title="LeCarnet - Chat Interface") as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
with gr.Row():
|
| 72 |
# Left column: Options
|
| 73 |
with gr.Column(scale=1, min_width=150):
|
| 74 |
-
gr.Markdown("### 🧠 Model Settings")
|
| 75 |
model_selector = gr.Dropdown(
|
| 76 |
choices=["LeCarnet-3M", "LeCarnet-8M", "LeCarnet-21M"],
|
| 77 |
value="LeCarnet-8M",
|
|
@@ -80,18 +89,10 @@ with gr.Blocks(title="LeCarnet - Chat Interface") as demo:
|
|
| 80 |
max_tokens = gr.Slider(1, 512, value=512, step=1, label="Max New Tokens")
|
| 81 |
temperature = gr.Slider(0.1, 2.0, value=0.7, step=0.1, label="Temperature")
|
| 82 |
top_p = gr.Slider(0.1, 1.0, value=0.9, step=0.05, label="Top-p Sampling")
|
| 83 |
-
clear_button = gr.Button("
|
| 84 |
|
| 85 |
-
# Right column: Chat
|
| 86 |
with gr.Column(scale=4):
|
| 87 |
-
gr.Markdown("### 🤖 LeCarnet Chatbot")
|
| 88 |
-
model_logo = gr.Image(
|
| 89 |
-
value="media/le-carnet.png",
|
| 90 |
-
label="Model Logo",
|
| 91 |
-
height=100,
|
| 92 |
-
width=100,
|
| 93 |
-
interactive=False
|
| 94 |
-
)
|
| 95 |
chatbot = gr.Chatbot(
|
| 96 |
bubble_full_width=False,
|
| 97 |
height=500
|
|
|
|
| 21 |
# Initialize default model
|
| 22 |
load_model("LeCarnet-8M")
|
| 23 |
|
|
|
|
|
|
|
|
|
|
| 24 |
# Streaming generation function
|
| 25 |
def respond(message, max_tokens, temperature, top_p):
|
|
|
|
| 26 |
inputs = tokenizer(message, return_tensors="pt")
|
| 27 |
streamer = TextIteratorStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
|
| 28 |
|
|
|
|
| 64 |
|
| 65 |
# Gradio UI
|
| 66 |
with gr.Blocks(title="LeCarnet - Chat Interface") as demo:
|
| 67 |
+
# Top bar with logo and title
|
| 68 |
+
with gr.Row():
|
| 69 |
+
with gr.Column(min_width=100):
|
| 70 |
+
gr.Image(
|
| 71 |
+
value="media/le-carnet.png",
|
| 72 |
+
label="Model Logo",
|
| 73 |
+
height=60,
|
| 74 |
+
width=60,
|
| 75 |
+
interactive=False
|
| 76 |
+
)
|
| 77 |
+
with gr.Column():
|
| 78 |
+
gr.Markdown("# LeCarnet")
|
| 79 |
+
|
| 80 |
+
# Main layout
|
| 81 |
with gr.Row():
|
| 82 |
# Left column: Options
|
| 83 |
with gr.Column(scale=1, min_width=150):
|
|
|
|
| 84 |
model_selector = gr.Dropdown(
|
| 85 |
choices=["LeCarnet-3M", "LeCarnet-8M", "LeCarnet-21M"],
|
| 86 |
value="LeCarnet-8M",
|
|
|
|
| 89 |
max_tokens = gr.Slider(1, 512, value=512, step=1, label="Max New Tokens")
|
| 90 |
temperature = gr.Slider(0.1, 2.0, value=0.7, step=0.1, label="Temperature")
|
| 91 |
top_p = gr.Slider(0.1, 1.0, value=0.9, step=0.05, label="Top-p Sampling")
|
| 92 |
+
clear_button = gr.Button("Clear Chat")
|
| 93 |
|
| 94 |
+
# Right column: Chat
|
| 95 |
with gr.Column(scale=4):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
chatbot = gr.Chatbot(
|
| 97 |
bubble_full_width=False,
|
| 98 |
height=500
|