NexAItools commited on
Commit
2e6cea2
·
verified ·
1 Parent(s): 451c5c7

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +95 -0
app.py ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ import sys
4
+ from datetime import datetime
5
+
6
+ # Add the src directory to the path
7
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'src')))
8
+
9
+ # Import Ashus AI components
10
+ from src.orchestration.task_manager import TaskManager, TaskStatus
11
+ from src.orchestration.agent_manager import AgentManager
12
+ from src.orchestration.message_router import MessageRouter
13
+ from src.agents.executor import ExecutorAgent
14
+ from src.tools.registry import ToolRegistry
15
+ from src.tools.web_browser import WebBrowserTool
16
+ from src.tools.file_system import FileSystemTool
17
+ from src.tools.code_execution import CodeExecutionTool
18
+
19
+ # Initialize components
20
+ task_manager = TaskManager()
21
+ agent_manager = AgentManager()
22
+ message_router = MessageRouter()
23
+ tool_registry = ToolRegistry()
24
+
25
+ # Register tools
26
+ tool_registry.register_tool(WebBrowserTool())
27
+ tool_registry.register_tool(FileSystemTool())
28
+ tool_registry.register_tool(CodeExecutionTool())
29
+
30
+ # Initialize executor agent
31
+ executor_agent = ExecutorAgent(
32
+ agent_id="executor",
33
+ name="Executor Agent",
34
+ task_manager=task_manager,
35
+ tool_registry=tool_registry
36
+ )
37
+
38
+ agent_manager.register_agent("executor", executor_agent)
39
+ message_router.subscribe("executor", executor_agent.process_message)
40
+
41
+ # Chat history
42
+ chat_history = []
43
+
44
+ def process_message(message, history):
45
+ task = task_manager.create_task(
46
+ description=message,
47
+ user_id="web_user"
48
+ )
49
+ processed_task = executor_agent.process_task(task)
50
+ if processed_task.status == TaskStatus.COMPLETED and processed_task.result:
51
+ response = processed_task.result.get("message", "Task completed successfully.")
52
+ else:
53
+ response = "I'm sorry, I couldn't process your request."
54
+
55
+ timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
56
+ history.append((message, response))
57
+ return history
58
+
59
+ def clear_chat():
60
+ chat_history.clear()
61
+ return []
62
+
63
+ with gr.Blocks(title="Ashus AI", theme=gr.themes.Soft()) as demo:
64
+ gr.Markdown("# Ashus AI")
65
+ gr.Markdown("Welcome to Ashus AI, an open-source autonomous agent system.")
66
+
67
+ with gr.Row():
68
+ with gr.Column(scale=3):
69
+ chatbot = gr.Chatbot(label="Chat with Ashus AI")
70
+ msg = gr.Textbox(placeholder="Ask me anything...", show_label=False)
71
+
72
+ with gr.Row():
73
+ submit_btn = gr.Button("Submit", variant="primary")
74
+ clear_btn = gr.Button("Clear")
75
+
76
+ with gr.Column(scale=1):
77
+ gr.Markdown("### About Ashus AI")
78
+ gr.Markdown("""
79
+ Ashus AI is an open-source autonomous agent system.
80
+
81
+ **Features:**
82
+ - Multi-agent architecture
83
+ - Tools: Web browsing, file system, code execution
84
+ - Task-based processing
85
+ - FastAPI backend
86
+
87
+ [View on GitHub](https://github.com/yourusername/ashus-ai)
88
+ """)
89
+
90
+ submit_btn.click(process_message, inputs=[msg, chatbot], outputs=[chatbot])
91
+ msg.submit(process_message, inputs=[msg, chatbot], outputs=[chatbot])
92
+ clear_btn.click(clear_chat, outputs=[chatbot])
93
+
94
+ if __name__ == "__main__":
95
+ demo.launch()