From 64fc06840711b6936522c1d4e63a3a79118c74b4 Mon Sep 17 00:00:00 2001 From: yatiraj Date: Wed, 11 Mar 2026 20:09:41 +0530 Subject: [PATCH 1/4] feat: add agent marketplace swarm example with skill-based routing --- examples/agent_marketplace_swarm/.env.example | 2 + examples/agent_marketplace_swarm/README.md | 296 ++++++++++++++++++ examples/agent_marketplace_swarm/__init__.py | 0 .../bindu_super_agent.py | 63 ++++ .../agent_marketplace_swarm/orchestrator.py | 48 +++ .../agent_marketplace_swarm/research_agent.py | 24 ++ .../agent_marketplace_swarm/router_agent.py | 17 + .../agent_marketplace_swarm/skill_registry.py | 35 +++ .../agent-marketplace-routing/skill.yaml | 8 + .../summarizer_agent.py | 24 ++ .../translator_agent.py | 24 ++ 11 files changed, 541 insertions(+) create mode 100644 examples/agent_marketplace_swarm/.env.example create mode 100644 examples/agent_marketplace_swarm/README.md create mode 100644 examples/agent_marketplace_swarm/__init__.py create mode 100644 examples/agent_marketplace_swarm/bindu_super_agent.py create mode 100644 examples/agent_marketplace_swarm/orchestrator.py create mode 100644 examples/agent_marketplace_swarm/research_agent.py create mode 100644 examples/agent_marketplace_swarm/router_agent.py create mode 100644 examples/agent_marketplace_swarm/skill_registry.py create mode 100644 examples/agent_marketplace_swarm/skills/agent-marketplace-routing/skill.yaml create mode 100644 examples/agent_marketplace_swarm/summarizer_agent.py create mode 100644 examples/agent_marketplace_swarm/translator_agent.py diff --git a/examples/agent_marketplace_swarm/.env.example b/examples/agent_marketplace_swarm/.env.example new file mode 100644 index 00000000..f2842743 --- /dev/null +++ b/examples/agent_marketplace_swarm/.env.example @@ -0,0 +1,2 @@ +GROQ_API_KEY=your_groq_api_key_here +MODEL_NAME=llama-3.3-70b-versatile \ No newline at end of file diff --git a/examples/agent_marketplace_swarm/README.md b/examples/agent_marketplace_swarm/README.md new file mode 100644 index 00000000..bf2eb535 --- /dev/null +++ b/examples/agent_marketplace_swarm/README.md @@ -0,0 +1,296 @@ +# 🌻 Bindu Agent Marketplace Swarm + +## A Dynamic Multi-Agent Marketplace Built with Bindu + +This project demonstrates how to build a skill-driven AI agent marketplace using Bindu — the identity, communication, and orchestration layer for AI agents. + +Instead of relying on a single large AI system, this architecture enables multiple specialized agents to collaborate through dynamic skill discovery and intelligent routing. + +The system showcases how autonomous agents can register capabilities, discover tasks, and execute them collaboratively, forming a scalable agent ecosystem. + +## 🌍 Why Agent Marketplaces? + +Traditional AI applications typically rely on one model performing all tasks. + +This approach has several limitations: + +- Poor scalability +- Lack of specialization +- Difficult maintenance +- Limited extensibility + +Agent marketplaces solve this by enabling multiple specialized agents to collaborate. + +Each agent: + +- Advertises its skills +- Receives tasks dynamically +- Executes specialized operations +- Returns results through a shared orchestration layer + +Bindu provides the infrastructure to support these decentralized AI ecosystems. + +## 🧠 Core Concept + +This project models an AI agent marketplace. + +Agents dynamically register their capabilities in a Skill Registry. + +When a user sends a request: + +1. The Router Agent analyzes the request +2. The Skill Registry identifies which agent has the required capability +3. The Orchestrator executes the appropriate agent +4. The result is returned to the user + +This enables flexible, scalable multi-agent collaboration. + +## 🏗️ System Architecture + +The system consists of four primary components: + +| Component | Role | +|-----------|------| +| Router Agent | Determines which skill is required for a request | +| Skill Registry | Stores agent capabilities and enables agent discovery | +| Specialized Agents | Perform specific tasks (research, summarization, translation) | +| Orchestrator | Coordinates routing and agent execution | + +## 🔁 Execution Flow + +``` +User Request + ↓ +Router Agent + ↓ +Skill Registry Lookup + ↓ +Agent Discovery + ↓ +Selected Agent Executes Task + ↓ +Response Returned +``` + +Example queries: + +- Explain quantum computing +- Summarize this article +- Translate hello to Spanish + +## 🤖 Agents in the Marketplace + +### Research Agent + +Handles knowledge and explanation queries. + +Example: +``` +Explain quantum computing +``` + +### Summarizer Agent + +Condenses long content into concise summaries. + +Example: +``` +Summarize this article about artificial intelligence +``` + +### Translator Agent + +Translates text between languages. + +Example: +``` +Translate hello how are you to Spanish +``` + +## 🧩 Dynamic Skill Registration + +Unlike traditional static routing systems, agents register their skills dynamically with the registry. + +Example: + +```python +registry.register_agent("research_agent", ["research", "explain"]) +registry.register_agent("summarizer_agent", ["summarize"]) +registry.register_agent("translator_agent", ["translate"]) +``` + +This allows new agents to be added easily without modifying the router logic. + +## 📁 Project Structure + +``` +examples/ +└── agent_marketplace_swarm/ + ├── bindu_super_agent.py + ├── orchestrator.py + ├── router_agent.py + ├── skill_registry.py + ├── research_agent.py + ├── summarizer_agent.py + ├── translator_agent.py + ├── env.example + ├── README.md + └── skills/ + └── agent-marketplace-routing/ + └── skill.yaml +``` + +## ⚙️ Technologies Used + +| Technology | Purpose | +|------------|---------| +| Bindu | Agent identity and runtime framework | +| Groq LLM | High-performance language model inference | +| Python | Core application logic | +| FastAPI | Testing interface | +| dotenv | Environment configuration | + +## 🚀 Quick Start + +### 1️⃣ Clone the Repository + +```bash +git clone https://github.com/getbindu/bindu.git +cd bindu +``` + +### 2️⃣ Create Virtual Environment + +```bash +python -m venv .venv +``` + +Activate environment: + +**Windows** +```bash +.venv\Scripts\activate +``` + +**macOS / Linux** +```bash +source .venv/bin/activate +``` + +### 3️⃣ Install Dependencies + +```bash +pip install -e . +pip install groq python-dotenv fastapi uvicorn +``` + +### 4️⃣ Configure Environment Variables + +Create `.env` file inside: + +``` +examples/agent_marketplace_swarm/ +``` + +Add: + +``` +GROQ_API_KEY=your_groq_api_key +MODEL_NAME=llama-3.3-70b-versatile +``` + +### 5️⃣ Run the Bindu Agent + +```bash +cd examples/agent_marketplace_swarm +python bindu_super_agent.py +``` + +The agent will start at: + +``` +http://localhost:3773 +``` + +### 6️⃣ Test the Agent (Swagger) + +Run the test API: + +```bash +uvicorn test_api:app --reload +``` + +Open: + +``` +http://127.0.0.1:8000/docs +``` + +Example request: + +```json +{ + "message": "Explain quantum computing" +} +``` + +## 🌻 How This Demonstrates Bindu's Vision + +Bindu is designed to support Internet-scale AI agents. + +This example demonstrates key principles: + +**Agent Identity** + +Each agent operates as a unique entity within the system. + +**Skill Discovery** + +Agents advertise capabilities through the Skill Registry. + +**Agent Collaboration** + +Agents collaborate through an orchestration pipeline. + +**Extensible Ecosystem** + +New agents can be added without modifying existing infrastructure. + +## 🔮 Possible Extensions + +Future improvements could include: + +- Autonomous agent negotiation +- Economic agent marketplaces +- Reputation systems for agents +- Distributed multi-agent swarms +- Agent-to-agent communication protocols + +## 🧬 Philosophy + +Most AI systems focus on building: + +> larger models + +Bindu focuses on building: + +> better systems + +This project demonstrates that complex intelligence emerges from collaboration between specialized agents. + +## ⭐ Why This Example Exists + +This example helps developers: + +- Understand multi-agent architectures +- Learn dynamic skill routing +- Build scalable AI agent systems +- Explore Bindu-based agent orchestration + +## 🌍 The Bigger Picture + +The future of AI will not be a single agent. + +It will be a network of collaborating agents. + +This project is a small step toward that vision. diff --git a/examples/agent_marketplace_swarm/__init__.py b/examples/agent_marketplace_swarm/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/examples/agent_marketplace_swarm/bindu_super_agent.py b/examples/agent_marketplace_swarm/bindu_super_agent.py new file mode 100644 index 00000000..0a599f9f --- /dev/null +++ b/examples/agent_marketplace_swarm/bindu_super_agent.py @@ -0,0 +1,63 @@ +from dotenv import load_dotenv +load_dotenv() + +from bindu.penguin.bindufy import bindufy +from orchestrator import Orchestrator +from typing import List, Dict, Any + +orchestrator = Orchestrator() + + +def handler(messages: list[dict[str, str]]) -> str: + """ + Protocol-compliant handler for Bindu. + + Safely extracts user input from message history + and routes it through the agent marketplace swarm. + """ + + # -------- Input Validation -------- + + if not isinstance(messages, list): + return "Invalid input format: messages must be a list." + + if not messages: + return "No input message received." + + last_msg = messages[-1] + + if not isinstance(last_msg, dict): + return "Invalid message structure." + + user_input = last_msg.get("content") + + if not user_input or not isinstance(user_input, str): + return "Empty or invalid message content." + + # -------- Swarm Execution -------- + + try: + result = orchestrator.run(user_input) + return result + + except Exception as e: + return f"Internal agent error: {str(e)}" + + +if __name__ == "__main__": + config = { + "author": "yatirajkulkarni143@gmail.com", + "name": "agent-marketplace-swarm", + "description": "Skill-based agent marketplace demonstrating routing between research, summarization, and translation agents using Bindu.", + "capabilities": {"streaming": True}, + "deployment": { + "url": "http://localhost:3773", + "expose": True, + "cors_origins": ["http://localhost:5173"] + }, + "skills": ["skills/agent-marketplace-routing"], + "storage": {"type": "memory"}, + "scheduler": {"type": "memory"} + } + + bindufy(config=config, handler=handler) \ No newline at end of file diff --git a/examples/agent_marketplace_swarm/orchestrator.py b/examples/agent_marketplace_swarm/orchestrator.py new file mode 100644 index 00000000..8267d55a --- /dev/null +++ b/examples/agent_marketplace_swarm/orchestrator.py @@ -0,0 +1,48 @@ +""" +Orchestrator + +Coordinates agent discovery and execution. +""" + +from router_agent import RouterAgent +from skill_registry import SkillRegistry + +from research_agent import ResearchAgent +from summarizer_agent import SummarizerAgent +from translator_agent import TranslatorAgent + + +class Orchestrator: + + def __init__(self): + + self.registry = SkillRegistry() + + # initialize agents + self.research_agent = ResearchAgent() + self.summarizer_agent = SummarizerAgent() + self.translator_agent = TranslatorAgent() + + # register agents dynamically + self.registry.register_agent("research_agent", ["research", "explain"]) + self.registry.register_agent("summarizer_agent", ["summarize"]) + self.registry.register_agent("translator_agent", ["translate"]) + + self.router = RouterAgent(self.registry) + + self.agents = { + "research_agent": self.research_agent, + "summarizer_agent": self.summarizer_agent, + "translator_agent": self.translator_agent, + } + + async def run(self, request: str): + + agent_name = self.router.route(request) + + if not agent_name: + return "No suitable agent found." + + agent = self.agents.get(agent_name) + + return await agent.run(request) \ No newline at end of file diff --git a/examples/agent_marketplace_swarm/research_agent.py b/examples/agent_marketplace_swarm/research_agent.py new file mode 100644 index 00000000..4fd1cab4 --- /dev/null +++ b/examples/agent_marketplace_swarm/research_agent.py @@ -0,0 +1,24 @@ +import os +from groq import Groq + +MODEL = os.getenv("MODEL_NAME", "llama-3.3-70b-versatile") + +client = Groq(api_key=os.getenv("GROQ_API_KEY")) + + +class ResearchAgent: + + async def run(self, query: str): + + prompt = f""" + Provide a clear explanation for the following topic. + + {query} + """ + + response = client.chat.completions.create( + model=MODEL, + messages=[{"role": "user", "content": prompt}], + ) + + return response.choices[0].message.content \ No newline at end of file diff --git a/examples/agent_marketplace_swarm/router_agent.py b/examples/agent_marketplace_swarm/router_agent.py new file mode 100644 index 00000000..604e5812 --- /dev/null +++ b/examples/agent_marketplace_swarm/router_agent.py @@ -0,0 +1,17 @@ +""" +Router Agent + +Routes incoming requests to the appropriate agent. +""" + + +class RouterAgent: + + def __init__(self, registry): + self.registry = registry + + def route(self, request: str): + + agent = self.registry.find_agent(request) + + return agent \ No newline at end of file diff --git a/examples/agent_marketplace_swarm/skill_registry.py b/examples/agent_marketplace_swarm/skill_registry.py new file mode 100644 index 00000000..16b9e2c4 --- /dev/null +++ b/examples/agent_marketplace_swarm/skill_registry.py @@ -0,0 +1,35 @@ +""" +Skill Registry + +Central marketplace where agents advertise their capabilities. +""" + + +class SkillRegistry: + + def __init__(self): + self.skill_to_agent = {} + + def register_agent(self, agent_name: str, skills: list[str]): + """ + Register an agent and the skills it provides. + """ + for skill in skills: + self.skill_to_agent[skill] = agent_name + + def find_agent(self, request: str): + """ + Find best agent based on request. + """ + + request = request.lower() + + for skill, agent in self.skill_to_agent.items(): + if skill in request: + return agent + + # fallback logic + if "explain" in request or "what is" in request: + return self.skill_to_agent.get("research") + + return None \ No newline at end of file diff --git a/examples/agent_marketplace_swarm/skills/agent-marketplace-routing/skill.yaml b/examples/agent_marketplace_swarm/skills/agent-marketplace-routing/skill.yaml new file mode 100644 index 00000000..d952010e --- /dev/null +++ b/examples/agent_marketplace_swarm/skills/agent-marketplace-routing/skill.yaml @@ -0,0 +1,8 @@ +name: agent-marketplace-routing +description: Skill-based routing between research, summarization and translation agents +version: 0.1.0 + +capabilities: + - summarize text + - translate text + - research questions \ No newline at end of file diff --git a/examples/agent_marketplace_swarm/summarizer_agent.py b/examples/agent_marketplace_swarm/summarizer_agent.py new file mode 100644 index 00000000..19a6ddbe --- /dev/null +++ b/examples/agent_marketplace_swarm/summarizer_agent.py @@ -0,0 +1,24 @@ +import os +from groq import Groq + +MODEL = os.getenv("MODEL_NAME", "llama-3.3-70b-versatile") + +client = Groq(api_key=os.getenv("GROQ_API_KEY")) + + +class SummarizerAgent: + + async def run(self, text: str): + + prompt = f""" + Summarize the following text in a concise paragraph. + + {text} + """ + + response = client.chat.completions.create( + model=MODEL, + messages=[{"role": "user", "content": prompt}], + ) + + return response.choices[0].message.content \ No newline at end of file diff --git a/examples/agent_marketplace_swarm/translator_agent.py b/examples/agent_marketplace_swarm/translator_agent.py new file mode 100644 index 00000000..226edf2c --- /dev/null +++ b/examples/agent_marketplace_swarm/translator_agent.py @@ -0,0 +1,24 @@ +import os +from groq import Groq + +MODEL = os.getenv("MODEL_NAME", "llama-3.3-70b-versatile") + +client = Groq(api_key=os.getenv("GROQ_API_KEY")) + + +class TranslatorAgent: + + async def run(self, text: str): + + prompt = f""" + Translate the following text to Spanish. + + {text} + """ + + response = client.chat.completions.create( + model=MODEL, + messages=[{"role": "user", "content": prompt}], + ) + + return response.choices[0].message.content \ No newline at end of file From 7ada77bae71098668d57e71b75ec10af1d6f7659 Mon Sep 17 00:00:00 2001 From: yatiraj Date: Wed, 18 Mar 2026 11:39:44 +0530 Subject: [PATCH 2/4] refactor: simplify structure, remove unnecessary files, align with bindu examples --- examples/agent_marketplace_swarm/.env.example | 4 +-- .../agent_marketplace_swarm/orchestrator.py | 22 ++------------ .../agent_marketplace_swarm/router_agent.py | 13 +++++---- .../summarizer_agent.py | 29 ++++++++----------- .../translator_agent.py | 29 ++++++++----------- 5 files changed, 37 insertions(+), 60 deletions(-) diff --git a/examples/agent_marketplace_swarm/.env.example b/examples/agent_marketplace_swarm/.env.example index f2842743..a165ddea 100644 --- a/examples/agent_marketplace_swarm/.env.example +++ b/examples/agent_marketplace_swarm/.env.example @@ -1,2 +1,2 @@ -GROQ_API_KEY=your_groq_api_key_here -MODEL_NAME=llama-3.3-70b-versatile \ No newline at end of file +OPENAI_API_KEY=your_openrouter_key +OPENAI_API_BASE=https://openrouter.ai/api/v1 \ No newline at end of file diff --git a/examples/agent_marketplace_swarm/orchestrator.py b/examples/agent_marketplace_swarm/orchestrator.py index 8267d55a..bd46878f 100644 --- a/examples/agent_marketplace_swarm/orchestrator.py +++ b/examples/agent_marketplace_swarm/orchestrator.py @@ -5,9 +5,6 @@ """ from router_agent import RouterAgent -from skill_registry import SkillRegistry - -from research_agent import ResearchAgent from summarizer_agent import SummarizerAgent from translator_agent import TranslatorAgent @@ -16,24 +13,11 @@ class Orchestrator: def __init__(self): - self.registry = SkillRegistry() - - # initialize agents - self.research_agent = ResearchAgent() - self.summarizer_agent = SummarizerAgent() - self.translator_agent = TranslatorAgent() - - # register agents dynamically - self.registry.register_agent("research_agent", ["research", "explain"]) - self.registry.register_agent("summarizer_agent", ["summarize"]) - self.registry.register_agent("translator_agent", ["translate"]) - - self.router = RouterAgent(self.registry) + self.router = RouterAgent() self.agents = { - "research_agent": self.research_agent, - "summarizer_agent": self.summarizer_agent, - "translator_agent": self.translator_agent, + "summarizer_agent": SummarizerAgent(), + "translator_agent": TranslatorAgent(), } async def run(self, request: str): diff --git a/examples/agent_marketplace_swarm/router_agent.py b/examples/agent_marketplace_swarm/router_agent.py index 604e5812..ae50498d 100644 --- a/examples/agent_marketplace_swarm/router_agent.py +++ b/examples/agent_marketplace_swarm/router_agent.py @@ -7,11 +7,14 @@ class RouterAgent: - def __init__(self, registry): - self.registry = registry - def route(self, request: str): - agent = self.registry.find_agent(request) + request = request.lower() + + if "summarize" in request: + return "summarizer_agent" + + elif "translate" in request: + return "translator_agent" - return agent \ No newline at end of file + return None \ No newline at end of file diff --git a/examples/agent_marketplace_swarm/summarizer_agent.py b/examples/agent_marketplace_swarm/summarizer_agent.py index 19a6ddbe..0c6fb5fb 100644 --- a/examples/agent_marketplace_swarm/summarizer_agent.py +++ b/examples/agent_marketplace_swarm/summarizer_agent.py @@ -1,24 +1,19 @@ -import os -from groq import Groq +""" +Summarizer Agent +""" -MODEL = os.getenv("MODEL_NAME", "llama-3.3-70b-versatile") - -client = Groq(api_key=os.getenv("GROQ_API_KEY")) +from agno.agent import Agent +from agno.models.openrouter import OpenRouter class SummarizerAgent: - async def run(self, text: str): - - prompt = f""" - Summarize the following text in a concise paragraph. - - {text} - """ - - response = client.chat.completions.create( - model=MODEL, - messages=[{"role": "user", "content": prompt}], + def __init__(self): + self.agent = Agent( + model=OpenRouter(id="openai/gpt-oss-120b"), + instructions="Summarize the given text clearly and concisely.", ) - return response.choices[0].message.content \ No newline at end of file + async def run(self, text: str): + response = self.agent.run(text) + return response.content \ No newline at end of file diff --git a/examples/agent_marketplace_swarm/translator_agent.py b/examples/agent_marketplace_swarm/translator_agent.py index 226edf2c..f631eaff 100644 --- a/examples/agent_marketplace_swarm/translator_agent.py +++ b/examples/agent_marketplace_swarm/translator_agent.py @@ -1,24 +1,19 @@ -import os -from groq import Groq +""" +Translator Agent +""" -MODEL = os.getenv("MODEL_NAME", "llama-3.3-70b-versatile") - -client = Groq(api_key=os.getenv("GROQ_API_KEY")) +from agno.agent import Agent +from agno.models.openrouter import OpenRouter class TranslatorAgent: - async def run(self, text: str): - - prompt = f""" - Translate the following text to Spanish. - - {text} - """ - - response = client.chat.completions.create( - model=MODEL, - messages=[{"role": "user", "content": prompt}], + def __init__(self): + self.agent = Agent( + model=OpenRouter(id="openai/gpt-oss-120b"), + instructions="Translate the given text to Spanish.", ) - return response.choices[0].message.content \ No newline at end of file + async def run(self, text: str): + response = self.agent.run(text) + return response.content \ No newline at end of file From 7e73a0c3ff65cabc18cf48781351aaa3c96836f1 Mon Sep 17 00:00:00 2001 From: yatiraj Date: Wed, 18 Mar 2026 11:47:42 +0530 Subject: [PATCH 3/4] refactor: remove research agent and skill registry to simplify example --- .../agent_marketplace_swarm/research_agent.py | 24 ------------- .../agent_marketplace_swarm/skill_registry.py | 35 ------------------- 2 files changed, 59 deletions(-) delete mode 100644 examples/agent_marketplace_swarm/research_agent.py delete mode 100644 examples/agent_marketplace_swarm/skill_registry.py diff --git a/examples/agent_marketplace_swarm/research_agent.py b/examples/agent_marketplace_swarm/research_agent.py deleted file mode 100644 index 4fd1cab4..00000000 --- a/examples/agent_marketplace_swarm/research_agent.py +++ /dev/null @@ -1,24 +0,0 @@ -import os -from groq import Groq - -MODEL = os.getenv("MODEL_NAME", "llama-3.3-70b-versatile") - -client = Groq(api_key=os.getenv("GROQ_API_KEY")) - - -class ResearchAgent: - - async def run(self, query: str): - - prompt = f""" - Provide a clear explanation for the following topic. - - {query} - """ - - response = client.chat.completions.create( - model=MODEL, - messages=[{"role": "user", "content": prompt}], - ) - - return response.choices[0].message.content \ No newline at end of file diff --git a/examples/agent_marketplace_swarm/skill_registry.py b/examples/agent_marketplace_swarm/skill_registry.py deleted file mode 100644 index 16b9e2c4..00000000 --- a/examples/agent_marketplace_swarm/skill_registry.py +++ /dev/null @@ -1,35 +0,0 @@ -""" -Skill Registry - -Central marketplace where agents advertise their capabilities. -""" - - -class SkillRegistry: - - def __init__(self): - self.skill_to_agent = {} - - def register_agent(self, agent_name: str, skills: list[str]): - """ - Register an agent and the skills it provides. - """ - for skill in skills: - self.skill_to_agent[skill] = agent_name - - def find_agent(self, request: str): - """ - Find best agent based on request. - """ - - request = request.lower() - - for skill, agent in self.skill_to_agent.items(): - if skill in request: - return agent - - # fallback logic - if "explain" in request or "what is" in request: - return self.skill_to_agent.get("research") - - return None \ No newline at end of file From d750a9b16697c4dee85ffc81591e7351c0cdd543 Mon Sep 17 00:00:00 2001 From: yatiraj Date: Sat, 21 Mar 2026 13:51:23 +0530 Subject: [PATCH 4/4] fix: resolve async issue, improve routing, and stabilize agent responses --- .../bindu_super_agent.py | 6 ++-- .../agent_marketplace_swarm/orchestrator.py | 30 +++++++++++++++---- .../agent_marketplace_swarm/router_agent.py | 16 ++++++++-- .../summarizer_agent.py | 24 +++++++++++++-- .../translator_agent.py | 16 ++++++++-- 5 files changed, 76 insertions(+), 16 deletions(-) diff --git a/examples/agent_marketplace_swarm/bindu_super_agent.py b/examples/agent_marketplace_swarm/bindu_super_agent.py index 0a599f9f..357226ac 100644 --- a/examples/agent_marketplace_swarm/bindu_super_agent.py +++ b/examples/agent_marketplace_swarm/bindu_super_agent.py @@ -1,6 +1,7 @@ from dotenv import load_dotenv load_dotenv() +import asyncio from bindu.penguin.bindufy import bindufy from orchestrator import Orchestrator from typing import List, Dict, Any @@ -37,7 +38,8 @@ def handler(messages: list[dict[str, str]]) -> str: # -------- Swarm Execution -------- try: - result = orchestrator.run(user_input) + # FIX: Run async orchestrator properly + result = asyncio.run(orchestrator.run(user_input)) return result except Exception as e: @@ -48,7 +50,7 @@ def handler(messages: list[dict[str, str]]) -> str: config = { "author": "yatirajkulkarni143@gmail.com", "name": "agent-marketplace-swarm", - "description": "Skill-based agent marketplace demonstrating routing between research, summarization, and translation agents using Bindu.", + "description": "Skill-based agent marketplace demonstrating routing between summarization and translation agents using Bindu.", "capabilities": {"streaming": True}, "deployment": { "url": "http://localhost:3773", diff --git a/examples/agent_marketplace_swarm/orchestrator.py b/examples/agent_marketplace_swarm/orchestrator.py index bd46878f..fcd475fe 100644 --- a/examples/agent_marketplace_swarm/orchestrator.py +++ b/examples/agent_marketplace_swarm/orchestrator.py @@ -2,6 +2,7 @@ Orchestrator Coordinates agent discovery and execution. +Routes user request to the correct agent. """ from router_agent import RouterAgent @@ -12,21 +13,38 @@ class Orchestrator: def __init__(self): - + # Initialize router self.router = RouterAgent() + # Initialize available agents self.agents = { "summarizer_agent": SummarizerAgent(), "translator_agent": TranslatorAgent(), } async def run(self, request: str): + """ + Main execution function. + Routes the request to the correct agent and returns the response. + """ + + try: + # Step 1: Route request to correct agent + agent_name = self.router.route(request) + + if not agent_name: + return "No suitable agent found for this request." + + # Step 2: Get agent instance + agent = self.agents.get(agent_name) - agent_name = self.router.route(request) + if not agent: + return "Selected agent not available." - if not agent_name: - return "No suitable agent found." + # Step 3: Execute agent task + response = await agent.run(request) - agent = self.agents.get(agent_name) + return response - return await agent.run(request) \ No newline at end of file + except Exception as e: + return f"Orchestrator error: {str(e)}" \ No newline at end of file diff --git a/examples/agent_marketplace_swarm/router_agent.py b/examples/agent_marketplace_swarm/router_agent.py index ae50498d..8382be94 100644 --- a/examples/agent_marketplace_swarm/router_agent.py +++ b/examples/agent_marketplace_swarm/router_agent.py @@ -2,19 +2,29 @@ Router Agent Routes incoming requests to the appropriate agent. +Simple keyword-based routing. """ class RouterAgent: def route(self, request: str): + """ + Route the request to the correct agent based on keywords. + """ request = request.lower() - if "summarize" in request: + # Summarization / Explanation tasks + if "summarize" in request or "summary" in request: return "summarizer_agent" - elif "translate" in request: + if "explain" in request or "what is" in request: + return "summarizer_agent" + + # Translation tasks + if "translate" in request: return "translator_agent" - return None \ No newline at end of file + # Default fallback + return "summarizer_agent" \ No newline at end of file diff --git a/examples/agent_marketplace_swarm/summarizer_agent.py b/examples/agent_marketplace_swarm/summarizer_agent.py index 0c6fb5fb..30b6c33f 100644 --- a/examples/agent_marketplace_swarm/summarizer_agent.py +++ b/examples/agent_marketplace_swarm/summarizer_agent.py @@ -1,5 +1,7 @@ """ Summarizer Agent + +Handles summarization and explanation tasks. """ from agno.agent import Agent @@ -11,9 +13,25 @@ class SummarizerAgent: def __init__(self): self.agent = Agent( model=OpenRouter(id="openai/gpt-oss-120b"), - instructions="Summarize the given text clearly and concisely.", + instructions=( + "You are a helpful assistant. " + "If the user asks to summarize, provide a concise summary. " + "If the user asks to explain a topic, provide a clear explanation." + ), ) async def run(self, text: str): - response = self.agent.run(text) - return response.content \ No newline at end of file + """ + Execute summarization or explanation task. + """ + + try: + response = self.agent.run(text) + + if response and hasattr(response, "content"): + return response.content + + return "No response generated." + + except Exception as e: + return f"Summarizer agent error: {str(e)}" \ No newline at end of file diff --git a/examples/agent_marketplace_swarm/translator_agent.py b/examples/agent_marketplace_swarm/translator_agent.py index f631eaff..cb07eea6 100644 --- a/examples/agent_marketplace_swarm/translator_agent.py +++ b/examples/agent_marketplace_swarm/translator_agent.py @@ -15,5 +15,17 @@ def __init__(self): ) async def run(self, text: str): - response = self.agent.run(text) - return response.content \ No newline at end of file + """ + Execute translation task. + """ + + try: + response = self.agent.run(text) + + if response and hasattr(response, "content"): + return response.content + + return "No response generated." + + except Exception as e: + return f"Translator agent error: {str(e)}" \ No newline at end of file