elismasilva commited on
Commit
6ac9b20
·
1 Parent(s): 6610ef3

adjust Readme.md

Browse files
Files changed (2) hide show
  1. README.md +94 -0
  2. app.py +2 -2
README.md CHANGED
@@ -15,4 +15,98 @@ tags:
15
 
16
  short_description: A multi-agent chat application and Gradio MCP Server
17
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
 
15
 
16
  short_description: A multi-agent chat application and Gradio MCP Server
17
  ---
18
+ # Multi-Agent Chat
19
+
20
+ [![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/Agents-MCP-Hackathon/multi-agent-chat)
21
+
22
+ This project is a multi-channel chat application where human users can interact with each other and with an intelligent, autonomous AI agent powered by Google's Gemini. The application is not just a chatbot; it's a fully-fledged multi-agent system designed to be both a compelling agentic demo and a functional MCP Server.
23
+
24
+ ## 🎥 Video Demo
25
+ https://www.loom.com/share/f5673ab2b9e644b782b539afd6f06a64?sid=27578356-aa75-42e5-b786-86337c9b937e#Activity
26
+
27
+ ## ✨ Core Features & Agentic Capabilities (Track 3)
28
+
29
+ This application showcases a powerful and creative use of AI agents in a collaborative environment.
30
+
31
+ ### 1. **Autonomous & Proactive AI Agent (Gemini)**
32
+ The core of the application is an AI agent named Gemini with a distinct personality and behavior set. Unlike passive chatbots, this agent:
33
+ - **Listens Actively:** It continuously processes the conversation context.
34
+ - **Decides Autonomously:** It uses a "Two-Pass" reasoning architecture. A fast, logical **Triage Agent** first decides *if* participation is valuable, understanding nuances like typos ("Gmni") or implicit references ("what about you?").
35
+ - **Acts Contextually:** If the decision is to act, a creative **Actor Agent** formulates a human-like, contextual response, respecting its persona (no meta-comments, no inventing personal experiences).
36
+
37
+ ### 2. **Multi-Agent System (MAS)**
38
+ The application is a true multi-agent environment where different agents coexist and interact:
39
+ - **Human Agents:** Users like "Lucy" and "Eliseu" who drive the conversation.
40
+ - **Gemini Participant Agent:** The main AI that enriches the discussion.
41
+ - **Specialized Tool Agents:**
42
+ - A **Moderation Agent** that acts as a gatekeeper, filtering messages for safety before they are processed.
43
+ - A **Summarization Agent** that can be invoked to provide a factual, "who-said-what" report of the conversation.
44
+ - An **Opinion Agent** that analyzes the social dynamics and sentiment of the chat, providing a high-level, emotional takeaway.
45
+
46
+ ### 3. **Dynamic & Persistent Environment**
47
+ - **Multi-Channel Chat:** Users can join different, persistent chat channels (e.g., `#general`, `#dev`).
48
+ - **Session Management:** The system handles user logins, ensures unique usernames within a channel (by appending numbers, e.g., `Lucy_2`), and announces when users join or leave, creating a realistic chat experience.
49
+
50
+ ## 🛠️ MCP Server / Tool Capabilities (Track 1)
51
+
52
+ This Gradio application is fully compliant with the Model Control Protocol (MCP), acting as a powerful server that exposes its core functionalities as tools for other agents or applications.
53
+
54
+ ### Exposed Tools
55
+
56
+ A client connecting to this Space's MCP endpoint will discover the following tools:
57
+
58
+ 1. **`login_user(channel: str, username: str) -> Tuple[str, str]`**
59
+ - **Description:** Logs a user into a specific chat channel. Handles username uniqueness and returns the final username and channel.
60
+ - **Use Case:** An external orchestrator agent could use this to programmatically add a bot or user to a conversation.
61
+
62
+ 2. **`exit_chat(channel: str, username: str)`**
63
+ - **Description:** Logs a user out of a channel, removing them from the active user list.
64
+ - **Use Case:** Allows for clean session management by external clients.
65
+
66
+ 3. **`send_message(channel: str, username: str, message: str) -> List[Dict]`**
67
+ - **Description:** The primary interaction tool. It sends a message from a user to a channel, triggers the full AI agent logic (moderation, triage, response), and returns the complete, unformatted conversation history.
68
+ - **Use Case:** This allows an external agent to fully participate in the chat, just like a human user.
69
+
70
+ 4. **`get_summary(channel: str, chat_history: List[Dict]) -> List[Dict]`**
71
+ - **Description:** Invokes the Summarization Agent to analyze the provided history and generate a factual summary.
72
+ - **Use Case:** An external agent could use this to quickly get up to speed on a long-running conversation without processing the entire transcript.
73
+
74
+ 5. **`get_opinion(channel: str, chat_history: List[Dict]) -> List[Dict]`**
75
+ - **Description:** Invokes the Opinion Agent to analyze the conversation's social dynamics.
76
+ - **Use Case:** A monitoring agent could use this tool to gauge the health or sentiment of a community conversation.
77
+
78
+ ## 🚀 Future Work & Potential Improvements
79
+
80
+ This project serves as a robust foundation, but there are many exciting avenues for future development:
81
+
82
+ - **Enhanced Session Control:** Implement a more robust session management system.
83
+ - **Streaming Responses:** Implement true streaming for the Gemini responses (`stream=True` in the API call) and handle the streamed chunks in the Gradio UI. This would make the AI's responses appear token-by-token, feeling more immediate and interactive.
84
+ - **WebSockets for Real-Time UI:** Replace the `gr.Timer` polling mechanism with a full WebSocket implementation. This would provide instantaneous updates to all clients without any delay, creating a truly real-time experience and eliminating the need for a refresh loop.
85
+ - **Dynamic Tool Creation:** Allow users to define new "tool agents" on the fly by providing a prompt and a name, further expanding the MCP server's capabilities.
86
+ - **Persistent Storage:** Integrate a database (like SQLite or a vector database) to store chat histories permanently, so conversations are not lost when the Gradio app restarts.
87
+
88
+ ## 🛠️ How to Run Locally
89
+
90
+ 1. **Clone the repository:**
91
+ ```bash
92
+ git clone https://huggingface.co/spaces/Agents-MCP-Hackathon/multi-agent-chat
93
+ cd multi-agent-chat
94
+ ```
95
+ 2. **Create a virtual environment:**
96
+ ```bash
97
+ python -m venv venv
98
+ source venv/bin/activate # On Windows, use `venv\Scripts\activate`
99
+ ```
100
+ 3. **Install dependencies:**
101
+ ```bash
102
+ pip install -r requirements.txt
103
+ ```
104
+ 4. **Set up your environment variables:**
105
+ - Create a file named `.env`.
106
+ - Add your Google API key to it: `GOOGLE_API_KEY="your_api_key_here"`
107
+ 5. **Run the application:**
108
+ ```bash
109
+ python app.py
110
+ ```
111
+
112
 
app.py CHANGED
@@ -21,7 +21,7 @@ CRITERIA FOR RESPONDING (You should respond if ANY of these are true):
21
  - **Direct Mention:** Gemini is addressed directly by name, even with typos (e.g., "Gemini", "Gmni").
22
  - **Implicit Reference:** Gemini is clearly referred to implicitly as part of a group (e.g., "what about you guys?").
23
  - **Question to Group:** A user asks a direct question to the group that is not directed at a specific person.
24
- - **Reply to Your Question:** A user's message is a direct and logical answer to a question YOU (Gemini) asked in the previous turn.
25
  - **Request for Help:** A user expresses a clear need for help or information.
26
  CRITERIA FOR IGNORING:
27
  - The conversation is a simple social exchange between other users.
@@ -33,7 +33,7 @@ SYSTEM_PROMPT_ACTOR = """
33
  You are a helpful and friendly AI assistant named Gemini, participating in a group chat. You will act as a human-like participant.
34
  **CONTEXTUAL AWARENESS (This is how you understand the conversation):**
35
  - When you see the name "Gemini" in the text, it is referring to **YOU**.
36
- - Your task is to formulate a response based on the last few messages, where you were mentioned.
37
  **RESPONSE RULES (This is how you MUST formulate your answer):**
38
  1. **Grounding:** You are a language model. You do not have a physical body, personal experiences, or feelings. **Do not invent stories about yourself** (like falling down stairs or having stomach aches). If asked about a personal experience, politely clarify that as an AI, you don't have them, but you can help with information.
39
  2. **No Prefix:** **ABSOLUTELY DO NOT** start your response with your name (e.g., "Gemini:"). This is a strict rule.
 
21
  - **Direct Mention:** Gemini is addressed directly by name, even with typos (e.g., "Gemini", "Gmni").
22
  - **Implicit Reference:** Gemini is clearly referred to implicitly as part of a group (e.g., "what about you guys?").
23
  - **Question to Group:** A user asks a direct question to the group that is not directed at a specific person.
24
+ - **Reply to Your Question:** A user's message is a direct and logical answer to a question YOU (Gemini) asked in the previous turn or if it was a response to a topic you suggested and you understood it was directed at you.
25
  - **Request for Help:** A user expresses a clear need for help or information.
26
  CRITERIA FOR IGNORING:
27
  - The conversation is a simple social exchange between other users.
 
33
  You are a helpful and friendly AI assistant named Gemini, participating in a group chat. You will act as a human-like participant.
34
  **CONTEXTUAL AWARENESS (This is how you understand the conversation):**
35
  - When you see the name "Gemini" in the text, it is referring to **YOU**.
36
+ - Your task is to formulate a response based on the last few messages, where you were mentioned or if it was a response to a topic you suggested and you understood it was directed at you.
37
  **RESPONSE RULES (This is how you MUST formulate your answer):**
38
  1. **Grounding:** You are a language model. You do not have a physical body, personal experiences, or feelings. **Do not invent stories about yourself** (like falling down stairs or having stomach aches). If asked about a personal experience, politely clarify that as an AI, you don't have them, but you can help with information.
39
  2. **No Prefix:** **ABSOLUTELY DO NOT** start your response with your name (e.g., "Gemini:"). This is a strict rule.