Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -130,19 +130,13 @@ def display_history(history):
|
|
130 |
return formatted_history
|
131 |
|
132 |
|
133 |
-
# Define the UI layout with
|
134 |
with gr.Blocks() as demo:
|
135 |
gr.Markdown("# 🧠 AI Chatbot Interface")
|
136 |
gr.Markdown("### Customize your AI Chatbot's behavior and responses.")
|
137 |
|
138 |
with gr.Row():
|
139 |
-
with gr.Column(
|
140 |
-
chatbot = gr.Chatbot()
|
141 |
-
message = gr.Textbox(label="Your message:", lines=1)
|
142 |
-
submit_btn = gr.Button("Send")
|
143 |
-
clear_btn = gr.Button("Clear Chat")
|
144 |
-
|
145 |
-
with gr.Column(scale=1): # Sidebar (smaller)
|
146 |
system_message = gr.Textbox(
|
147 |
value="You are a helpful assistant knowledgeable in various topics. Provide clear, concise, and friendly responses.",
|
148 |
label="System message",
|
@@ -158,7 +152,13 @@ with gr.Blocks() as demo:
|
|
158 |
temperature.change(fn=update_settings, inputs=[max_tokens, temperature, top_p], outputs=settings_output)
|
159 |
top_p.change(fn=update_settings, inputs=[max_tokens, temperature, top_p], outputs=settings_output)
|
160 |
|
161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
sample_prompt = gr.Dropdown(
|
163 |
choices=[
|
164 |
"Can you explain the theory of relativity?",
|
@@ -171,18 +171,18 @@ with gr.Blocks() as demo:
|
|
171 |
value="Can you explain the theory of relativity?",
|
172 |
type="value"
|
173 |
)
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
|
180 |
-
#
|
181 |
-
|
182 |
-
|
183 |
-
submit_feedback = gr.Button("Submit Feedback")
|
184 |
|
185 |
-
|
|
|
186 |
# Update the chatbot with the new message and response
|
187 |
def handle_send(message: str, system_message: str, max_tokens: int, temperature: float, top_p: float):
|
188 |
history = load_chat_history()
|
@@ -213,7 +213,6 @@ with gr.Blocks() as demo:
|
|
213 |
|
214 |
submit_feedback.click(fn=submit_user_feedback, inputs=feedback, outputs=[gr.Textbox(value="Feedback submitted! Thank you.", lines=1, placeholder="")])
|
215 |
|
216 |
-
|
217 |
# Launch the Gradio interface
|
218 |
if __name__ == "__main__":
|
219 |
demo.launch()
|
|
|
130 |
return formatted_history
|
131 |
|
132 |
|
133 |
+
# Define the UI layout with additional features
|
134 |
with gr.Blocks() as demo:
|
135 |
gr.Markdown("# 🧠 AI Chatbot Interface")
|
136 |
gr.Markdown("### Customize your AI Chatbot's behavior and responses.")
|
137 |
|
138 |
with gr.Row():
|
139 |
+
with gr.Column():
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
system_message = gr.Textbox(
|
141 |
value="You are a helpful assistant knowledgeable in various topics. Provide clear, concise, and friendly responses.",
|
142 |
label="System message",
|
|
|
152 |
temperature.change(fn=update_settings, inputs=[max_tokens, temperature, top_p], outputs=settings_output)
|
153 |
top_p.change(fn=update_settings, inputs=[max_tokens, temperature, top_p], outputs=settings_output)
|
154 |
|
155 |
+
with gr.Row():
|
156 |
+
chatbot = gr.Chatbot()
|
157 |
+
# Display chat history in a separate area
|
158 |
+
history_output = gr.Textbox(label="Chat History", lines=10, interactive=False)
|
159 |
+
|
160 |
+
with gr.Row():
|
161 |
+
with gr.Column():
|
162 |
sample_prompt = gr.Dropdown(
|
163 |
choices=[
|
164 |
"Can you explain the theory of relativity?",
|
|
|
171 |
value="Can you explain the theory of relativity?",
|
172 |
type="value"
|
173 |
)
|
174 |
+
message = gr.Textbox(label="Your message:", lines=1)
|
175 |
+
submit_btn = gr.Button("Send")
|
176 |
+
clear_btn = gr.Button("Clear Chat")
|
177 |
+
feedback = gr.Textbox(label="Feedback:", lines=1)
|
178 |
+
submit_feedback = gr.Button("Submit Feedback")
|
179 |
|
180 |
+
# Handle sample prompt selection
|
181 |
+
def update_message(prompt: str) -> str:
|
182 |
+
return prompt
|
|
|
183 |
|
184 |
+
sample_prompt.change(fn=update_message, inputs=sample_prompt, outputs=message)
|
185 |
+
|
186 |
# Update the chatbot with the new message and response
|
187 |
def handle_send(message: str, system_message: str, max_tokens: int, temperature: float, top_p: float):
|
188 |
history = load_chat_history()
|
|
|
213 |
|
214 |
submit_feedback.click(fn=submit_user_feedback, inputs=feedback, outputs=[gr.Textbox(value="Feedback submitted! Thank you.", lines=1, placeholder="")])
|
215 |
|
|
|
216 |
# Launch the Gradio interface
|
217 |
if __name__ == "__main__":
|
218 |
demo.launch()
|