agentensemble 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agentensemble/__init__.py +76 -0
- agentensemble/agents/__init__.py +32 -0
- agentensemble/agents/base.py +84 -0
- agentensemble/agents/hybrid_agent.py +147 -0
- agentensemble/agents/rag_agent.py +92 -0
- agentensemble/agents/react_agent.py +118 -0
- agentensemble/agents/stategraph_agent.py +97 -0
- agentensemble/agents/structured_agent.py +210 -0
- agentensemble/orchestration/__init__.py +22 -0
- agentensemble/orchestration/ensemble.py +145 -0
- agentensemble/orchestration/pipeline.py +27 -0
- agentensemble/orchestration/supervisor.py +27 -0
- agentensemble/orchestration/swarm.py +27 -0
- agentensemble/py.typed +3 -0
- agentensemble/testing/__init__.py +16 -0
- agentensemble/testing/benchmark.py +87 -0
- agentensemble/testing/comparison.py +82 -0
- agentensemble/testing/metrics.py +81 -0
- agentensemble/tools/__init__.py +20 -0
- agentensemble/tools/rag.py +226 -0
- agentensemble/tools/registry.py +83 -0
- agentensemble/tools/scraper.py +123 -0
- agentensemble/tools/search.py +155 -0
- agentensemble/tools/validator.py +51 -0
- agentensemble/utils/__init__.py +11 -0
- agentensemble/utils/llm.py +109 -0
- agentensemble-0.1.0.dist-info/METADATA +407 -0
- agentensemble-0.1.0.dist-info/RECORD +30 -0
- agentensemble-0.1.0.dist-info/WHEEL +5 -0
- agentensemble-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Validation Tool
|
|
3
|
+
|
|
4
|
+
Data validation and quality assurance for agents.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import Any, Optional
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ValidationTool:
|
|
11
|
+
"""
|
|
12
|
+
Validation tool for agent outputs.
|
|
13
|
+
|
|
14
|
+
Provides validation and quality checks.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(self, validation_mode: str = "fast"):
|
|
18
|
+
"""
|
|
19
|
+
Initialize validation tool.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
validation_mode: Validation mode ("fast", "deep")
|
|
23
|
+
"""
|
|
24
|
+
self.name = "validator"
|
|
25
|
+
self.validation_mode = validation_mode
|
|
26
|
+
|
|
27
|
+
def run(self, value: str, context: Optional[dict[str, Any]] = None, **kwargs) -> dict[str, Any]:
|
|
28
|
+
"""
|
|
29
|
+
Validate a value.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
value: Value to validate
|
|
33
|
+
context: Optional context for validation
|
|
34
|
+
**kwargs: Additional parameters
|
|
35
|
+
|
|
36
|
+
Returns:
|
|
37
|
+
Validation result with confidence and justifications
|
|
38
|
+
"""
|
|
39
|
+
# Placeholder - implement actual validation logic
|
|
40
|
+
return {
|
|
41
|
+
"valid": True,
|
|
42
|
+
"confidence": 0.9,
|
|
43
|
+
"justifications": [],
|
|
44
|
+
"value": value,
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
def __call__(
|
|
48
|
+
self, value: str, context: Optional[dict[str, Any]] = None, **kwargs
|
|
49
|
+
) -> dict[str, Any]:
|
|
50
|
+
"""Make tool callable"""
|
|
51
|
+
return self.run(value, context, **kwargs)
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"""
|
|
2
|
+
LLM Utilities
|
|
3
|
+
|
|
4
|
+
Provides helper functions for initializing Mistral AI models.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
from typing import Optional
|
|
9
|
+
from dotenv import load_dotenv
|
|
10
|
+
|
|
11
|
+
# Load environment variables
|
|
12
|
+
load_dotenv()
|
|
13
|
+
|
|
14
|
+
try:
|
|
15
|
+
from langchain_mistralai import ChatMistralAI, MistralAIEmbeddings
|
|
16
|
+
MISTRAL_AVAILABLE = True
|
|
17
|
+
except ImportError:
|
|
18
|
+
MISTRAL_AVAILABLE = False
|
|
19
|
+
ChatMistralAI = None
|
|
20
|
+
MistralAIEmbeddings = None
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def get_mistral_api_key() -> str:
|
|
24
|
+
"""
|
|
25
|
+
Get Mistral API key from environment.
|
|
26
|
+
|
|
27
|
+
Returns:
|
|
28
|
+
Mistral API key
|
|
29
|
+
|
|
30
|
+
Raises:
|
|
31
|
+
ValueError: If API key not found
|
|
32
|
+
"""
|
|
33
|
+
api_key = os.getenv("MISTRAL_API_KEY")
|
|
34
|
+
if not api_key:
|
|
35
|
+
raise ValueError(
|
|
36
|
+
"MISTRAL_API_KEY not found in environment. "
|
|
37
|
+
"Set it in .env file or environment variables."
|
|
38
|
+
)
|
|
39
|
+
return api_key
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def get_mistral_model(
|
|
43
|
+
model: str = "mistral-large-latest",
|
|
44
|
+
temperature: float = 0.7,
|
|
45
|
+
api_key: Optional[str] = None,
|
|
46
|
+
) -> ChatMistralAI:
|
|
47
|
+
"""
|
|
48
|
+
Initialize Mistral chat model.
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
model: Model name (default: "mistral-large-latest")
|
|
52
|
+
temperature: Temperature for generation
|
|
53
|
+
api_key: Optional API key (uses MISTRAL_API_KEY env var if not provided)
|
|
54
|
+
|
|
55
|
+
Returns:
|
|
56
|
+
ChatMistralAI instance
|
|
57
|
+
|
|
58
|
+
Raises:
|
|
59
|
+
ImportError: If langchain-mistralai not installed
|
|
60
|
+
ValueError: If API key not found
|
|
61
|
+
"""
|
|
62
|
+
if not MISTRAL_AVAILABLE:
|
|
63
|
+
raise ImportError(
|
|
64
|
+
"langchain-mistralai is required. "
|
|
65
|
+
"Install with: pip install langchain-mistralai"
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
if not api_key:
|
|
69
|
+
api_key = get_mistral_api_key()
|
|
70
|
+
|
|
71
|
+
return ChatMistralAI(
|
|
72
|
+
model=model,
|
|
73
|
+
temperature=temperature,
|
|
74
|
+
mistral_api_key=api_key,
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def get_mistral_embeddings(
|
|
79
|
+
model: str = "mistral-embed",
|
|
80
|
+
api_key: Optional[str] = None,
|
|
81
|
+
) -> MistralAIEmbeddings:
|
|
82
|
+
"""
|
|
83
|
+
Initialize Mistral embeddings model.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
model: Embedding model name (default: "mistral-embed")
|
|
87
|
+
api_key: Optional API key (uses MISTRAL_API_KEY env var if not provided)
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
MistralAIEmbeddings instance
|
|
91
|
+
|
|
92
|
+
Raises:
|
|
93
|
+
ImportError: If langchain-mistralai not installed
|
|
94
|
+
ValueError: If API key not found
|
|
95
|
+
"""
|
|
96
|
+
if not MISTRAL_AVAILABLE:
|
|
97
|
+
raise ImportError(
|
|
98
|
+
"langchain-mistralai is required. "
|
|
99
|
+
"Install with: pip install langchain-mistralai"
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
if not api_key:
|
|
103
|
+
api_key = get_mistral_api_key()
|
|
104
|
+
|
|
105
|
+
return MistralAIEmbeddings(
|
|
106
|
+
model=model,
|
|
107
|
+
mistral_api_key=api_key,
|
|
108
|
+
)
|
|
109
|
+
|
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentensemble
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Orchestrate AI agents in perfect harmony - A comprehensive Python framework for building, testing, and orchestrating multi-agent AI systems
|
|
5
|
+
Author-email: Irfan Ali <irfanali29@hotmail.com>
|
|
6
|
+
Maintainer-email: Irfan Ali <irfanali29@hotmail.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/irfanalidv/AgentEnsemble
|
|
9
|
+
Project-URL: Documentation, https://github.com/irfanalidv/AgentEnsemble#readme
|
|
10
|
+
Project-URL: Repository, https://github.com/irfanalidv/AgentEnsemble
|
|
11
|
+
Project-URL: Issues, https://github.com/irfanalidv/AgentEnsemble/issues
|
|
12
|
+
Keywords: ai-agents,multi-agent,orchestration,langgraph,langchain,rag,agent-testing,agentic-ai,state-graph,react-agent
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Requires-Python: >=3.9
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
Requires-Dist: langchain>=0.1.0
|
|
25
|
+
Requires-Dist: langchain-core>=0.1.0
|
|
26
|
+
Requires-Dist: langchain-community>=0.0.20
|
|
27
|
+
Requires-Dist: langchain-mistralai>=0.1.0
|
|
28
|
+
Requires-Dist: langgraph>=0.0.20
|
|
29
|
+
Requires-Dist: pydantic>=2.0.0
|
|
30
|
+
Requires-Dist: typing-extensions>=4.5.0
|
|
31
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
34
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
35
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
36
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
37
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
38
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
39
|
+
Provides-Extra: observability
|
|
40
|
+
Requires-Dist: langsmith>=0.1.0; extra == "observability"
|
|
41
|
+
Requires-Dist: opentelemetry-api>=1.20.0; extra == "observability"
|
|
42
|
+
Provides-Extra: rag
|
|
43
|
+
Requires-Dist: chromadb>=0.4.0; extra == "rag"
|
|
44
|
+
Requires-Dist: sentence-transformers>=2.2.0; extra == "rag"
|
|
45
|
+
Requires-Dist: langchain-text-splitters>=0.0.1; extra == "rag"
|
|
46
|
+
Requires-Dist: beautifulsoup4>=4.12.0; extra == "rag"
|
|
47
|
+
Requires-Dist: langchain-mistralai>=0.1.0; extra == "rag"
|
|
48
|
+
Provides-Extra: search
|
|
49
|
+
Requires-Dist: duckduckgo-search>=4.0.0; extra == "search"
|
|
50
|
+
Requires-Dist: google-search-results>=2.4.2; extra == "search"
|
|
51
|
+
Provides-Extra: all
|
|
52
|
+
Requires-Dist: agentensemble[dev,observability,rag,search]; extra == "all"
|
|
53
|
+
|
|
54
|
+
# AgentEnsemble 🎭
|
|
55
|
+
|
|
56
|
+
**Orchestrate AI agents in perfect harmony**
|
|
57
|
+
|
|
58
|
+
AgentEnsemble is a **simple, practical Python library** for building and orchestrating AI agents. Perfect for real-world tasks like web search, research, document Q&A, and multi-agent collaboration.
|
|
59
|
+
|
|
60
|
+
**Key Features:**
|
|
61
|
+
|
|
62
|
+
- 🚀 **Simple API** - Get started in minutes
|
|
63
|
+
- 🔍 **Web Search** - Serper API (with DuckDuckGo fallback)
|
|
64
|
+
- 📚 **RAG Support** - Document Q&A with Mistral AI
|
|
65
|
+
- 🤝 **Multi-Agent** - Coordinate multiple agents easily
|
|
66
|
+
- 🔓 **Open-Source** - Uses LangChain Community Tools
|
|
67
|
+
|
|
68
|
+
**Powered by Mistral AI** for LLM operations. **Open-source by default** - uses free tools from LangChain Community Tools.
|
|
69
|
+
|
|
70
|
+
[](https://www.python.org/downloads/)
|
|
71
|
+
[](LICENSE)
|
|
72
|
+
[](https://github.com/psf/black)
|
|
73
|
+
[](https://pypi.org/project/agentensemble/)
|
|
74
|
+
[](https://pepy.tech/projects/agentensemble)
|
|
75
|
+
|
|
76
|
+
## 📦 Installation
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# Basic installation
|
|
80
|
+
pip install agentensemble
|
|
81
|
+
|
|
82
|
+
# With optional features
|
|
83
|
+
pip install agentensemble[search] # Search tools (Serper API + DuckDuckGo)
|
|
84
|
+
pip install agentensemble[rag] # RAG capabilities
|
|
85
|
+
pip install agentensemble[all] # All features
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Verify Installation
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
python -c "from agentensemble import HybridAgent; print('✅ Installed!')"
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Output:**
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
✅ Installed!
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## ✨ Features
|
|
101
|
+
|
|
102
|
+
### 🤖 **Reference Agent Implementations**
|
|
103
|
+
|
|
104
|
+
- **ReAct Agent**: Simple reasoning + acting pattern
|
|
105
|
+
- **StateGraph Agent**: Custom nodes with intelligent routing
|
|
106
|
+
- **RAG-Enhanced Agent**: Scraping → embedding → retrieval with fallback strategies
|
|
107
|
+
- **Hybrid Agent**: Advanced iterative refinement with early stopping
|
|
108
|
+
- **Structured Agent**: Returns structured output (Pydantic models, JSON) using [LangChain's structured output](https://docs.langchain.com/oss/python/langchain/structured-output)
|
|
109
|
+
|
|
110
|
+
### 🎼 **Orchestration Patterns**
|
|
111
|
+
|
|
112
|
+
- **Supervisor Pattern**: Central coordinator managing specialized agents
|
|
113
|
+
- **Swarm Pattern**: Decentralized agent collaboration
|
|
114
|
+
- **Pipeline Pattern**: Sequential agent workflows
|
|
115
|
+
- **Ensemble Pattern**: Full multi-agent coordination
|
|
116
|
+
|
|
117
|
+
### 🔧 **Tool Ecosystem** (Open-Source by Default)
|
|
118
|
+
|
|
119
|
+
- Built-in tools using **LangChain Community Tools**:
|
|
120
|
+
- **SearchTool**: Serper API (default if API key provided) or DuckDuckGo (fallback) ⭐
|
|
121
|
+
- **ScraperTool**: Playwright-based web scraping
|
|
122
|
+
- **RAGTool**: Document loaders + vector stores (ChromaDB)
|
|
123
|
+
- **ValidationTool**: Quality assurance
|
|
124
|
+
- **No paid APIs required** - All tools work with free, open-source options
|
|
125
|
+
- Tool registry for dynamic tool management
|
|
126
|
+
- Direct integration with `langchain_community.tools`
|
|
127
|
+
- Custom tool creation framework
|
|
128
|
+
|
|
129
|
+
### 📊 **Testing & Comparison Framework**
|
|
130
|
+
|
|
131
|
+
- Benchmark suite for agent evaluation
|
|
132
|
+
- Multi-agent comparison engine
|
|
133
|
+
- Performance metrics: success rate, cost, execution time
|
|
134
|
+
- Interactive dashboards and reports
|
|
135
|
+
|
|
136
|
+
### 👁️ **Observability**
|
|
137
|
+
|
|
138
|
+
- Token usage and cost tracking
|
|
139
|
+
- LangSmith/OpenTelemetry integration
|
|
140
|
+
- Structured logging
|
|
141
|
+
- Agent execution tracing
|
|
142
|
+
|
|
143
|
+
## 🚀 Quick Start
|
|
144
|
+
|
|
145
|
+
### Environment Setup
|
|
146
|
+
|
|
147
|
+
Create a `.env` file for API keys:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# Required for search (default provider)
|
|
151
|
+
SERPER_API_KEY=your-serper-api-key-here
|
|
152
|
+
|
|
153
|
+
# Required for RAG/LLM features
|
|
154
|
+
MISTRAL_API_KEY=your-mistral-api-key-here
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Note:** SearchTool defaults to Serper API if `SERPER_API_KEY` is provided, otherwise falls back to DuckDuckGo (free, no API key needed).
|
|
158
|
+
|
|
159
|
+
**Note**:
|
|
160
|
+
|
|
161
|
+
- **Open-source by default** - Uses free tools from [LangChain Community Tools](https://docs.langchain.com/oss/python/integrations/tools/)
|
|
162
|
+
- Uses **Mistral AI** for all LLM operations (chat models and embeddings)
|
|
163
|
+
- Tools follow [LangChain RAG patterns](https://docs.langchain.com/oss/python/langchain/rag):
|
|
164
|
+
- `SerpAPIQueryRun` for search (default) or `DuckDuckGoSearchRun` (fallback) ⭐
|
|
165
|
+
- `WebBaseLoader` + `RecursiveCharacterTextSplitter` for RAG indexing
|
|
166
|
+
- `MistralAIEmbeddings` for embeddings
|
|
167
|
+
- `InMemoryVectorStore` / `Chroma` for vector storage
|
|
168
|
+
- `@tool` decorator for agentic RAG tools
|
|
169
|
+
|
|
170
|
+
### Structured Output
|
|
171
|
+
|
|
172
|
+
**Use Case:** Extract structured product review data from unstructured text
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
from pydantic import BaseModel, Field
|
|
176
|
+
from agentensemble.agents import StructuredAgent
|
|
177
|
+
|
|
178
|
+
class ProductReview(BaseModel):
|
|
179
|
+
product_name: str = Field(description="Name of the product")
|
|
180
|
+
rating: int = Field(description="Rating out of 5")
|
|
181
|
+
pros: list[str] = Field(description="List of positive aspects")
|
|
182
|
+
cons: list[str] = Field(description="List of negative aspects")
|
|
183
|
+
summary: str = Field(description="Overall summary of the review")
|
|
184
|
+
|
|
185
|
+
agent = StructuredAgent(response_format=ProductReview)
|
|
186
|
+
|
|
187
|
+
review_text = """
|
|
188
|
+
I recently purchased the iPhone 15 Pro Max and here's my honest review.
|
|
189
|
+
Rating: 4 out of 5 stars
|
|
190
|
+
Pros: Excellent camera quality, Fast A17 Pro chip, Great battery life, Premium build quality
|
|
191
|
+
Cons: Very expensive, Heavy and bulky, Limited storage on base model
|
|
192
|
+
Summary: Great phone with top-tier features, but the high price and weight might not be for everyone.
|
|
193
|
+
"""
|
|
194
|
+
|
|
195
|
+
result = agent.run(review_text)
|
|
196
|
+
print(result['structured_response'])
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
**Actual Output:**
|
|
200
|
+
|
|
201
|
+
```python
|
|
202
|
+
ProductReview(
|
|
203
|
+
product_name='iPhone 15 Pro Max',
|
|
204
|
+
rating=4,
|
|
205
|
+
pros=['Excellent camera quality', 'Fast A17 Pro chip', 'Great battery life', 'Premium build quality'],
|
|
206
|
+
cons=['Very expensive', 'Heavy and bulky', 'Limited storage on base model'],
|
|
207
|
+
summary='Great phone with top-tier features, but the high price and weight might not be for everyone.'
|
|
208
|
+
)
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## 📚 Documentation
|
|
212
|
+
|
|
213
|
+
- [Examples](examples/) - See `examples/` directory for usage examples
|
|
214
|
+
|
|
215
|
+
## 🏗️ Architecture
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
agentensemble/
|
|
219
|
+
├── agents/ # Reference agent implementations
|
|
220
|
+
├── orchestration/ # Orchestration patterns
|
|
221
|
+
├── tools/ # Tool ecosystem
|
|
222
|
+
├── testing/ # Testing & comparison framework
|
|
223
|
+
├── state/ # State management
|
|
224
|
+
└── observability/ # Monitoring & tracking
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## 🔍 Examples
|
|
228
|
+
|
|
229
|
+
### Example 1: Search Tool
|
|
230
|
+
|
|
231
|
+
**Use Case:** Research latest breakthroughs in quantum computing
|
|
232
|
+
|
|
233
|
+
```python
|
|
234
|
+
from agentensemble.tools import SearchTool
|
|
235
|
+
|
|
236
|
+
search = SearchTool() # Uses Serper API (or DuckDuckGo fallback)
|
|
237
|
+
result = search.run("What are the latest breakthroughs in quantum computing in 2024?")
|
|
238
|
+
print(result)
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
**Actual Output:**
|
|
242
|
+
|
|
243
|
+
```
|
|
244
|
+
1. Increased Qubit Stability and Error Correction · 2. Quantum Supremacy Milestones · 3. Advancements in Quantum Algorithms · 4. Commercial Quantum ... Explore the top quantum research stories of 2024, from advancements in quantum chemistry to developments in quantum AI. Google has developed a new quantum chip called Willow, which significantly reduces errors as it scales up, a major breakthrough in quantum error ... Error correction, a critical element of quantum control, emerged as a key innovation...
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Example 2: ReAct Agent
|
|
248
|
+
|
|
249
|
+
**Use Case:** Research AI applications in healthcare
|
|
250
|
+
|
|
251
|
+
```python
|
|
252
|
+
from agentensemble.agents import ReActAgent
|
|
253
|
+
from agentensemble.tools import SearchTool
|
|
254
|
+
|
|
255
|
+
agent = ReActAgent(name="research_agent", tools=[SearchTool()], max_iterations=3)
|
|
256
|
+
result = agent.run("What are the most promising applications of AI agents in healthcare in 2024?")
|
|
257
|
+
print(result)
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
**Actual Output:**
|
|
261
|
+
|
|
262
|
+
```python
|
|
263
|
+
{
|
|
264
|
+
'result': 'AI agents can aid clinicians in providing more accurate diagnoses by analyzing medical data—including lab results, digital scans, patient ... AI agents in healthcare are already helping with diagnostics, managing schedules, monitoring patients, handling documentation, and more. 10 strategic healthcare AI agent use cases · 1. Intelligent prior authorization assistant · 2. Chart-gap tracker · 3. Charge-edit auto-review agent. AI agents are reshaping healthcare in 2025, automating paperwork, enabling round-the-clock support, and optimizing clinical processes.',
|
|
265
|
+
'metadata': {
|
|
266
|
+
'iterations': 1,
|
|
267
|
+
'tool_calls': 1,
|
|
268
|
+
'agent': 'research_agent'
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Example 3: Hybrid Agent
|
|
274
|
+
|
|
275
|
+
**Use Case:** Research autonomous vehicle technology trends and challenges
|
|
276
|
+
|
|
277
|
+
```python
|
|
278
|
+
from agentensemble import HybridAgent
|
|
279
|
+
from agentensemble.tools import SearchTool
|
|
280
|
+
|
|
281
|
+
agent = HybridAgent(name="hybrid_research", tools=[SearchTool()], max_iterations=5)
|
|
282
|
+
result = agent.run("What are the key trends and challenges in autonomous vehicle technology in 2024?")
|
|
283
|
+
print(result)
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
**Actual Output:**
|
|
287
|
+
|
|
288
|
+
```python
|
|
289
|
+
{
|
|
290
|
+
'result': 'The global autonomous vehicle (AV) market surpassed $41 billion in 2024 and is expected to reach nearly $115 billion by 2029 (Statista). April 2024 saw Tesla integrate its vision-based occupancy network, replacing ultrasonic sensors, enhancing safety and autonomy. Top 5 Technical Challenges in Autonomous Vehicle Development & Possible Solutions · Challenge 1: Safety Assurance, Liability, and Cybersecurity. Level 3 autonomy poses a major liability shift from driver to automaker...',
|
|
291
|
+
'metadata': {
|
|
292
|
+
'iterations': 3,
|
|
293
|
+
'actions_taken': [],
|
|
294
|
+
'agent': 'hybrid_research'
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### Example 4: Structured Output
|
|
300
|
+
|
|
301
|
+
**Use Case:** Extract structured research summary from unstructured text
|
|
302
|
+
|
|
303
|
+
```python
|
|
304
|
+
from pydantic import BaseModel, Field
|
|
305
|
+
from agentensemble.agents import StructuredAgent
|
|
306
|
+
|
|
307
|
+
class ResearchSummary(BaseModel):
|
|
308
|
+
topic: str = Field(description="Main research topic")
|
|
309
|
+
key_findings: list[str] = Field(description="List of key findings")
|
|
310
|
+
impact: str = Field(description="Potential impact or significance")
|
|
311
|
+
sources_count: int = Field(description="Number of sources referenced")
|
|
312
|
+
|
|
313
|
+
agent = StructuredAgent(
|
|
314
|
+
name="research_summarizer",
|
|
315
|
+
response_format=ResearchSummary
|
|
316
|
+
)
|
|
317
|
+
|
|
318
|
+
result = agent.run("""
|
|
319
|
+
Topic: AI Agents in Financial Services
|
|
320
|
+
Key Findings:
|
|
321
|
+
1. AI agents are automating 60% of routine financial analysis tasks
|
|
322
|
+
2. Fraud detection accuracy improved by 45% with agent-based systems
|
|
323
|
+
3. Customer service response time reduced by 70%
|
|
324
|
+
Sources: 15 research papers and industry reports
|
|
325
|
+
Impact: Transformative - reshaping how financial institutions operate
|
|
326
|
+
""")
|
|
327
|
+
|
|
328
|
+
print(result['structured_response'])
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
**Actual Output:**
|
|
332
|
+
|
|
333
|
+
```python
|
|
334
|
+
ResearchSummary(
|
|
335
|
+
topic='AI Agents in Financial Services',
|
|
336
|
+
key_findings=[
|
|
337
|
+
'AI agents are automating 60% of routine financial analysis tasks.',
|
|
338
|
+
'Fraud detection accuracy improved by 45% with agent-based systems.',
|
|
339
|
+
'Customer service response time reduced by 70%.'
|
|
340
|
+
],
|
|
341
|
+
impact='Transformative - reshaping how financial institutions operate by enhancing efficiency, accuracy, and customer satisfaction while reducing operational costs.',
|
|
342
|
+
sources_count=15
|
|
343
|
+
)
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### Example 5: Multi-Agent Collaboration
|
|
347
|
+
|
|
348
|
+
**Use Case:** Research and validate information using multiple specialized agents
|
|
349
|
+
|
|
350
|
+
```python
|
|
351
|
+
from agentensemble import Ensemble, ReActAgent
|
|
352
|
+
from agentensemble.tools import SearchTool
|
|
353
|
+
|
|
354
|
+
researcher = ReActAgent(name="researcher", tools=[SearchTool()], max_iterations=2)
|
|
355
|
+
validator = ReActAgent(name="validator", tools=[SearchTool()], max_iterations=2)
|
|
356
|
+
|
|
357
|
+
ensemble = Ensemble(
|
|
358
|
+
conductor="supervisor",
|
|
359
|
+
agents={"researcher": researcher, "validator": validator}
|
|
360
|
+
)
|
|
361
|
+
|
|
362
|
+
result = ensemble.perform(
|
|
363
|
+
task="Research and validate research methodology",
|
|
364
|
+
data={"topic": "research methodology"}
|
|
365
|
+
)
|
|
366
|
+
|
|
367
|
+
print(result)
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
**Actual Output:**
|
|
371
|
+
|
|
372
|
+
```python
|
|
373
|
+
{
|
|
374
|
+
'results': {
|
|
375
|
+
'researcher': {
|
|
376
|
+
'result': 'by P Ranganathan · 2024 · Cited by 89 — In this article, we discuss the methods of determining the validity and reliability of a research questionnaire. by D Sreekumar · Cited by 41 — Research methodology is a structured and scientific approach used to collect, analyze, and interpret quantitative or qualitative data...',
|
|
377
|
+
'metadata': {'iterations': 1, 'tool_calls': 1, 'agent': 'researcher'}
|
|
378
|
+
},
|
|
379
|
+
'validator': {
|
|
380
|
+
'result': 'by P Ranganathan · 2024 · Cited by 89 — In this article, we discuss the methods of determining the validity and reliability of a research questionnaire. Reliability and validity are concepts used to evaluate the quality of research...',
|
|
381
|
+
'metadata': {'iterations': 1, 'tool_calls': 1, 'agent': 'validator'}
|
|
382
|
+
}
|
|
383
|
+
},
|
|
384
|
+
'conductor': 'supervisor',
|
|
385
|
+
'agents_used': ['researcher', 'validator']
|
|
386
|
+
}
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
## 🤝 Contributing
|
|
390
|
+
|
|
391
|
+
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
392
|
+
|
|
393
|
+
## 📄 License
|
|
394
|
+
|
|
395
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
396
|
+
|
|
397
|
+
## 🙏 Acknowledgments
|
|
398
|
+
|
|
399
|
+
Inspired by production-grade agentic AI architectures and best practices from the AI agent community.
|
|
400
|
+
|
|
401
|
+
## 📧 Contact
|
|
402
|
+
|
|
403
|
+
For questions, issues, or contributions, please open an issue on GitHub.
|
|
404
|
+
|
|
405
|
+
---
|
|
406
|
+
|
|
407
|
+
**AgentEnsemble** - Where agents work in concert 🎼
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
agentensemble/__init__.py,sha256=5fnKmSggDHgmqUFtlaCY6c3-9PC4x1I3MB8IfTCe2ms,1453
|
|
2
|
+
agentensemble/py.typed,sha256=gDbkkCm7wiYfL11PAFL0KT5SwhhZAGcs6GmQohsM5no,75
|
|
3
|
+
agentensemble/agents/__init__.py,sha256=uwA6JJPYy6yzsEjug9W7Dk3jPkVLLoKsZOALERwymN8,952
|
|
4
|
+
agentensemble/agents/base.py,sha256=Vop4TBqBB6i0g_aLdT9CVg1pYEfpeflaMBVWNgRv4Xc,2225
|
|
5
|
+
agentensemble/agents/hybrid_agent.py,sha256=FP8HVl6RbsrZA_yr3DKwB2LpqWFlXTTlWWiHP9Ztt_g,5143
|
|
6
|
+
agentensemble/agents/rag_agent.py,sha256=-snohtBSkNFmhBM5xnSEy-wE8gnijc45Ae8LJ0xOTpg,3056
|
|
7
|
+
agentensemble/agents/react_agent.py,sha256=d9XvF97IDgXUXoEOt8hPxS43c-e8ZIF9kFlavzUM4EU,3629
|
|
8
|
+
agentensemble/agents/stategraph_agent.py,sha256=u9B4lA22le86cZDfmGt4_9jymHXS4oj96Gushc86D4Q,2841
|
|
9
|
+
agentensemble/agents/structured_agent.py,sha256=aD86fA2JzHV9bPw_VdC89zmlMPKuUaTyxLPQnnmOWVA,7551
|
|
10
|
+
agentensemble/orchestration/__init__.py,sha256=52aHZ94b6UI5EyUuQgAQF1UY6zEhP1CMasOQicdQnwE,630
|
|
11
|
+
agentensemble/orchestration/ensemble.py,sha256=wIM-UVq2zvpLxLaEdo38PnG9cfRXMgTAA09VSWR-JHs,4841
|
|
12
|
+
agentensemble/orchestration/pipeline.py,sha256=ojNLOuU8WcA4LRiK0TlrkVshnfkMRoYJyF1t42Tdouc,693
|
|
13
|
+
agentensemble/orchestration/supervisor.py,sha256=ZqZyZQiHqaHSutC9ZjJNHkybQW0qXwwHcEbMNYv8bAI,716
|
|
14
|
+
agentensemble/orchestration/swarm.py,sha256=JP9jNNM4tPf5gn6QHZ2H0cVv3yIP7g0rKeva0YSJIAE,663
|
|
15
|
+
agentensemble/testing/__init__.py,sha256=FKuKX_INmrVYQ4d6JcPo2HNjO7-DFgXi66KNh1GVwHg,331
|
|
16
|
+
agentensemble/testing/benchmark.py,sha256=KxxRq72bpDixCc-u2fBxSoSaDDzHakZV4svB07ewMPk,2252
|
|
17
|
+
agentensemble/testing/comparison.py,sha256=o1haZYZJNAhtvMJcrQ8GwdY_sH9mZq9W6b3y9QE5dCM,2217
|
|
18
|
+
agentensemble/testing/metrics.py,sha256=NGlDLw-b_y_chDf33Ug_LMLlxXPpXqM-DHVNsvpF6gY,2028
|
|
19
|
+
agentensemble/tools/__init__.py,sha256=ekpI31lv3ExUKezg14gZUIWJ9USBjlsdhzze77vtC_g,500
|
|
20
|
+
agentensemble/tools/rag.py,sha256=TMVUzIclcOG4bdZD54_JRa5dmgTtWhWWA3AMFzbcQ2Y,7886
|
|
21
|
+
agentensemble/tools/registry.py,sha256=0qYUY4hG4vXAW9FT8HHdE4XlSfhZrJT7UdtuTn08S00,1920
|
|
22
|
+
agentensemble/tools/scraper.py,sha256=7qgOWLAiaeZqBpd5_Nb3t6ydrhk2gTSPXwMnVerZAGo,3988
|
|
23
|
+
agentensemble/tools/search.py,sha256=m1h0k-31fZz18lVGgLLvYh-f_7g9L1haDazlUnrh0EI,5190
|
|
24
|
+
agentensemble/tools/validator.py,sha256=4bEHS_THtdu6MWJb6ECCOTvyd1Lq_Gn3nNqxGk2YaU8,1298
|
|
25
|
+
agentensemble/utils/__init__.py,sha256=MSFVSH3h2qw1F10BF-D5qH6sa2aHt-WHI03u_0jSt9Y,194
|
|
26
|
+
agentensemble/utils/llm.py,sha256=QLgQGPtDI1Cs1PUTzQxn7ObEy64eTI8NO5LBgkJdYFA,2577
|
|
27
|
+
agentensemble-0.1.0.dist-info/METADATA,sha256=OMR36qp4d_lQRL31Dkd8hxs0T-TXcOmsllyNeapKgv4,15608
|
|
28
|
+
agentensemble-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
29
|
+
agentensemble-0.1.0.dist-info/top_level.txt,sha256=sN1QDpk1o9USqujptvmiwDN7W_Owh_udUWzUfR2MVK0,14
|
|
30
|
+
agentensemble-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
agentensemble
|