dacp 0.1.0__py3-none-any.whl → 0.3.1__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.
- dacp/__init__.py +40 -12
- dacp/intelligence.py +378 -0
- dacp/llm.py +28 -15
- dacp/logging_config.py +128 -0
- dacp/main.py +15 -0
- dacp/orchestrator.py +248 -0
- dacp/tools.py +66 -10
- dacp-0.3.1.dist-info/METADATA +464 -0
- dacp-0.3.1.dist-info/RECORD +15 -0
- dacp-0.1.0.dist-info/METADATA +0 -114
- dacp-0.1.0.dist-info/RECORD +0 -11
- {dacp-0.1.0.dist-info → dacp-0.3.1.dist-info}/WHEEL +0 -0
- {dacp-0.1.0.dist-info → dacp-0.3.1.dist-info}/licenses/LICENSE +0 -0
- {dacp-0.1.0.dist-info → dacp-0.3.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,464 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: dacp
|
3
|
+
Version: 0.3.1
|
4
|
+
Summary: Declarative Agent Communication Protocol - A protocol for managing LLM/agent communications and tool function calls
|
5
|
+
Author-email: Andrew Whitehouse <andrew.whitehouse@example.com>
|
6
|
+
License: MIT
|
7
|
+
Project-URL: Homepage, https://github.com/andrewwhitehouse/dacp
|
8
|
+
Project-URL: Repository, https://github.com/andrewwhitehouse/dacp
|
9
|
+
Project-URL: Documentation, https://github.com/andrewwhitehouse/dacp#readme
|
10
|
+
Project-URL: Issues, https://github.com/andrewwhitehouse/dacp/issues
|
11
|
+
Keywords: llm,agent,communication,protocol,ai,ml
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
13
|
+
Classifier: Intended Audience :: Developers
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
15
|
+
Classifier: Operating System :: OS Independent
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
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
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
24
|
+
Requires-Python: >=3.8
|
25
|
+
Description-Content-Type: text/markdown
|
26
|
+
License-File: LICENSE
|
27
|
+
Requires-Dist: requests>=2.25.0
|
28
|
+
Requires-Dist: pyyaml>=5.4.0
|
29
|
+
Provides-Extra: openai
|
30
|
+
Requires-Dist: openai>=1.0.0; extra == "openai"
|
31
|
+
Provides-Extra: anthropic
|
32
|
+
Requires-Dist: anthropic>=0.18.0; extra == "anthropic"
|
33
|
+
Provides-Extra: local
|
34
|
+
Requires-Dist: requests>=2.25.0; extra == "local"
|
35
|
+
Provides-Extra: all
|
36
|
+
Requires-Dist: openai>=1.0.0; extra == "all"
|
37
|
+
Requires-Dist: anthropic>=0.18.0; extra == "all"
|
38
|
+
Provides-Extra: dev
|
39
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
40
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
41
|
+
Requires-Dist: black>=22.0.0; extra == "dev"
|
42
|
+
Requires-Dist: flake8>=4.0.0; extra == "dev"
|
43
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
44
|
+
Requires-Dist: types-requests>=2.25.0; extra == "dev"
|
45
|
+
Requires-Dist: types-PyYAML>=6.0.0; extra == "dev"
|
46
|
+
Dynamic: license-file
|
47
|
+
|
48
|
+
# DACP - Declarative Agent Communication Protocol
|
49
|
+
|
50
|
+
A Python library for managing LLM/agent communications and tool function calls following the OAS Open Agent Specification.
|
51
|
+
|
52
|
+
## Installation
|
53
|
+
|
54
|
+
```bash
|
55
|
+
pip install -e .
|
56
|
+
```
|
57
|
+
|
58
|
+
## Quick Start
|
59
|
+
|
60
|
+
```python
|
61
|
+
import dacp
|
62
|
+
|
63
|
+
# Create an orchestrator to manage agents
|
64
|
+
orchestrator = dacp.Orchestrator()
|
65
|
+
|
66
|
+
# Create and register an agent
|
67
|
+
class MyAgent:
|
68
|
+
def handle_message(self, message):
|
69
|
+
return {"response": f"Hello {message.get('name', 'World')}!"}
|
70
|
+
|
71
|
+
agent = MyAgent()
|
72
|
+
orchestrator.register_agent("my-agent", agent)
|
73
|
+
|
74
|
+
# Send a message to the agent
|
75
|
+
response = orchestrator.send_message("my-agent", {"name": "Alice"})
|
76
|
+
print(response) # {"response": "Hello Alice!"}
|
77
|
+
|
78
|
+
# Use built-in tools
|
79
|
+
result = dacp.file_writer("./output/greeting.txt", "Hello, World!")
|
80
|
+
print(result["message"]) # "Successfully wrote 13 characters to ./output/greeting.txt"
|
81
|
+
|
82
|
+
# Use intelligence providers (supports multiple LLM providers)
|
83
|
+
intelligence_config = {
|
84
|
+
"engine": "anthropic",
|
85
|
+
"model": "claude-3-haiku-20240307",
|
86
|
+
"api_key": "your-api-key" # or set ANTHROPIC_API_KEY env var
|
87
|
+
}
|
88
|
+
response = dacp.invoke_intelligence("What is the weather like today?", intelligence_config)
|
89
|
+
|
90
|
+
# Or use the legacy call_llm function for OpenAI
|
91
|
+
response = dacp.call_llm("What is the weather like today?")
|
92
|
+
```
|
93
|
+
|
94
|
+
## Features
|
95
|
+
|
96
|
+
- **Agent Orchestration**: Central management of multiple agents with message routing
|
97
|
+
- **Tool Registry**: Register and manage custom tools for LLM agents
|
98
|
+
- **Built-in Tools**: Includes a `file_writer` tool that automatically creates parent directories
|
99
|
+
- **LLM Integration**: Built-in support for OpenAI models (extensible)
|
100
|
+
- **Protocol Parsing**: Parse and validate agent responses
|
101
|
+
- **Tool Execution**: Safe execution of registered tools
|
102
|
+
- **Conversation History**: Track and query agent interactions
|
103
|
+
- **OAS Compliance**: Follows Open Agent Specification standards
|
104
|
+
|
105
|
+
## API Reference
|
106
|
+
|
107
|
+
### Orchestrator
|
108
|
+
|
109
|
+
- `Orchestrator()`: Create a new orchestrator instance
|
110
|
+
- `register_agent(agent_id: str, agent) -> None`: Register an agent
|
111
|
+
- `unregister_agent(agent_id: str) -> bool`: Remove an agent
|
112
|
+
- `send_message(agent_id: str, message: Dict) -> Dict`: Send message to specific agent
|
113
|
+
- `broadcast_message(message: Dict, exclude_agents: List[str] = None) -> Dict`: Send message to all agents
|
114
|
+
- `get_conversation_history(agent_id: str = None) -> List[Dict]`: Get conversation history
|
115
|
+
- `clear_history() -> None`: Clear conversation history
|
116
|
+
- `get_session_info() -> Dict`: Get current session information
|
117
|
+
|
118
|
+
### Tools
|
119
|
+
|
120
|
+
- `register_tool(tool_id: str, func)`: Register a new tool
|
121
|
+
- `run_tool(tool_id: str, args: Dict) -> dict`: Execute a registered tool
|
122
|
+
- `TOOL_REGISTRY`: Access the current tool registry
|
123
|
+
- `file_writer(path: str, content: str) -> dict`: Write content to file, creating directories automatically
|
124
|
+
|
125
|
+
### Intelligence (Multi-Provider LLM Support)
|
126
|
+
|
127
|
+
- `invoke_intelligence(prompt: str, config: dict) -> str`: Call any supported LLM provider
|
128
|
+
- `validate_config(config: dict) -> bool`: Validate intelligence configuration
|
129
|
+
- `get_supported_engines() -> list`: Get list of supported engines
|
130
|
+
|
131
|
+
### LLM (Legacy)
|
132
|
+
|
133
|
+
- `call_llm(prompt: str, model: str = "gpt-4") -> str`: Call OpenAI (legacy function)
|
134
|
+
|
135
|
+
### Logging
|
136
|
+
|
137
|
+
- `enable_info_logging(log_file: str = None) -> None`: Enable info-level logging with emoji format
|
138
|
+
- `enable_debug_logging(log_file: str = None) -> None`: Enable debug logging with detailed format
|
139
|
+
- `enable_quiet_logging() -> None`: Enable only error and critical logging
|
140
|
+
- `setup_dacp_logging(level, format_style, include_timestamp, log_file) -> None`: Custom logging setup
|
141
|
+
- `set_dacp_log_level(level: str) -> None`: Change log level dynamically
|
142
|
+
- `disable_dacp_logging() -> None`: Disable all DACP logging
|
143
|
+
- `enable_dacp_logging() -> None`: Re-enable DACP logging
|
144
|
+
|
145
|
+
### Protocol
|
146
|
+
|
147
|
+
- `parse_agent_response(response: str | dict) -> dict`: Parse agent response
|
148
|
+
- `is_tool_request(msg: dict) -> bool`: Check if message is a tool request
|
149
|
+
- `get_tool_request(msg: dict) -> tuple[str, dict]`: Extract tool request details
|
150
|
+
- `wrap_tool_result(name: str, result: dict) -> dict`: Wrap tool result for agent
|
151
|
+
- `is_final_response(msg: dict) -> bool`: Check if message is a final response
|
152
|
+
- `get_final_response(msg: dict) -> dict`: Extract final response
|
153
|
+
|
154
|
+
## Agent Development
|
155
|
+
|
156
|
+
### Creating an Agent
|
157
|
+
|
158
|
+
Agents must implement a `handle_message` method:
|
159
|
+
|
160
|
+
```python
|
161
|
+
import dacp
|
162
|
+
|
163
|
+
class GreetingAgent:
|
164
|
+
def handle_message(self, message):
|
165
|
+
name = message.get("name", "World")
|
166
|
+
task = message.get("task")
|
167
|
+
|
168
|
+
if task == "greet":
|
169
|
+
return {"response": f"Hello, {name}!"}
|
170
|
+
elif task == "farewell":
|
171
|
+
return {"response": f"Goodbye, {name}!"}
|
172
|
+
else:
|
173
|
+
return {"error": f"Unknown task: {task}"}
|
174
|
+
|
175
|
+
# Register the agent
|
176
|
+
orchestrator = dacp.Orchestrator()
|
177
|
+
agent = GreetingAgent()
|
178
|
+
orchestrator.register_agent("greeter", agent)
|
179
|
+
|
180
|
+
# Use the agent
|
181
|
+
response = orchestrator.send_message("greeter", {
|
182
|
+
"task": "greet",
|
183
|
+
"name": "Alice"
|
184
|
+
})
|
185
|
+
print(response) # {"response": "Hello, Alice!"}
|
186
|
+
```
|
187
|
+
|
188
|
+
### Agent Base Class
|
189
|
+
|
190
|
+
You can also inherit from the `Agent` base class:
|
191
|
+
|
192
|
+
```python
|
193
|
+
import dacp
|
194
|
+
|
195
|
+
class MyAgent(dacp.Agent):
|
196
|
+
def handle_message(self, message):
|
197
|
+
return {"processed": message}
|
198
|
+
```
|
199
|
+
|
200
|
+
### Tool Requests from Agents
|
201
|
+
|
202
|
+
Agents can request tool execution by returning properly formatted responses:
|
203
|
+
|
204
|
+
```python
|
205
|
+
class ToolUsingAgent:
|
206
|
+
def handle_message(self, message):
|
207
|
+
if message.get("task") == "write_file":
|
208
|
+
return {
|
209
|
+
"tool_request": {
|
210
|
+
"name": "file_writer",
|
211
|
+
"args": {
|
212
|
+
"path": "./output/agent_file.txt",
|
213
|
+
"content": "Hello from agent!"
|
214
|
+
}
|
215
|
+
}
|
216
|
+
}
|
217
|
+
return {"response": "Task completed"}
|
218
|
+
|
219
|
+
# The orchestrator will automatically execute the tool and return results
|
220
|
+
orchestrator = dacp.Orchestrator()
|
221
|
+
agent = ToolUsingAgent()
|
222
|
+
orchestrator.register_agent("file-agent", agent)
|
223
|
+
|
224
|
+
response = orchestrator.send_message("file-agent", {"task": "write_file"})
|
225
|
+
# Tool will be executed automatically
|
226
|
+
```
|
227
|
+
|
228
|
+
## Intelligence Configuration
|
229
|
+
|
230
|
+
DACP supports multiple LLM providers through the `invoke_intelligence` function. Configure different providers using a configuration dictionary:
|
231
|
+
|
232
|
+
### OpenAI
|
233
|
+
|
234
|
+
```python
|
235
|
+
import dacp
|
236
|
+
|
237
|
+
openai_config = {
|
238
|
+
"engine": "openai",
|
239
|
+
"model": "gpt-4", # or "gpt-3.5-turbo", "gpt-4-turbo", etc.
|
240
|
+
"api_key": "your-openai-key", # or set OPENAI_API_KEY env var
|
241
|
+
"endpoint": "https://api.openai.com/v1", # optional, uses default
|
242
|
+
"temperature": 0.7, # optional, default 0.7
|
243
|
+
"max_tokens": 150 # optional, default 150
|
244
|
+
}
|
245
|
+
|
246
|
+
response = dacp.invoke_intelligence("Explain quantum computing", openai_config)
|
247
|
+
```
|
248
|
+
|
249
|
+
### Anthropic (Claude)
|
250
|
+
|
251
|
+
```python
|
252
|
+
anthropic_config = {
|
253
|
+
"engine": "anthropic",
|
254
|
+
"model": "claude-3-haiku-20240307", # or other Claude models
|
255
|
+
"api_key": "your-anthropic-key", # or set ANTHROPIC_API_KEY env var
|
256
|
+
"endpoint": "https://api.anthropic.com", # optional, uses default
|
257
|
+
"temperature": 0.7,
|
258
|
+
"max_tokens": 150
|
259
|
+
}
|
260
|
+
|
261
|
+
response = dacp.invoke_intelligence("Write a poem about AI", anthropic_config)
|
262
|
+
```
|
263
|
+
|
264
|
+
### Azure OpenAI
|
265
|
+
|
266
|
+
```python
|
267
|
+
azure_config = {
|
268
|
+
"engine": "azure",
|
269
|
+
"model": "gpt-4", # Your deployed model name
|
270
|
+
"api_key": "your-azure-key", # or set AZURE_OPENAI_API_KEY env var
|
271
|
+
"endpoint": "https://your-resource.openai.azure.com", # or set AZURE_OPENAI_ENDPOINT env var
|
272
|
+
"api_version": "2024-02-01" # optional, default provided
|
273
|
+
}
|
274
|
+
|
275
|
+
response = dacp.invoke_intelligence("Analyze this data", azure_config)
|
276
|
+
```
|
277
|
+
|
278
|
+
### Local LLMs (Ollama, etc.)
|
279
|
+
|
280
|
+
```python
|
281
|
+
# For Ollama (default local setup)
|
282
|
+
local_config = {
|
283
|
+
"engine": "local",
|
284
|
+
"model": "llama2", # or any model available in Ollama
|
285
|
+
"endpoint": "http://localhost:11434/api/generate", # Ollama default
|
286
|
+
"temperature": 0.7,
|
287
|
+
"max_tokens": 150
|
288
|
+
}
|
289
|
+
|
290
|
+
# For custom local APIs
|
291
|
+
custom_local_config = {
|
292
|
+
"engine": "local",
|
293
|
+
"model": "custom-model",
|
294
|
+
"endpoint": "http://localhost:8080/generate", # Your API endpoint
|
295
|
+
"temperature": 0.7,
|
296
|
+
"max_tokens": 150
|
297
|
+
}
|
298
|
+
|
299
|
+
response = dacp.invoke_intelligence("Tell me a story", local_config)
|
300
|
+
```
|
301
|
+
|
302
|
+
### Configuration from OAS YAML
|
303
|
+
|
304
|
+
You can load configuration from OAS (Open Agent Specification) YAML files:
|
305
|
+
|
306
|
+
```python
|
307
|
+
import yaml
|
308
|
+
import dacp
|
309
|
+
|
310
|
+
# Load config from YAML file
|
311
|
+
with open('agent_config.yaml', 'r') as f:
|
312
|
+
config = yaml.safe_load(f)
|
313
|
+
|
314
|
+
intelligence_config = config.get('intelligence', {})
|
315
|
+
response = dacp.invoke_intelligence("Hello, AI!", intelligence_config)
|
316
|
+
```
|
317
|
+
|
318
|
+
### Installation for Different Providers
|
319
|
+
|
320
|
+
Install optional dependencies for the providers you need:
|
321
|
+
|
322
|
+
```bash
|
323
|
+
# For OpenAI
|
324
|
+
pip install dacp[openai]
|
325
|
+
|
326
|
+
# For Anthropic
|
327
|
+
pip install dacp[anthropic]
|
328
|
+
|
329
|
+
# For all providers
|
330
|
+
pip install dacp[all]
|
331
|
+
|
332
|
+
# For local providers (requests is already included in base install)
|
333
|
+
pip install dacp[local]
|
334
|
+
```
|
335
|
+
|
336
|
+
## Built-in Tools
|
337
|
+
|
338
|
+
### file_writer
|
339
|
+
|
340
|
+
The `file_writer` tool automatically creates parent directories and writes content to files:
|
341
|
+
|
342
|
+
```python
|
343
|
+
import dacp
|
344
|
+
|
345
|
+
# This will create the ./output/ directory if it doesn't exist
|
346
|
+
result = dacp.file_writer("./output/file.txt", "Hello, World!")
|
347
|
+
|
348
|
+
if result["success"]:
|
349
|
+
print(f"File written: {result['path']}")
|
350
|
+
print(f"Message: {result['message']}")
|
351
|
+
else:
|
352
|
+
print(f"Error: {result['error']}")
|
353
|
+
```
|
354
|
+
|
355
|
+
**Features:**
|
356
|
+
- ✅ Automatically creates parent directories
|
357
|
+
- ✅ Handles Unicode content properly
|
358
|
+
- ✅ Returns detailed success/error information
|
359
|
+
- ✅ Safe error handling
|
360
|
+
|
361
|
+
## Logging
|
362
|
+
|
363
|
+
DACP includes comprehensive logging to help you monitor agent operations, tool executions, and intelligence calls.
|
364
|
+
|
365
|
+
### Quick Setup
|
366
|
+
|
367
|
+
```python
|
368
|
+
import dacp
|
369
|
+
|
370
|
+
# Enable info-level logging with emoji format (recommended for production)
|
371
|
+
dacp.enable_info_logging()
|
372
|
+
|
373
|
+
# Enable debug logging for development (shows detailed information)
|
374
|
+
dacp.enable_debug_logging()
|
375
|
+
|
376
|
+
# Enable quiet logging (errors only)
|
377
|
+
dacp.enable_quiet_logging()
|
378
|
+
```
|
379
|
+
|
380
|
+
### Custom Configuration
|
381
|
+
|
382
|
+
```python
|
383
|
+
# Full control over logging configuration
|
384
|
+
dacp.setup_dacp_logging(
|
385
|
+
level="INFO", # DEBUG, INFO, WARNING, ERROR, CRITICAL
|
386
|
+
format_style="emoji", # "simple", "detailed", "emoji"
|
387
|
+
include_timestamp=True, # Include timestamps
|
388
|
+
log_file="dacp.log" # Optional: also log to file
|
389
|
+
)
|
390
|
+
|
391
|
+
# Change log level dynamically
|
392
|
+
dacp.set_dacp_log_level("DEBUG")
|
393
|
+
|
394
|
+
# Disable/enable logging
|
395
|
+
dacp.disable_dacp_logging()
|
396
|
+
dacp.enable_dacp_logging()
|
397
|
+
```
|
398
|
+
|
399
|
+
### What Gets Logged
|
400
|
+
|
401
|
+
With logging enabled, you'll see:
|
402
|
+
|
403
|
+
- **🎭 Agent Registration**: When agents are registered/unregistered
|
404
|
+
- **📨 Message Routing**: Messages sent to agents and broadcast operations
|
405
|
+
- **🔧 Tool Execution**: Tool calls, execution time, and results
|
406
|
+
- **🧠 Intelligence Calls**: LLM provider calls, configuration, and performance
|
407
|
+
- **❌ Errors**: Detailed error information with context
|
408
|
+
- **📊 Performance**: Execution times for operations
|
409
|
+
|
410
|
+
### Log Format Examples
|
411
|
+
|
412
|
+
**Emoji Format** (clean, production-friendly):
|
413
|
+
```
|
414
|
+
2025-07-02 09:54:58 - 🎭 Orchestrator initialized with session ID: session_1751414098
|
415
|
+
2025-07-02 09:54:58 - ✅ Agent 'demo-agent' registered successfully (type: MyAgent)
|
416
|
+
2025-07-02 09:54:58 - 📨 Sending message to agent 'demo-agent'
|
417
|
+
2025-07-02 09:54:58 - 🔧 Agent 'demo-agent' requested tool execution
|
418
|
+
2025-07-02 09:54:58 - 🛠️ Executing tool: 'file_writer' with args: {...}
|
419
|
+
2025-07-02 09:54:58 - ✅ Tool 'file_writer' executed successfully in 0.001s
|
420
|
+
```
|
421
|
+
|
422
|
+
**Detailed Format** (development/debugging):
|
423
|
+
```
|
424
|
+
2025-07-02 09:54:58 - dacp.orchestrator:89 - INFO - 📨 Sending message to agent 'demo-agent'
|
425
|
+
2025-07-02 09:54:58 - dacp.orchestrator:90 - DEBUG - 📋 Message content: {'task': 'greet'}
|
426
|
+
2025-07-02 09:54:58 - dacp.tools:26 - DEBUG - 🛠️ Executing tool 'file_writer' with args: {...}
|
427
|
+
```
|
428
|
+
|
429
|
+
### Example Usage
|
430
|
+
|
431
|
+
```python
|
432
|
+
import dacp
|
433
|
+
|
434
|
+
# Enable logging
|
435
|
+
dacp.enable_info_logging()
|
436
|
+
|
437
|
+
# Create and use components - logging happens automatically
|
438
|
+
orchestrator = dacp.Orchestrator()
|
439
|
+
agent = MyAgent()
|
440
|
+
orchestrator.register_agent("my-agent", agent)
|
441
|
+
|
442
|
+
# This will log the message sending, tool execution, etc.
|
443
|
+
response = orchestrator.send_message("my-agent", {"task": "process"})
|
444
|
+
```
|
445
|
+
|
446
|
+
## Development
|
447
|
+
|
448
|
+
```bash
|
449
|
+
# Install development dependencies
|
450
|
+
pip install -e .[dev]
|
451
|
+
|
452
|
+
# Run tests
|
453
|
+
pytest
|
454
|
+
|
455
|
+
# Format code
|
456
|
+
black .
|
457
|
+
|
458
|
+
# Lint code
|
459
|
+
flake8
|
460
|
+
```
|
461
|
+
|
462
|
+
## License
|
463
|
+
|
464
|
+
MIT License
|
@@ -0,0 +1,15 @@
|
|
1
|
+
dacp/__init__.py,sha256=qTwsfYAnuq4PiE_1Vm6gK7VAycBEz_K6C2hzmPOODI0,1352
|
2
|
+
dacp/exceptions.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
+
dacp/intelligence.py,sha256=dyVxbVHAX56tsgC-_C9jNTov9PstPTiGehBS4L57lXw,15002
|
4
|
+
dacp/llm.py,sha256=JxHqM-aIm9pAMcVHQevbJGxrlBH4uV1ngRQdvyp9L3A,827
|
5
|
+
dacp/logging_config.py,sha256=FqQp650BwQLKM32L0ITYjadXXzG22KbjsL21_JlK9LM,3950
|
6
|
+
dacp/main.py,sha256=ZcJLymC9S5A4iO4yV7X178RLlhDrDuAwirdevUD5Yn0,470
|
7
|
+
dacp/orchestrator.py,sha256=oJ0C27qMBVgAW8jPqTvNhVOuaYBn5wRa2kJIej05iac,10065
|
8
|
+
dacp/protocol.py,sha256=DVhLTdyDVlAu8ETSEX8trPeycKfMeirHwcWQ8-BY7eA,1026
|
9
|
+
dacp/tools.py,sha256=9YNBg-YJtAWKNo88VXgQ6bedu_4Z3pGWq2QWVXPJg30,3009
|
10
|
+
dacp/types.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
|
+
dacp-0.3.1.dist-info/licenses/LICENSE,sha256=tb5kgUYRypHqAy8wlrJUBSYI5l1SBmawSYHmCC-MVW0,1074
|
12
|
+
dacp-0.3.1.dist-info/METADATA,sha256=CAs6fi58DLlSzcKkn8uPMKd1QP19yPWbFNKF71Z8Q5s,14506
|
13
|
+
dacp-0.3.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
14
|
+
dacp-0.3.1.dist-info/top_level.txt,sha256=Qxy0cy5jl7ttTQoGFlY9LXB6CbSvsekJ2y0P8I7L1zA,5
|
15
|
+
dacp-0.3.1.dist-info/RECORD,,
|
dacp-0.1.0.dist-info/METADATA
DELETED
@@ -1,114 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.4
|
2
|
-
Name: dacp
|
3
|
-
Version: 0.1.0
|
4
|
-
Summary: DACP - Declarative Agent Communication Protocol for LLM/agent communications and tool function calls
|
5
|
-
Author-email: Your Name <your.email@example.com>
|
6
|
-
License: MIT
|
7
|
-
Project-URL: Homepage, https://github.com/yourusername/dacp
|
8
|
-
Project-URL: Repository, https://github.com/yourusername/dacp
|
9
|
-
Project-URL: Issues, https://github.com/yourusername/dacp/issues
|
10
|
-
Keywords: llm,agent,tools,openai,communication
|
11
|
-
Classifier: Development Status :: 3 - Alpha
|
12
|
-
Classifier: Intended Audience :: Developers
|
13
|
-
Classifier: License :: OSI Approved :: MIT License
|
14
|
-
Classifier: Programming Language :: Python :: 3
|
15
|
-
Classifier: Programming Language :: Python :: 3.8
|
16
|
-
Classifier: Programming Language :: Python :: 3.9
|
17
|
-
Classifier: Programming Language :: Python :: 3.10
|
18
|
-
Classifier: Programming Language :: Python :: 3.11
|
19
|
-
Classifier: Programming Language :: Python :: 3.12
|
20
|
-
Requires-Python: >=3.8
|
21
|
-
Description-Content-Type: text/markdown
|
22
|
-
License-File: LICENSE
|
23
|
-
Requires-Dist: openai>=1.0.0
|
24
|
-
Provides-Extra: dev
|
25
|
-
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
26
|
-
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
27
|
-
Requires-Dist: black>=22.0.0; extra == "dev"
|
28
|
-
Requires-Dist: flake8>=5.0.0; extra == "dev"
|
29
|
-
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
30
|
-
Requires-Dist: types-requests>=2.28.0; extra == "dev"
|
31
|
-
Dynamic: license-file
|
32
|
-
|
33
|
-
# DACP - Delcarative Agent Communication Protocol
|
34
|
-
|
35
|
-
A Python library for managing LLM/agent communications and tool function calls following the OAS Open Agent Specification.
|
36
|
-
|
37
|
-
## Installation
|
38
|
-
|
39
|
-
```bash
|
40
|
-
pip install -e .
|
41
|
-
```
|
42
|
-
|
43
|
-
## Quick Start
|
44
|
-
|
45
|
-
```python
|
46
|
-
import dacp
|
47
|
-
|
48
|
-
# Register a custom tool
|
49
|
-
def my_custom_tool(param1: str, param2: int) -> dict:
|
50
|
-
return {"result": f"Processed {param1} with {param2}"}
|
51
|
-
|
52
|
-
dacp.register_tool("my_custom_tool", my_custom_tool)
|
53
|
-
|
54
|
-
# Call an LLM
|
55
|
-
response = dacp.call_llm("What is the weather like today?")
|
56
|
-
|
57
|
-
# Parse agent response
|
58
|
-
parsed = dacp.parse_agent_response(response)
|
59
|
-
|
60
|
-
# Check if it's a tool request
|
61
|
-
if dacp.is_tool_request(parsed):
|
62
|
-
tool_name, args = dacp.get_tool_request(parsed)
|
63
|
-
result = dacp.run_tool(tool_name, args)
|
64
|
-
tool_response = dacp.wrap_tool_result(tool_name, result)
|
65
|
-
```
|
66
|
-
|
67
|
-
## Features
|
68
|
-
|
69
|
-
- **Tool Registry**: Register and manage custom tools for LLM agents
|
70
|
-
- **LLM Integration**: Built-in support for OpenAI models (extensible)
|
71
|
-
- **Protocol Parsing**: Parse and validate agent responses
|
72
|
-
- **Tool Execution**: Safe execution of registered tools
|
73
|
-
- **OAS Compliance**: Follows Open Agent Specification standards
|
74
|
-
|
75
|
-
## API Reference
|
76
|
-
|
77
|
-
### Tools
|
78
|
-
|
79
|
-
- `register_tool(tool_id: str, func)`: Register a new tool
|
80
|
-
- `run_tool(tool_id: str, args: Dict) -> dict`: Execute a registered tool
|
81
|
-
- `TOOL_REGISTRY`: Access the current tool registry
|
82
|
-
|
83
|
-
### LLM
|
84
|
-
|
85
|
-
- `call_llm(prompt: str, model: str = "gpt-4") -> str`: Call an LLM with a prompt
|
86
|
-
|
87
|
-
### Protocol
|
88
|
-
|
89
|
-
- `parse_agent_response(response: str | dict) -> dict`: Parse agent response
|
90
|
-
- `is_tool_request(msg: dict) -> bool`: Check if message is a tool request
|
91
|
-
- `get_tool_request(msg: dict) -> tuple[str, dict]`: Extract tool request details
|
92
|
-
- `wrap_tool_result(name: str, result: dict) -> dict`: Wrap tool result for agent
|
93
|
-
- `is_final_response(msg: dict) -> bool`: Check if message is a final response
|
94
|
-
- `get_final_response(msg: dict) -> dict`: Extract final response
|
95
|
-
|
96
|
-
## Development
|
97
|
-
|
98
|
-
```bash
|
99
|
-
# Install development dependencies
|
100
|
-
pip install -e .[dev]
|
101
|
-
|
102
|
-
# Run tests
|
103
|
-
pytest
|
104
|
-
|
105
|
-
# Format code
|
106
|
-
black .
|
107
|
-
|
108
|
-
# Lint code
|
109
|
-
flake8
|
110
|
-
```
|
111
|
-
|
112
|
-
## License
|
113
|
-
|
114
|
-
MIT License
|
dacp-0.1.0.dist-info/RECORD
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
dacp/__init__.py,sha256=SY-MnntwhtBTXfVVSSEtK6rLBrlOMkWyXhfPvpeJSDo,690
|
2
|
-
dacp/exceptions.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
-
dacp/llm.py,sha256=doz7mHby2pLf0khX-AVcNo9DE1yZCGLwAzaEUEfTeo0,581
|
4
|
-
dacp/protocol.py,sha256=DVhLTdyDVlAu8ETSEX8trPeycKfMeirHwcWQ8-BY7eA,1026
|
5
|
-
dacp/tools.py,sha256=fkRAnVPgbsOxfphYgevDmrxfIkSF3lliVWAMLThpY68,971
|
6
|
-
dacp/types.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
|
-
dacp-0.1.0.dist-info/licenses/LICENSE,sha256=tb5kgUYRypHqAy8wlrJUBSYI5l1SBmawSYHmCC-MVW0,1074
|
8
|
-
dacp-0.1.0.dist-info/METADATA,sha256=Dwm_o_IWbwSdr3QeRFTccyGzwAwNRRQ20eG8g0BX12I,3447
|
9
|
-
dacp-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
10
|
-
dacp-0.1.0.dist-info/top_level.txt,sha256=Qxy0cy5jl7ttTQoGFlY9LXB6CbSvsekJ2y0P8I7L1zA,5
|
11
|
-
dacp-0.1.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|