clean up interface
Browse files
app.py
CHANGED
|
@@ -45,11 +45,8 @@ class SessionChatBot:
|
|
| 45 |
|
| 46 |
def respond(self, message, history):
|
| 47 |
messages = [{"role": "system", "content": SYSTEM_PROMPT}]
|
| 48 |
-
for
|
| 49 |
-
|
| 50 |
-
messages.append({"role": "user", "content": user_msg})
|
| 51 |
-
if bot_msg:
|
| 52 |
-
messages.append({"role": "assistant", "content": bot_msg})
|
| 53 |
messages.append({"role": "user", "content": message})
|
| 54 |
|
| 55 |
response = ""
|
|
@@ -63,7 +60,7 @@ class SessionChatBot:
|
|
| 63 |
token = chunk.choices[0].delta.content
|
| 64 |
if token:
|
| 65 |
response += token
|
| 66 |
-
yield response
|
| 67 |
|
| 68 |
# Save log after full response
|
| 69 |
self.append_to_session_log(message, response)
|
|
@@ -109,8 +106,9 @@ with gr.Blocks() as demo:
|
|
| 109 |
chatbot_ui = gr.ChatInterface(
|
| 110 |
fn=create_chatbot(),
|
| 111 |
title="BoundrAI",
|
|
|
|
| 112 |
textbox=gr.Textbox(placeholder="Ask me anything...", container=True),
|
| 113 |
-
)
|
| 114 |
|
| 115 |
report_btn = gr.Button("Report Companion Interaction")
|
| 116 |
status_box = gr.Textbox(label="Report Status", interactive=False)
|
|
|
|
| 45 |
|
| 46 |
def respond(self, message, history):
|
| 47 |
messages = [{"role": "system", "content": SYSTEM_PROMPT}]
|
| 48 |
+
for msg in history:
|
| 49 |
+
messages.append(msg)
|
|
|
|
|
|
|
|
|
|
| 50 |
messages.append({"role": "user", "content": message})
|
| 51 |
|
| 52 |
response = ""
|
|
|
|
| 60 |
token = chunk.choices[0].delta.content
|
| 61 |
if token:
|
| 62 |
response += token
|
| 63 |
+
yield {"role": "assistant", "content": response}
|
| 64 |
|
| 65 |
# Save log after full response
|
| 66 |
self.append_to_session_log(message, response)
|
|
|
|
| 106 |
chatbot_ui = gr.ChatInterface(
|
| 107 |
fn=create_chatbot(),
|
| 108 |
title="BoundrAI",
|
| 109 |
+
type="messages", # Switch to OpenAI-style message format
|
| 110 |
textbox=gr.Textbox(placeholder="Ask me anything...", container=True),
|
| 111 |
+
)
|
| 112 |
|
| 113 |
report_btn = gr.Button("Report Companion Interaction")
|
| 114 |
status_box = gr.Textbox(label="Report Status", interactive=False)
|