loopy-agent 0.4.0__tar.gz

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.
Files changed (36) hide show
  1. loopy_agent-0.4.0/.gitignore +51 -0
  2. loopy_agent-0.4.0/CHANGELOG.md +188 -0
  3. loopy_agent-0.4.0/CONTRIBUTING.md +305 -0
  4. loopy_agent-0.4.0/PKG-INFO +816 -0
  5. loopy_agent-0.4.0/README.md +776 -0
  6. loopy_agent-0.4.0/ai_concepts.png +0 -0
  7. loopy_agent-0.4.0/docs/README.md +662 -0
  8. loopy_agent-0.4.0/examples/01_basic_loop.py +58 -0
  9. loopy_agent-0.4.0/examples/02_gateway_routing.py +73 -0
  10. loopy_agent-0.4.0/examples/03_eval_gate.py +86 -0
  11. loopy_agent-0.4.0/examples/04_orchestrator_workers.py +167 -0
  12. loopy_agent-0.4.0/examples/05_middleware_pipeline.py +161 -0
  13. loopy_agent-0.4.0/examples/06_plugins.py +212 -0
  14. loopy_agent-0.4.0/examples/07_complete_workflow.py +262 -0
  15. loopy_agent-0.4.0/loopy/__init__.py +153 -0
  16. loopy_agent-0.4.0/loopy/_types.pyi +520 -0
  17. loopy_agent-0.4.0/loopy/agents.py +604 -0
  18. loopy_agent-0.4.0/loopy/cache.py +236 -0
  19. loopy_agent-0.4.0/loopy/cli.py +326 -0
  20. loopy_agent-0.4.0/loopy/evals.py +447 -0
  21. loopy_agent-0.4.0/loopy/gateway.py +409 -0
  22. loopy_agent-0.4.0/loopy/guardrails.py +226 -0
  23. loopy_agent-0.4.0/loopy/loop.py +171 -0
  24. loopy_agent-0.4.0/loopy/mcp.py +216 -0
  25. loopy_agent-0.4.0/loopy/middleware.py +460 -0
  26. loopy_agent-0.4.0/loopy/observe.py +380 -0
  27. loopy_agent-0.4.0/loopy/plugins/__init__.py +353 -0
  28. loopy_agent-0.4.0/loopy/plugins/audio.py +244 -0
  29. loopy_agent-0.4.0/loopy/plugins/marketplace.py +284 -0
  30. loopy_agent-0.4.0/loopy/plugins/memory.py +309 -0
  31. loopy_agent-0.4.0/loopy/plugins/rag.py +269 -0
  32. loopy_agent-0.4.0/loopy/plugins/tools.py +297 -0
  33. loopy_agent-0.4.0/loopy/py.typed +0 -0
  34. loopy_agent-0.4.0/pyproject.toml +78 -0
  35. loopy_agent-0.4.0/tests/__init__.py +0 -0
  36. loopy_agent-0.4.0/tests/test_loopy.py +1190 -0
