Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -75,108 +75,44 @@ def respond(
|
|
| 75 |
accumulated += new_text
|
| 76 |
yield accumulated
|
| 77 |
|
| 78 |
-
# --- Gradio Interface ---
|
| 79 |
-
# CSS for the custom logo and layout
|
| 80 |
-
css = """
|
| 81 |
-
.gradio-container {
|
| 82 |
-
padding: 0 !important;
|
| 83 |
-
}
|
| 84 |
-
.gradio-container > main.fillable {
|
| 85 |
-
padding: 0 !important;
|
| 86 |
-
}
|
| 87 |
-
#chatbot {
|
| 88 |
-
height: calc(100vh - 21px - 16px);
|
| 89 |
-
max-height: 1500px;
|
| 90 |
-
}
|
| 91 |
-
#chatbot .chatbot-conversations {
|
| 92 |
-
height: 100vh;
|
| 93 |
-
background-color: var(--ms-gr-ant-color-bg-layout);
|
| 94 |
-
padding-left: 4px;
|
| 95 |
-
padding-right: 4px;
|
| 96 |
-
}
|
| 97 |
-
#chatbot .chatbot-conversations .chatbot-conversations-list {
|
| 98 |
-
padding-left: 0;
|
| 99 |
-
padding-right: 0;
|
| 100 |
-
}
|
| 101 |
-
#chatbot .chatbot-chat {
|
| 102 |
-
padding: 32px;
|
| 103 |
-
padding-bottom: 0;
|
| 104 |
-
height: 100%;
|
| 105 |
-
}
|
| 106 |
-
@media (max-width: 768px) {
|
| 107 |
-
#chatbot .chatbot-chat {
|
| 108 |
-
padding: 0;
|
| 109 |
-
}
|
| 110 |
-
}
|
| 111 |
-
#chatbot .chatbot-chat .chatbot-chat-messages {
|
| 112 |
-
flex: 1;
|
| 113 |
-
}
|
| 114 |
-
.logo-container {
|
| 115 |
-
display: flex;
|
| 116 |
-
justify-content: center;
|
| 117 |
-
padding: 10px;
|
| 118 |
-
}
|
| 119 |
-
.logo-container img {
|
| 120 |
-
max-width: 80%; /* Adjust as needed */
|
| 121 |
-
height: auto;
|
| 122 |
-
}
|
| 123 |
-
"""
|
| 124 |
|
| 125 |
with gr.Blocks(css=css, fill_width=True) as demo:
|
| 126 |
-
with gr.
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
value=
|
| 131 |
-
label="
|
| 132 |
-
interactive=
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
)
|
| 137 |
|
| 138 |
-
gr.
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
temperature_slider = gr.Slider(
|
| 157 |
-
0.1, 2.0, value=0.7, step=0.1, label="Temperature"
|
| 158 |
-
)
|
| 159 |
-
top_p_slider = gr.Slider(
|
| 160 |
-
0.1, 1.0, value=0.9, step=0.05, label="Top‑p"
|
| 161 |
-
)
|
| 162 |
-
|
| 163 |
-
with gr.Column(scale=3):
|
| 164 |
-
chatbot = gr.ChatInterface(
|
| 165 |
-
fn=respond,
|
| 166 |
-
additional_inputs=[
|
| 167 |
-
model_dropdown,
|
| 168 |
-
max_tokens_slider,
|
| 169 |
-
temperature_slider,
|
| 170 |
-
top_p_slider,
|
| 171 |
-
],
|
| 172 |
-
examples=[
|
| 173 |
-
["Il était une fois un petit garçon qui vivait dans un village paisible."],
|
| 174 |
-
["Il était une fois une grenouille qui rêvait de toucher les étoiles chaque nuit depuis son étang."],
|
| 175 |
-
["Il était une fois un petit lapin perdu"],
|
| 176 |
-
],
|
| 177 |
-
cache_examples=False,
|
| 178 |
-
submit_btn="Generate",
|
| 179 |
-
)
|
| 180 |
|
| 181 |
if __name__ == "__main__":
|
| 182 |
demo.queue()
|
|
|
|
| 75 |
accumulated += new_text
|
| 76 |
yield accumulated
|
| 77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
with gr.Blocks(css=css, fill_width=True) as demo:
|
| 80 |
+
with gr.Row():
|
| 81 |
+
with gr.Column(scale=1):
|
| 82 |
+
model_dropdown = gr.Dropdown(
|
| 83 |
+
choices=list(MODEL_PATHS.keys()),
|
| 84 |
+
value=initial_model,
|
| 85 |
+
label="Choose Model",
|
| 86 |
+
interactive=True
|
| 87 |
+
)
|
| 88 |
+
max_tokens_slider = gr.Slider(
|
| 89 |
+
1, 512, value=512, step=1, label="Max new tokens"
|
| 90 |
+
)
|
| 91 |
+
temperature_slider = gr.Slider(
|
| 92 |
+
0.1, 2.0, value=0.7, step=0.1, label="Temperature"
|
| 93 |
+
)
|
| 94 |
+
top_p_slider = gr.Slider(
|
| 95 |
+
0.1, 1.0, value=0.9, step=0.05, label="Top‑p"
|
| 96 |
)
|
| 97 |
|
| 98 |
+
with gr.Column(scale=3):
|
| 99 |
+
chatbot = gr.ChatInterface(
|
| 100 |
+
fn=respond,
|
| 101 |
+
additional_inputs=[
|
| 102 |
+
model_dropdown,
|
| 103 |
+
max_tokens_slider,
|
| 104 |
+
temperature_slider,
|
| 105 |
+
top_p_slider,
|
| 106 |
+
],
|
| 107 |
+
examples=[
|
| 108 |
+
["Il était une fois un petit garçon qui vivait dans un village paisible."],
|
| 109 |
+
["Il était une fois une grenouille qui rêvait de toucher les étoiles chaque nuit depuis son étang."],
|
| 110 |
+
["Il était une fois un petit lapin perdu"],
|
| 111 |
+
],
|
| 112 |
+
cache_examples=False,
|
| 113 |
+
submit_btn="Generate",
|
| 114 |
+
avatar_images=(None, "media/le-carnet.png")
|
| 115 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
|
| 117 |
if __name__ == "__main__":
|
| 118 |
demo.queue()
|