File size: 1,647 Bytes
9fc4259
 
 
 
 
 
9fd2f28
9fc4259
9fd2f28
9fc4259
 
 
9fd2f28
 
 
 
9fc4259
9fd2f28
 
 
9fc4259
9fd2f28
 
 
9fc4259
9fd2f28
 
 
9fc4259
9fd2f28
 
 
 
9fc4259
9fd2f28
 
 
 
9fc4259
9fd2f28
 
 
 
 
9fc4259
9fd2f28
9fc4259
9fd2f28
9fc4259
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# app.py

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

# Init agents
codebot = ProgrammerAgent()
bugbot = DebuggerAgent()

def chat_with_bots(user_input):
    # Send same input to both agents
    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 inputs
    log_message_to_firestore(msg_to_codebot.to_dict())
    log_message_to_firestore(msg_to_bugbot.to_dict())

    # Get both responses
    reply_codebot = codebot.receive_message(msg_to_codebot)
    reply_bugbot = bugbot.receive_message(msg_to_bugbot)

    # Log responses
    log_message_to_firestore(reply_codebot.to_dict())
    log_message_to_firestore(reply_bugbot.to_dict())

    # Format reply for chat
    full_reply = f"""
🧠 **CodeBot** (Programmer):  
{reply_codebot.content}

🐞 **BugBot** (Debugger):  
{reply_bugbot.content}
"""
    return full_reply.strip()

# Gradio UI
with gr.Blocks(title="BotTalks: Chat with 2 AI Agents") as demo:
    gr.Markdown("# 🤖 BotTalks: Chat with 2 AI Friends!\nAsk anything and see how both agents respond.")
    input_box = gr.Textbox(label="You", placeholder="Ask something like: How do I reverse a list?", lines=2)
    output_box = gr.Textbox(label="Responses", lines=10)

    send_btn = gr.Button("Send")

    send_btn.click(chat_with_bots, inputs=input_box, outputs=output_box)

demo.launch()