File size: 2,138 Bytes
f558c35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e601bf1
f558c35
e601bf1
f558c35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# from Registry.agents.tech_support_chat.agent import ChatSupportAgent
# # /home/matias/dev/my-agents/Registry/agents/tech_support_agent/agent.py
# import gradio as gr
# # from agent import ChatSupportAgent  # assumes this matches your current structure


# agent = ChatSupportAgent(agent_name="tech_support_agent")



# def chat_with_agent(user_input, history):
#     print("USER INPUT: ", user_input)
#     result = agent.run(user_input)['result']
#     print("RESULT: ", result)
#     response = result#.get("result", "⚠️ Error: No response!!")
#     history.append((user_input, response))
#     return history, history

# with gr.Blocks() as demo:
#     gr.Markdown("# πŸ’» Tech Support Chat Agent\nHelping you solve your tech issues!")

#     chatbot = gr.Chatbot()
#     msg = gr.Textbox(label="Your question", placeholder="e.g. Why is Python indentation important?")
#     state = gr.State([])

#     def submit_message(user_message, history):
#         return chat_with_agent(user_message, history)

#     msg.submit(submit_message, [msg, state], [chatbot, state])
#     gr.Button("Clear").click(lambda: ([], []), None, [chatbot, state])

#     gr.Markdown("---")
#     gr.Markdown("Built with ❀️ using Cerebrum & Gradio")

# demo.launch()



# app.py
import gradio as gr
from Registry.agents.tech_support_chat.agent import ChatSupportAgent

agent = ChatSupportAgent(agent_name="demo_agent")

def chat_with_agent(user_input, history):
    result = agent.run(user_input)['result']
    history.append((user_input, result))
    return history, history

with gr.Blocks() as demo:
    gr.Markdown("## πŸ“š Demo Agent – AI Research Assistant")
    chatbot = gr.Chatbot()
    msg = gr.Textbox(label="Ask a question", placeholder="e.g. Recent papers about LLMs in education")
    state = gr.State([])

    def submit_message(user_message, history):
        return chat_with_agent(user_message, history)

    msg.submit(submit_message, [msg, state], [chatbot, state])
    gr.Button("Clear").click(lambda: ([], []), None, [chatbot, state])
    gr.Markdown("πŸ€– Powered by Cerebrum")

if __name__ == "__main__":
    demo.launch()