|
|
|
|
|
import gradio as gr |
|
from agents.programmer import ProgrammerAgent |
|
from agents.debugger import DebuggerAgent |
|
from agents.base_agent import ACPMessage |
|
from firebase.firebase_config import log_message_to_firestore |
|
|
|
|
|
codebot = ProgrammerAgent() |
|
bugbot = DebuggerAgent() |
|
|
|
chat_history = [] |
|
|
|
def chat_with_bots(user_input): |
|
global chat_history |
|
|
|
|
|
chat_history.append(("π₯ You", f"<span class='user-msg'>{user_input}</span>")) |
|
|
|
|
|
msg_to_codebot = ACPMessage(sender="User", receiver="CodeBot", performative="request", content=user_input) |
|
msg_to_bugbot = ACPMessage(sender="User", receiver="BugBot", performative="request", content=user_input) |
|
|
|
|
|
log_message_to_firestore(msg_to_codebot.to_dict()) |
|
log_message_to_firestore(msg_to_bugbot.to_dict()) |
|
|
|
|
|
reply_codebot = codebot.receive_message(msg_to_codebot) |
|
reply_bugbot = bugbot.receive_message(msg_to_bugbot) |
|
|
|
|
|
log_message_to_firestore(reply_codebot.to_dict()) |
|
log_message_to_firestore(reply_bugbot.to_dict()) |
|
|
|
|
|
chat_history.append(("π© CodeBot", f"<span class='codebot-msg'>{reply_codebot.content}</span>")) |
|
chat_history.append(("π§ BugBot", f"<span class='bugbot-msg'>{reply_bugbot.content}</span>")) |
|
|
|
return chat_history |
|
|
|
|
|
with gr.Blocks(css=""" |
|
.user-msg { |
|
background-color: #ffdddd; |
|
padding: 8px 12px; |
|
border-radius: 10px; |
|
display: inline-block; |
|
} |
|
|
|
.codebot-msg { |
|
background-color: #ddffdd; |
|
padding: 8px 12px; |
|
border-radius: 10px; |
|
display: inline-block; |
|
} |
|
|
|
.bugbot-msg { |
|
background-color: #ffe5cc; |
|
padding: 8px 12px; |
|
border-radius: 10px; |
|
display: inline-block; |
|
} |
|
|
|
.gr-chatbot { |
|
height: 250px !important; |
|
overflow-y: auto; |
|
} |
|
""") as demo: |
|
gr.Markdown("### Mn.o1 ACP Based Bots") |
|
|
|
chatbot = gr.Chatbot(label="Chat", bubble_full_width=False, show_copy_button=True) |
|
|
|
with gr.Row(): |
|
msg_input = gr.Textbox(placeholder="Ask a question...", lines=1, show_label=False) |
|
send_btn = gr.Button("Send", variant="primary") |
|
|
|
send_btn.click(chat_with_bots, inputs=msg_input, outputs=chatbot) |
|
msg_input.submit(chat_with_bots, inputs=msg_input, outputs=chatbot) |
|
gr.Markdown( |
|
""" |
|
<div style='text-align: right; font-size: 0.9em; padding-top: 20px;'> |
|
π Connect with me: |
|
<a href="https://www.linkedin.com/in/aymnsk" target="_blank">LinkedIn</a> | |
|
<a href="https://github.com/aymnsk" target="_blank">GitHub</a> | |
|
<a href="https://www.instagram.com/damnn_aymn/" target="_blank">Instagram</a> | |
|
<a href="https://huggingface.co/aymnsk" target="_blank">HF</a> |
|
</div> |
|
""", |
|
elem_id="footer" |
|
) |
|
|
|
|
|
demo.launch() |
|
|