Skip to content

Commit 380807d

Browse files
committed
Fix the protocol registry log warning
1 parent d324105 commit 380807d

File tree

4 files changed

+79
-50
lines changed

4 files changed

+79
-50
lines changed

README.md

Lines changed: 73 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,15 @@ result = agent("Analyze this repository for security issues")
8383
### Custom Agent with Tools
8484

8585
```python
86+
import asyncio
87+
import dspy
8688
from agenspy import BaseAgent
8789
from typing import Dict, Any
8890

8991
class CodeReviewAgent(BaseAgent):
9092
def __init__(self, name: str):
9193
super().__init__(name)
92-
self.register_tool("review_code", self.review_code)
93-
94+
9495
async def review_code(self, code: str, language: str) -> Dict[str, Any]:
9596
"""Review code for potential issues."""
9697
# Your custom review logic here
@@ -99,10 +100,52 @@ class CodeReviewAgent(BaseAgent):
99100
"issues": ["Consider adding error handling", "Document this function"],
100101
"suggestions": ["Use list comprehension for better performance"]
101102
}
103+
104+
async def forward(self, **kwargs) -> dspy.Prediction:
105+
"""Process agent request."""
106+
code = kwargs.get("code", "")
107+
language = kwargs.get("language", "python")
108+
result = await self.review_code(code, language)
109+
return dspy.Prediction(**result)
110+
111+
async def main():
112+
# Configure DSPy with your preferred language model
113+
lm = dspy.LM('openai/gpt-4o-mini')
114+
dspy.configure(lm=lm)
115+
116+
# Create and use the agent
117+
agent = CodeReviewAgent("code-reviewer")
118+
result = await agent(code="def add(a, b): return a + b", language="python")
119+
print("Review Results:", result)
120+
121+
# Run the async main function
122+
if __name__ == "__main__":
123+
asyncio.run(main())
124+
```
125+
126+
127+
### Python MCP Server
128+
129+
```python
130+
131+
from agentic_dspy.servers import GitHubMCPServer
132+
133+
# Create and start Python MCP server [header-11](#header-11)
134+
server = GitHubMCPServer(port=8080)
135+
136+
# Add custom tools [header-12](#header-12)
137+
async def custom_tool(param: str):
138+
return f"Processed: {param}"
139+
140+
server.register_tool(
141+
"custom_tool",
142+
"A custom tool",
143+
{"param": "string"},
144+
custom_tool
145+
)
146+
147+
server.start()
102148

103-
# Usage
104-
agent = CodeReviewAgent("code-reviewer")
105-
result = await agent.review_code("def add(a, b): return a + b", "python")
106149
```
107150

108151
# 🏗️ Architecture
@@ -140,59 +183,46 @@ Agenspy provides a protocol-first approach to building AI agents:
140183
### Advanced Usage Example: Custom MCP Server
141184

142185
```python
143-
from agenspy.servers import BaseMCPServer
186+
from agenspy.servers.mcp_python_server import PythonMCPServer
144187
import asyncio
145188

146-
class CustomMCPServer(BaseMCPServer):
189+
class CustomMCPServer(PythonMCPServer):
147190
def __init__(self, port: int = 8080):
148-
super().__init__(port=port)
149-
self.register_tool("custom_operation", self.handle_custom_op)
150-
151-
async def handle_custom_op(self, param1: str, param2: int) -> dict:
191+
super().__init__(name="custom-mcp-server", port=port)
192+
self.register_tool(
193+
name="custom_operation",
194+
description="A custom operation that processes parameters",
195+
parameters={
196+
"type": "object",
197+
"properties": {
198+
"param1": {"type": "string", "description": "First parameter"},
199+
"param2": {"type": "integer", "description": "Second parameter"}
200+
},
201+
"required": ["param1", "param2"]
202+
},
203+
handler=self.handle_custom_op
204+
)
205+
206+
async def handle_custom_op(self, **kwargs):
152207
"""Handle custom operation with parameters."""
153-
return {"result": f"Processed {param1} with {param2}"}
208+
param1 = kwargs.get("param1")
209+
param2 = kwargs.get("param2")
210+
return f"Processed {param1} with {param2}"
154211

155212
# Start the server
156-
server = CustomMCPServer(port=8080)
157-
print("Starting MCP server on port 8080...")
158-
server.start()
213+
if __name__ == "__main__":
214+
server = CustomMCPServer(port=8080)
215+
print("Starting MCP server on port 8080...")
216+
server.start()
159217
```
160218

161219
## 🖥️ Command Line Interface
162220

163221
Agenspy provides a command-line interface for managing agents and protocols:
164222

165-
### Basic Commands
166223
```bash
167224
# Show help and available commands
168225
agenspy --help
169-
170-
# Show version information
171-
agenspy --version
172-
```
173-
174-
### Agent Management
175-
```bash
176-
# List available agents
177-
agenspy agent --help
178-
```
179-
180-
### Protocol Management
181-
```bash
182-
# List available protocols
183-
agenspy protocol --help
184-
185-
# Test protocol connection
186-
agenspy protocol test [PROTOCOL] [--server SERVER]
187-
188-
# Get detailed information about a protocol
189-
agenspy protocol info [PROTOCOL_NAME]
190-
```
191-
192-
### Server Management
193-
```bash
194-
# Start the server
195-
agenspy server --help
196226
```
197227

198228
## 📚 Documentation

agenspy/utils/protocol_registry.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ def __init__(self):
1515
def register_protocol(self, protocol_type: ProtocolType, protocol_class: Type[BaseProtocol]):
1616
"""Register a protocol implementation."""
1717
self._protocols[protocol_type] = protocol_class
18-
print(f"📝 Registered {protocol_type.value} protocol")
1918

2019
def create_protocol(self, protocol_type: ProtocolType, **kwargs) -> BaseProtocol:
2120
"""Create a protocol instance."""

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "agenspy"
7-
version = "0.1.0"
8-
description = "Protocol-first AI agent framework built on DSPy - supporting MCP, Agent2Agent, and future protocols"
7+
version = "0.0.1"
8+
description = "Agenspy (Agentic-DSPy)- Protocol-first AI agent framework built on DSPy - supporting MCP, Agent2Agent, and future protocols"
99
readme = "README.md"
1010
authors = [{ name = "Shashi Jagtap", email = "[email protected]" }]
1111
license = { text = "MIT License" }

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121

2222
setup(
2323
name="agenspy",
24-
version="0.1.0",
25-
author="Agenspy Contributors",
26-
author_email="shashikant@super-agentic.ai",
27-
description="Protocol-first AI agent framework built on DSPy",
24+
version="0.0.1",
25+
author="Shashi Jagtap",
26+
author_email="shashi@super-agentic.ai",
27+
description="Agenspy (Agentic-DSPy)- Protocol-first AI agent framework built on DSPy",
2828
long_description=long_description,
2929
long_description_content_type="text/markdown",
3030
url="https://github.com/superagenticai/agenspy",

0 commit comments

Comments
 (0)