Spaces:
Configuration error
Configuration error
Refactor ChatInterface in app.py to use an accordion for additional settings, improving organization and readability of input fields.
Browse files
app.py
CHANGED
|
@@ -150,16 +150,25 @@ with gr.Blocks(css=fancy_css) as demo:
|
|
| 150 |
type="messages",
|
| 151 |
avatar_images=(str(ASSETS_DIR / "monster_icon.png"), str(ASSETS_DIR / "smart_confidant_icon.png"))
|
| 152 |
)
|
| 153 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
gr.ChatInterface(
|
| 155 |
fn=respond,
|
| 156 |
chatbot=chatbot,
|
| 157 |
additional_inputs=[
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
],
|
| 164 |
type="messages",
|
| 165 |
)
|
|
|
|
| 150 |
type="messages",
|
| 151 |
avatar_images=(str(ASSETS_DIR / "monster_icon.png"), str(ASSETS_DIR / "smart_confidant_icon.png"))
|
| 152 |
)
|
| 153 |
+
|
| 154 |
+
# Create additional inputs in an accordion below the chatbot
|
| 155 |
+
with gr.Accordion("⚙️ Additional Settings", open=False):
|
| 156 |
+
system_message = gr.Textbox(value=DEFAULT_SYSTEM_MESSAGE, label="System message")
|
| 157 |
+
max_tokens = gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens")
|
| 158 |
+
temperature = gr.Slider(minimum=0.1, maximum=2.0, value=0.7, step=0.1, label="Temperature")
|
| 159 |
+
top_p = gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)")
|
| 160 |
+
selected_model = gr.Radio(choices=MODEL_OPTIONS, label="Select Model", value=MODEL_OPTIONS[0])
|
| 161 |
+
|
| 162 |
+
# Create ChatInterface with the custom chatbot and pre-rendered additional inputs
|
| 163 |
gr.ChatInterface(
|
| 164 |
fn=respond,
|
| 165 |
chatbot=chatbot,
|
| 166 |
additional_inputs=[
|
| 167 |
+
system_message,
|
| 168 |
+
max_tokens,
|
| 169 |
+
temperature,
|
| 170 |
+
top_p,
|
| 171 |
+
selected_model,
|
| 172 |
],
|
| 173 |
type="messages",
|
| 174 |
)
|