Update app.py
Browse files
app.py
CHANGED
|
@@ -60,6 +60,22 @@ def generate_text(input_text, selected_model, history):
|
|
| 60 |
|
| 61 |
return generated_response, history, history # Return three values
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
# Create Gradio interface with a dropdown for model selection
|
| 64 |
iface = gr.Interface(
|
| 65 |
fn=generate_text,
|
|
@@ -69,11 +85,12 @@ iface = gr.Interface(
|
|
| 69 |
gr.State() # This is where we maintain the history state (input)
|
| 70 |
],
|
| 71 |
outputs=[
|
| 72 |
-
gr.Textbox(label="Response", placeholder="Response will be shown here"),
|
| 73 |
-
gr.Textbox(label="History", placeholder="Interaction history will be shown here", lines=10, interactive=False),
|
| 74 |
gr.State() # History needs to be output as well
|
| 75 |
],
|
| 76 |
-
title="Chat with OpenRouter Models"
|
|
|
|
| 77 |
)
|
| 78 |
|
| 79 |
iface.launch()
|
|
|
|
| 60 |
|
| 61 |
return generated_response, history, history # Return three values
|
| 62 |
|
| 63 |
+
# Inject custom CSS directly into the Gradio interface for scrollbars
|
| 64 |
+
css = """
|
| 65 |
+
#response-output {
|
| 66 |
+
height: 150px;
|
| 67 |
+
overflow: auto;
|
| 68 |
+
border: 1px solid #ddd;
|
| 69 |
+
padding: 10px;
|
| 70 |
+
}
|
| 71 |
+
#history-output {
|
| 72 |
+
height: 300px;
|
| 73 |
+
overflow: auto;
|
| 74 |
+
border: 1px solid #ddd;
|
| 75 |
+
padding: 10px;
|
| 76 |
+
}
|
| 77 |
+
"""
|
| 78 |
+
|
| 79 |
# Create Gradio interface with a dropdown for model selection
|
| 80 |
iface = gr.Interface(
|
| 81 |
fn=generate_text,
|
|
|
|
| 85 |
gr.State() # This is where we maintain the history state (input)
|
| 86 |
],
|
| 87 |
outputs=[
|
| 88 |
+
gr.Textbox(label="Response", placeholder="Response will be shown here", elem_id="response-output"),
|
| 89 |
+
gr.Textbox(label="History", placeholder="Interaction history will be shown here", lines=10, interactive=False, elem_id="history-output"),
|
| 90 |
gr.State() # History needs to be output as well
|
| 91 |
],
|
| 92 |
+
title="Chat with OpenRouter Models",
|
| 93 |
+
css=css # Apply the custom CSS here
|
| 94 |
)
|
| 95 |
|
| 96 |
iface.launch()
|