Update utils/chatbot_interface_test.py
Browse files- utils/chatbot_interface_test.py +16 -25
utils/chatbot_interface_test.py
CHANGED
|
@@ -89,37 +89,28 @@ class ChatbotInterface:
|
|
| 89 |
"""
|
| 90 |
logging.info("Creating Gradio interface...")
|
| 91 |
|
| 92 |
-
|
| 93 |
-
css = ""
|
| 94 |
-
css_path = "style.css"
|
| 95 |
-
if os.path.exists(css_path):
|
| 96 |
-
with open(css_path, "r") as f:
|
| 97 |
-
css = f.read()
|
| 98 |
-
|
| 99 |
-
with gr.Blocks() as demo: #css=css
|
| 100 |
# Title and description area.
|
| 101 |
gr.Markdown(f"## {self.title}\n{self.description}")
|
| 102 |
|
| 103 |
# Chatbot output area.
|
| 104 |
chatbot_output = gr.Chatbot(label=self.output_label, type="messages")
|
| 105 |
-
|
| 106 |
# Use a gr.Row container as the input box with an integrated submit button.
|
| 107 |
-
with gr.Row(elem_id="input-container"):
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
|
| 115 |
-
|
| 116 |
-
reset = gr.ClearButton(
|
| 117 |
-
value="🔄",
|
| 118 |
-
variant="primary",
|
| 119 |
-
elem_id="reset-button",
|
| 120 |
-
size="sm"
|
| 121 |
-
)
|
| 122 |
-
|
| 123 |
# Define a local function to reset input
|
| 124 |
def reset_output() -> list:
|
| 125 |
"""
|
|
@@ -146,7 +137,7 @@ class ChatbotInterface:
|
|
| 146 |
)
|
| 147 |
|
| 148 |
|
| 149 |
-
Bind the Enter key (textbox submit) to the same processing function
|
| 150 |
user_input.submit(
|
| 151 |
fn=process_input,
|
| 152 |
inputs=[user_input, chatbot_output],
|
|
|
|
| 89 |
"""
|
| 90 |
logging.info("Creating Gradio interface...")
|
| 91 |
|
| 92 |
+
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
# Title and description area.
|
| 94 |
gr.Markdown(f"## {self.title}\n{self.description}")
|
| 95 |
|
| 96 |
# Chatbot output area.
|
| 97 |
chatbot_output = gr.Chatbot(label=self.output_label, type="messages")
|
|
|
|
| 98 |
# Use a gr.Row container as the input box with an integrated submit button.
|
| 99 |
+
with gr.Row(elem_id="input-container", equal_height=True):
|
| 100 |
+
user_input = gr.Textbox(
|
| 101 |
+
lines=1,
|
| 102 |
+
show_label=False, # Hide label for a unified look.
|
| 103 |
+
elem_id="chat-input",
|
| 104 |
+
placeholder=self.input_placeholder,
|
| 105 |
+
scale=500,
|
| 106 |
+
)
|
| 107 |
+
reset = gr.ClearButton(
|
| 108 |
+
value="🔄",
|
| 109 |
+
variant="secondary",
|
| 110 |
+
elem_id="reset-button",
|
| 111 |
+
size="lg"
|
| 112 |
+
)
|
| 113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
# Define a local function to reset input
|
| 115 |
def reset_output() -> list:
|
| 116 |
"""
|
|
|
|
| 137 |
)
|
| 138 |
|
| 139 |
|
| 140 |
+
# Bind the Enter key (textbox submit) to the same processing function
|
| 141 |
user_input.submit(
|
| 142 |
fn=process_input,
|
| 143 |
inputs=[user_input, chatbot_output],
|