Skip to main content

DACP - Declarative Agent Communication Protocol for LLM/agent communications and tool function calls

Project description

DACP - Delcarative Agent Communication Protocol

A Python library for managing LLM/agent communications and tool function calls following the OAS Open Agent Specification.

Installation

pip install -e .

Quick Start

import dacp

# Register a custom tool
def my_custom_tool(param1: str, param2: int) -> dict:
    return {"result": f"Processed {param1} with {param2}"}

dacp.register_tool("my_custom_tool", my_custom_tool)

# Call an LLM
response = dacp.call_llm("What is the weather like today?")

# Parse agent response
parsed = dacp.parse_agent_response(response)

# Check if it's a tool request
if dacp.is_tool_request(parsed):
    tool_name, args = dacp.get_tool_request(parsed)
    result = dacp.run_tool(tool_name, args)
    tool_response = dacp.wrap_tool_result(tool_name, result)

Features

  • Tool Registry: Register and manage custom tools for LLM agents
  • LLM Integration: Built-in support for OpenAI models (extensible)
  • Protocol Parsing: Parse and validate agent responses
  • Tool Execution: Safe execution of registered tools
  • OAS Compliance: Follows Open Agent Specification standards

API Reference

Tools

  • register_tool(tool_id: str, func): Register a new tool
  • run_tool(tool_id: str, args: Dict) -> dict: Execute a registered tool
  • TOOL_REGISTRY: Access the current tool registry

LLM

  • call_llm(prompt: str, model: str = "gpt-4") -> str: Call an LLM with a prompt

Protocol

  • parse_agent_response(response: str | dict) -> dict: Parse agent response
  • is_tool_request(msg: dict) -> bool: Check if message is a tool request
  • get_tool_request(msg: dict) -> tuple[str, dict]: Extract tool request details
  • wrap_tool_result(name: str, result: dict) -> dict: Wrap tool result for agent
  • is_final_response(msg: dict) -> bool: Check if message is a final response
  • get_final_response(msg: dict) -> dict: Extract final response

Development

# Install development dependencies
pip install -e .[dev]

# Run tests
pytest

# Format code
black .

# Lint code
flake8

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dacp-0.1.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dacp-0.1.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file dacp-0.1.0.tar.gz.

File metadata

  • Download URL: dacp-0.1.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for dacp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b16d446cd3f78d4bf771f61d61ddbd66e997906f9d2a86b4b041750593568f97
MD5 81cadd7546b28315aef6450767297069
BLAKE2b-256 2a35445048584d042765e157cfd8a4877df4682cca45a72a8ea079c76657bc6c

See more details on using hashes here.

File details

Details for the file dacp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dacp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for dacp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 81721bdc700b2acb826c6d31e33725500c9332d81c6f5ce57fe36e83a61bfa86
MD5 84cc25ea9ff9165f626b8d70ded4b2f3
BLAKE2b-256 405b7bae799d1fcb6dd1fb0a3730bc1271280434d614c81ca163b93256e902ed

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page