@@ -0,0 +1,51 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # Distribution / packaging
7
+ .Python
8
+ build/
9
+ develop-eggs/
10
+ dist/
11
+ downloads/
12
+ eggs/
13
+ .eggs/
14
+ lib/
15
+ lib64/
16
+ parts/
17
+ sdist/
18
+ var/
19
+ wheels/
20
+ *.egg-info/
21
+ .installed.cfg
22
+ *.egg
23
+
24
+ # Virtual environments
25
+ .venv/
26
+ venv/
27
+ ENV/
28
+
29
+ # IDE
30
+ .vscode/
31
+ .idea/
32
+ *.swp
33
+ *.swo
34
+
35
+ # Testing
36
+ .pytest_cache/
37
+ .coverage
38
+ htmlcov/
39
+
40
+ # Build
41
+ *.so
42
+ *.dylib
43
+
44
+ # OS
45
+ .DS_Store
46
+ Thumbs.db
47
+
48
+ # Loopy specific
49
+ .cache/
50
+ *.log
51
+ workflow_traces.json
@@ -0,0 +1,188 @@
1
+ # 📋 Changelog
2
+
3
+ All notable changes to loopy will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ---
9
+
10
+ ## [0.4.0] - 2026-07-24
11
+
12
+ ### Added
13
+
14
+ - **AudioPlugin** - Speech-to-text and text-to-speech integration
15
+ - `SpeechToText` - Whisper-compatible transcription
16
+ - `TextToSpeech` - Multi-voice synthesis
17
+ - Configurable providers (OpenAI, ElevenLabs, local)
18
+
19
+ - **MarketplacePlugin** - Plugin discovery and installation
20
+ - `PluginMarketplace` - Search, install, uninstall plugins
21
+ - PyPI integration for plugin distribution
22
+ - Cache for installed plugins
23
+
24
+ - **New tests** - 4 additional tests (59 total)
25
+
26
+ ### Changed
27
+
28
+ - Version bumped to 0.4.0
29
+ - Updated plugin lazy imports
30
+
31
+ ---
32
+
33
+ ## [0.3.0] - 2026-07-24
34
+
35
+ ### Added
36
+
37
+ - **TraceExporter** - Export traces to external backends
38
+ - `export_file()` - Export to JSON file
39
+ - `export_stdout()` - Export to console
40
+ - `export_http()` - Export to Jaeger/Zipkin via HTTP
41
+
42
+ - **RAGPlugin** - Retrieval-Augmented Generation
43
+ - `Retriever` - Vector/keyword document search
44
+ - `Document` - Document storage with metadata
45
+
46
+ - **ToolsPlugin** - Tool registry for function calling
47
+ - `ToolRegistry` - Register and execute tools
48
+ - `Tool` - Tool schema generation (OpenAI format)
49
+ - Built-in calculator and JSON tools
50
+
51
+ - **MemoryPlugin** - Long-term agent memory
52
+ - `MemoryStore` - Persistent memory storage
53
+ - `Memory` - Memory entries with importance scoring
54
+ - JSON file persistence
55
+
56
+ - **New tests** - 6 additional tests (55 total)
57
+
58
+ ### Changed
59
+
60
+ - Version bumped to 0.3.0
61
+ - Updated plugins/__init__.py with lazy imports
62
+
63
+ ---
64
+
65
+ ## [0.2.0] - 2026-07-24
66
+
67
+ ### Added
68
+
69
+ - **Evaluator-Optimizer Pattern** (2026 agentic workflow)
70
+ - `EvalGate` - LLM-as-judge evaluation gate
71
+ - `EvalGateType` - COMMAND, ARTIFACT, MANUAL, JUDGE
72
+ - `JudgeConfig` - Configure evaluation criteria and thresholds
73
+ - `EvalGateResult` - Pass/fail with score and feedback
74
+
75
+ - **Orchestrator-Workers Pattern**
76
+ - `Router` - Pattern-based task routing to specialist agents
77
+ - `RoutingRule` - Define routing patterns
78
+ - `TaskDecomposer` - Break tasks into subtasks with dependencies
79
+ - `SubTask` - Dependency-aware task execution
80
+
81
+ - **Async Context Managers**
82
+ - `Gateway` now supports `async with` for automatic cleanup
83
+
84
+ - **Connection Pooling**
85
+ - `ConnectionPool` - HTTP connection reuse for lower latency
86
+
87
+ - **New Middleware**
88
+ - `RetryMiddleware` - Auto-retry with exponential backoff
89
+ - `CircuitBreakerMiddleware` - Prevent cascade failures
90
+ - `FallbackMiddleware` - Provider failover
91
+
92
+ - **New tests** - 12 additional tests (49 total)
93
+
94
+ ### Changed
95
+
96
+ - Version bumped to 0.2.0
97
+ - Updated all exports in __init__.py
98
+ - Enhanced Orchestrator with routing and decomposition
99
+
100
+ ---
101
+
102
+ ## [0.1.0] - 2026-07-24
103
+
104
+ ### Added
105
+
106
+ - **Agentic Loop** (`loop.py`)
107
+ - `AgentLoop` - Plan → Act → Observe → Reflect cycle
108
+ - `LoopConfig` - Configure callbacks and stopping conditions
109
+ - `StepResult` - Track iteration results
110
+
111
+ - **AI Gateway** (`gateway.py`)
112
+ - `Gateway` - Multi-provider LLM routing
113
+ - `ModelProvider` - OpenAI, Anthropic, Ollama, Custom
114
+ - `ProviderConfig` - Provider configuration
115
+ - `GatewayResponse` - Unified response format
116
+ - Batch requests and streaming support
117
+
118
+ - **Guardrails** (`guardrails.py`)
119
+ - `GuardrailPipeline` - Input/output filtering
120
+ - PII detection (SSN, email, phone, credit card)
121
+ - Jailbreak detection
122
+
123
+ - **Evals** (`evals.py`)
124
+ - `Evaluator` - Judge-based model evaluation
125
+ - `EvalSuite` / `EvalCase` - Test case management
126
+ - Simple string matching and LLM judge support
127
+
128
+ - **Cache** (`cache.py`)
129
+ - `LLMCache` - Semantic token caching
130
+ - TTL and LRU eviction
131
+ - Hit rate tracking and cost estimation
132
+
133
+ - **Observability** (`observe.py`)
134
+ - `Tracer` - Distributed tracing
135
+ - `Span` - Operation tracking
136
+ - `MetricsCollector` - Counter/histogram/gauge metrics
137
+
138
+ - **MCP Client** (`mcp.py`)
139
+ - `MCPClient` - Model Context Protocol client
140
+ - `LocalMCP` - Local tool execution
141
+
142
+ - **Multi-Agent** (`agents.py`)
143
+ - `Orchestrator` - Agent pool management
144
+ - `SubAgent` - Individual agent configuration
145
+
146
+ - **Middleware** (`middleware.py`)
147
+ - `MiddlewarePipeline` - Composable request/response hooks
148
+ - Built-in: Logging, Timing, RateLimit, Cache, Validation, Function
149
+
150
+ - **Plugin System** (`plugins.py`)
151
+ - `Plugin` - Base plugin class
152
+ - `PluginRegistry` - Central component registry
153
+ - `PluginLoader` - Auto-discovery from packages/directories
154
+
155
+ - **CLI** (`cli.py`)
156
+ - Commands: info, chat, guard, cache, trace, eval, agent
157
+
158
+ - **Type Stubs** (`py.typed`, `_types.pyi`)
159
+ - Full IDE autocompletion support
160
+
161
+ - **Initial tests** - 37 tests passing
162
+
163
+ ---
164
+
165
+ ## Roadmap
166
+
167
+ ### v0.5.0 (Planned)
168
+ - Streaming improvements
169
+ - WebSocket support
170
+ - Advanced vector embeddings
171
+ - Rate limiting improvements
172
+
173
+ ### v0.6.0 (Planned)
174
+ - Multi-modal support
175
+ - Image generation tools
176
+ - Code execution sandbox
177
+ - Enhanced security features
178
+
179
+ ---
180
+
181
+ ## Version History Summary
182
+
183
+ | Version | Tests | Key Features |
184
+ |---------|-------|--------------|
185
+ | 0.1.0 | 37 | Initial 8 concepts |
186
+ | 0.2.0 | 49 | EvalGate, Router, Async, Middleware |
187
+ | 0.3.0 | 55 | Plugins, OpenTelemetry, RAG, Tools, Memory |
188
+ | 0.4.0 | 59 | Audio, Marketplace, Production Hardening |
@@ -0,0 +1,305 @@
1
+ # 🤝 Contributing to Loopy
2
+
3
+ Thank you for your interest in contributing to Loopy! This document provides guidelines and information for contributors.
4
+
5
+ ---
6
+
7
+ ## 📋 Table of Contents
8
+
9
+ - [Code of Conduct](#code-of-conduct)
10
+ - [Getting Started](#getting-started)
11
+ - [Development Setup](#development-setup)
12
+ - [Making Changes](#making-changes)
13
+ - [Testing](#testing)
14
+ - [Pull Request Process](#pull-request-process)
15
+ - [Style Guidelines](#style-guidelines)
16
+ - [Adding Features](#adding-features)
17
+ - [Bug Reports](#bug-reports)
18
+
19
+ ---
20
+
21
+ ## 📜 Code of Conduct
22
+
23
+ Please read and follow our [Code of Conduct](CODE_OF_CONDUCT.md). We are committed to providing a welcoming and inclusive environment for everyone.
24
+
25
+ ---
26
+
27
+ ## 🚀 Getting Started
28
+
29
+ 1. **Fork the repository** on GitHub
30
+ 2. **Clone your fork** locally:
31
+ ```bash
32
+ git clone https://github.com/your-username/loopy.git
33
+ cd loopy
34
+ ```
35
+ 3. **Add upstream remote**:
36
+ ```bash
37
+ git remote add upstream https://github.com/Dream-Pixels-Forge/loopy.git
38
+ ```
39
+
40
+ ---
41
+
42
+ ## 🛠️ Development Setup
43
+
44
+ ### Prerequisites
45
+
46
+ - Python 3.11+
47
+ - pip or poetry
48
+
49
+ ### Installation
50
+
51
+ ```bash
52
+ # Create virtual environment
53
+ python -m venv venv
54
+ source venv/bin/activate # Linux/Mac
55
+ # or
56
+ venv\Scripts\activate # Windows
57
+
58
+ # Install in development mode
59
+ pip install -e ".[dev]"
60
+
61
+ # Install pre-commit hooks (optional)
62
+ pip install pre-commit
63
+ pre-commit install
64
+ ```
65
+
66
+ ### Project Structure
67
+
68
+ ```
69
+ loopy/
70
+ ├── loopy/ # Source code
71
+ │ ├── __init__.py # Public API exports
72
+ │ ├── loop.py # Agentic loop engine
73
+ │ ├── gateway.py # AI Gateway
74
+ │ ├── guardrails.py # Guardrails
75
+ │ ├── evals.py # Evals + EvalGate
76
+ │ ├── cache.py # LLM Cache
77
+ │ ├── observe.py # Observability
78
+ │ ├── mcp.py # MCP Client
79
+ │ ├── agents.py # Multi-Agent
80
+ │ ├── middleware.py # Middleware
81
+ │ ├── cli.py # CLI
82
+ │ └── plugins/ # First-party plugins
83
+ │ ├── __init__.py
84
+ │ ├── rag.py
85
+ │ ├── tools.py
86
+ │ ├── memory.py
87
+ │ ├── audio.py
88
+ │ └── marketplace.py
89
+ ├── tests/ # Test suite
90
+ ├── docs/ # Documentation
91
+ ├── examples/ # Usage examples
92
+ └── pyproject.toml # Project configuration
93
+ ```
94
+
95
+ ---
96
+
97
+ ## ✏️ Making Changes
98
+
99
+ ### Branch Naming
100
+
101
+ Use descriptive branch names:
102
+ - `feature/add-new-middleware`
103
+ - `fix/cache-eviction-bug`
104
+ - `docs/update-api-reference`
105
+ - `refactor/improve-gateway`
106
+
107
+ ### Commit Messages
108
+
109
+ Follow [Conventional Commits](https://www.conventionalcommits.org/):
110
+ - `feat: add new RetryMiddleware`
111
+ - `fix: resolve cache eviction issue`
112
+ - `docs: update API reference`
113
+ - `refactor: improve gateway performance`
114
+ - `test: add tests for RAG plugin`
115
+
116
+ ---
117
+
118
+ ## 🧪 Testing
119
+
120
+ ### Running Tests
121
+
122
+ ```bash
123
+ # Run all tests
124
+ pytest
125
+
126
+ # Run with verbose output
127
+ pytest -v
128
+
129
+ # Run specific test file
130
+ pytest tests/test_loopy.py
131
+
132
+ # Run specific test class
133
+ pytest tests/test_loopy.py::TestAgentLoop
134
+
135
+ # Run with coverage
136
+ pytest --cov=loopy --cov-report=html
137
+ ```
138
+
139
+ ### Writing Tests
140
+
141
+ - Place tests in `tests/` directory
142
+ - Name test files `test_<module>.py`
143
+ - Use `pytest` fixtures when appropriate
144
+ - Aim for high coverage (80%+ target)
145
+
146
+ Example test:
147
+
148
+ ```python
149
+ import asyncio
150
+ from loopy import AgentLoop, LoopConfig
151
+
152
+ def test_basic_loop():
153
+ """Test basic agent loop execution."""
154
+ async def planner(history):
155
+ return "Test plan"
156
+
157
+ async def actor(plan):
158
+ return "Test action"
159
+
160
+ loop = AgentLoop(LoopConfig(
161
+ planner=planner,
162
+ actor=actor,
163
+ max_steps=1,
164
+ ))
165
+
166
+ async def run_test():
167
+ results = await loop.run()
168
+ assert len(results) == 1
169
+ assert results[0].status == StepStatus.COMPLETE
170
+
171
+ asyncio.run(run_test())
172
+ ```
173
+
174
+ ---
175
+
176
+ ## 🔀 Pull Request Process
177
+
178
+ 1. **Create a feature branch** from `main`
179
+ 2. **Make your changes** with tests
180
+ 3. **Run the test suite** to ensure everything passes
181
+ 4. **Update documentation** if needed
182
+ 5. **Submit a pull request** with:
183
+ - Clear title and description
184
+ - Link to related issues
185
+ - Screenshots (if applicable)
186
+
187
+ ### PR Checklist
188
+
189
+ - [ ] Tests pass locally
190
+ - [ ] New tests added for new features
191
+ - [ ] Documentation updated
192
+ - [ ] Type hints added/updated
193
+ - [ ] No breaking changes (or documented in CHANGELOG)
194
+ - [ ] Code follows style guidelines
195
+
196
+ ---
197
+
198
+ ## 📏 Style Guidelines
199
+
200
+ ### Python Style
201
+
202
+ - Follow PEP 8
203
+ - Use type hints consistently
204
+ - Maximum line length: 100 characters
205
+ - Use f-strings for string formatting
206
+
207
+ ### Docstrings
208
+
209
+ Use Google-style docstrings:
210
+
211
+ ```python
212
+ def my_function(param1: str, param2: int = 10) -> bool:
213
+ """
214
+ Brief description of the function.
215
+
216
+ Longer description if needed.
217
+
218
+ Args:
219
+ param1: Description of param1
220
+ param2: Description of param2
221
+
222
+ Returns:
223
+ Description of return value
224
+
225
+ Raises:
226
+ ValueError: When something is wrong
227
+
228
+ Example:
229
+ >>> result = my_function("hello", 5)
230
+ >>> print(result)
231
+ True
232
+ """
233
+ ```
234
+
235
+ ### Import Order
236
+
237
+ ```python
238
+ # Standard library
239
+ import asyncio
240
+ import logging
241
+ from dataclasses import dataclass
242
+ from typing import Any
243
+
244
+ # Third-party
245
+ import httpx
246
+
247
+ # Local
248
+ from loopy.gateway import Gateway
249
+ ```
250
+
251
+ ---
252
+
253
+ ## ➕ Adding Features
254
+
255
+ ### Adding a New Module
256
+
257
+ 1. Create `loopy/new_module.py`
258
+ 2. Add exports to `loopy/__init__.py`
259
+ 3. Add to `__all__` list
260
+ 4. Write tests in `tests/test_new_module.py`
261
+ 5. Update documentation
262
+
263
+ ### Adding a New Plugin
264
+
265
+ 1. Create `loopy/plugins/new_plugin.py`
266
+ 2. Implement `Plugin` base class
267
+ 3. Add lazy import to `loopy/plugins/__init__.py`
268
+ 4. Write tests in `tests/test_loopy.py`
269
+ 5. Document in docs/README.md
270
+
271
+ ### Adding Middleware
272
+
273
+ 1. Create class inheriting from `Middleware`
274
+ 2. Implement `before()`, `after()`, and/or `on_error()`
275
+ 3. Add to `loopy/middleware.py`
276
+ 4. Export in `loopy/__init__.py`
277
+ 5. Write tests
278
+
279
+ ---
280
+
281
+ ## 🐛 Bug Reports
282
+
283
+ When filing a bug report, please include:
284
+
285
+ 1. **Environment** (Python version, OS)
286
+ 2. **Steps to reproduce**
287
+ 3. **Expected behavior**
288
+ 4. **Actual behavior**
289
+ 5. **Error messages/tracebacks**
290
+ 6. **Minimal code example**
291
+
292
+ ---
293
+
294
+ ## 📚 Resources
295
+
296
+ - [Documentation](docs/README.md)
297
+ - [API Reference](docs/README.md#api-reference)
298
+ - [Examples](examples/)
299
+ - [Changelog](CHANGELOG.md)
300
+
301
+ ---
302
+
303
+ ## 🙏 Thank You!
304
+
305
+ Thank you for contributing to Loopy! Your help is appreciated.