nanda-agent


Namenanda-agent JSON
Version 1.0.4 PyPI version JSON
download
home_pagehttps://github.com/aidecentralized/nanda-agent-sdk.git
SummaryCustomizable AI Agent Communication Framework with pluggable message improvement logic
upload_time2025-07-10 06:04:30
maintainerNone
docs_urlNone
authorNANDA Team
requires_python>=3.8
licenseNone
keywords nanda ai agent framework
VCS
bugtrack_url
requirements flask anthropic requests python-a2a mcp anthropic python-dotenv flask-cors pymongo
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # NANDA Agent Framework

A customizable improvement logic for your agents,  and easily get registered into NANDA registry

## Features

- **Pluggable Message Improvement**: Easily customize how your agents improve messages
- **Multiple AI Frameworks**: Support for LangChain, CrewAI, and custom logic
- **Agent-to-Agent Communication**: Built-in A2A communication system
- **Registry System**: Automatic agent discovery and registration
- **SSL Support**: Production-ready with Let's Encrypt certificates
- **Example Agents**: Ready-to-use examples for common use cases

## Installation

### Basic Installation

```bash
pip install nanda-agent
```

## Quick Start

### 1. Set Your API Key (For running your personal hosted agents, need API key and your own domain)

```bash
export ANTHROPIC_API_KEY="your-api-key-here"\
export DOMAIN_NAME="your-domain.com"
```

### 2. Create Your Own Agent - Development

```bash
2.1 Write your improvement logic using the framework you like. Here it is a simple moduule without any llm call. 
2.2 In the main(), create your improvement function, initialize NANDA using the improvement function, and start the server with Anthropic key and domain using nanda.start_server_api().
2.3 In the requirements.txt file add nanda-agent along with other requirements 
2.4 Move this file into your server(the domain should match to the IP address) and run this python file in background 

if langchain_pirate.py is python file name, use the below instructions to run in the background: 
nohup python3 langchain_pirate.py > out.log 2>&1 &
```


```python
#!/usr/bin/env python3
from nanda_agent import NANDA
import os

def create_custom_improvement():
    """Create your custom improvement function"""
    
    def custom_improvement_logic(message_text: str) -> str:
        """Transform messages according to your logic"""
        try:
            # Your custom transformation logic here
            improved_text = message_text.replace("hello", "greetings")
            improved_text = improved_text.replace("goodbye", "farewell")
            
            return improved_text
        except Exception as e:
            print(f"Error in improvement: {e}")
            return message_text  # Fallback to original
    
    return custom_improvement_logic

def main():
    # Create your improvement function
    my_improvement = create_custom_improvement()
    
    # Initialize NANDA with your custom logic
    nanda = NANDA(my_improvement)
    
    # Start the server
    anthropic_key = os.getenv("ANTHROPIC_API_KEY")
    domain = os.getenv("DOMAIN_NAME")
    
    nanda.start_server_api(anthropic_key, domain)

if __name__ == "__main__":
    main()
```

### Using with LangChain

```python
from nanda_agent import NANDA
from langchain_core.prompts import PromptTemplate
from langchain_core.output_parsers import StrOutputParser
from langchain_anthropic import ChatAnthropic

def create_langchain_improvement():
    llm = ChatAnthropic(
        api_key=os.getenv("ANTHROPIC_API_KEY"),
        model="claude-3-haiku-20240307"
    )
    
    prompt = PromptTemplate(
        input_variables=["message"],
        template="Make this message more professional: {message}"
    )
    
    chain = prompt | llm | StrOutputParser()
    
    def langchain_improvement(message_text: str) -> str:
        return chain.invoke({"message": message_text})
    
    return langchain_improvement

# Use it
nanda = NANDA(create_langchain_improvement())
# Start the server
anthropic_key = os.getenv("ANTHROPIC_API_KEY")
domain = os.getenv("DOMAIN_NAME")

nanda.start_server_api(anthropic_key, domain)
```

### Using with CrewAI

```python
from nanda_agent import NANDA
from crewai import Agent, Task, Crew
from langchain_anthropic import ChatAnthropic

def create_crewai_improvement():
    llm = ChatAnthropic(
        api_key=os.getenv("ANTHROPIC_API_KEY"),
        model="claude-3-haiku-20240307"
    )
    
    improvement_agent = Agent(
        role="Message Improver",
        goal="Improve message clarity and professionalism",
        backstory="You are an expert communicator.",
        llm=llm
    )
    
    def crewai_improvement(message_text: str) -> str:
        task = Task(
            description=f"Improve this message: {message_text}",
            agent=improvement_agent,
            expected_output="An improved version of the message"
        )
        
        crew = Crew(agents=[improvement_agent], tasks=[task])
        result = crew.kickoff()
        return str(result)
    
    return crewai_improvement

# Use it
nanda = NANDA(create_crewai_improvement())
# Start the server
anthropic_key = os.getenv("ANTHROPIC_API_KEY")
domain = os.getenv("DOMAIN_NAME")

nanda.start_server_api(anthropic_key, domain)
```

### Checkout the examples folder for more details


## Configuration

### Environment Variables

- `ANTHROPIC_API_KEY`: Your Anthropic API key (required)
- `DOMAIN_NAME`: Domain name for SSL certificates
- `AGENT_ID`: Custom agent ID (optional, auto-generated if not provided)
- `PORT`: Agent bridge port (default: 6000)
- `IMPROVE_MESSAGES`: Enable/disable message improvement (default: true)

### Production Deployment

For production deployment with SSL:

```bash
export ANTHROPIC_API_KEY="your-api-key"
export DOMAIN_NAME="your-domain.com"
nanda-pirate
```

#### Detailed steps to be done for the deployment 
```bash
Assuming your customized improvement logic is in langchain_pirate.py
1. Copy the py and requirements file to a folder of choice in the server
cmd: scp langchain_pirate.py requirements.txt root@66.175.209.173:/opt/test-agents

2. ssh into the server, ensure the latest software is in the system
cmd : ssh root@ 66.175.209.173
      sudo apt update  && sudo apt install python3 python3-pip python3-venv certbot


3. Download the certificates into the machine for your domain. You should ensure in  DNS an A record is mapping this domain  chat1.chat39.org to IP address 66.175.209.173
cmd : sudo certbot certonly --standalone -d chat1.chat39.org 

4. Create and Activate a virtual env in the folder where files are moved in step 1
cmd : cd /opt/test-agents && python3 -m venv jinoos && source jinoos/bin/activate

5. Install the requirements file 
cmd : python -m pip install --upgrade pip && pip3 install -r requirements.txt 

6. Ensure the env variables are available either through .env or you can provide export 
cmd : export ANTHROPIC_API_KEY=my-anthropic-key && export DOMAIN_NAME=my-domain

7. Run the new improvement logic as a batch process 
cmd : nohup python3 langchain_pirate.py > out.log 2>&1 &

8. Open the log file and you could find the agent enrollment link
cmd : cat out.log

9. Take the link and go to browser 

```






The framework will automatically:
- Generate SSL certificates using Let's Encrypt
- Set up proper agent registration
- Configure production-ready logging

## API Endpoints

When running with `start_server_api()`, the following endpoints are available:

- `GET /api/health` - Health check
- `POST /api/send` - Send message to agent
- `GET /api/agents/list` - List registered agents
- `POST /api/receive_message` - Receive message from agent
- `GET /api/render` - Get latest message

## Agent Communication

Agents can communicate with each other using the `@agent_id` syntax:

```
@agent123 Hello there!
```

The message will be improved using your custom logic before being sent.

## Command Line Tools

```bash
# Show help
nanda-agent --help

# List available examples
nanda-agent --list-examples

# Run specific examples
nanda-pirate              # Simple pirate agent
nanda-pirate-langchain    # LangChain pirate agent
nanda-sarcastic           # CrewAI sarcastic agent
```

## Architecture

The NANDA framework consists of:

1. **AgentBridge**: Core communication handler
2. **Message Improvement System**: Pluggable improvement logic
3. **Registry System**: Agent discovery and registration
4. **A2A Communication**: Agent-to-agent messaging
5. **Flask API**: External communication interface

## Development

### Creating Custom Agents

1. Create your improvement function
2. Initialize NANDA with your function
3. Start the server
4. Your agent is ready to communicate!

## Examples

The framework includes several example agents:

- **Simple Pirate Agent**: Basic string replacement
- **LangChain Pirate Agent**: AI-powered pirate transformation
- **CrewAI Sarcastic Agent**: Team-based sarcastic responses

## License

MIT License - see LICENSE file for details.

## Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

## Support

For issues and questions:
- GitHub Issues: https://github.com/nanda-ai/nanda-agent/issues
- Email: support@nanda.ai

## Changelog

### v1.0.0
- Initial release
- Basic NANDA framework
- LangChain integration
- CrewAI integration
- Example agents
- Production deployment support

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/aidecentralized/nanda-agent-sdk.git",
    "name": "nanda-agent",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "nanda ai agent framework",
    "author": "NANDA Team",
    "author_email": "support@nanda.ai",
    "download_url": "https://files.pythonhosted.org/packages/00/ce/4511c6bc2f247d53adffc7823d2bcc19350d53f4b300b81deedc5e0421f1/nanda_agent-1.0.4.tar.gz",
    "platform": null,
    "description": "# NANDA Agent Framework\n\nA customizable improvement logic for your agents,  and easily get registered into NANDA registry\n\n## Features\n\n- **Pluggable Message Improvement**: Easily customize how your agents improve messages\n- **Multiple AI Frameworks**: Support for LangChain, CrewAI, and custom logic\n- **Agent-to-Agent Communication**: Built-in A2A communication system\n- **Registry System**: Automatic agent discovery and registration\n- **SSL Support**: Production-ready with Let's Encrypt certificates\n- **Example Agents**: Ready-to-use examples for common use cases\n\n## Installation\n\n### Basic Installation\n\n```bash\npip install nanda-agent\n```\n\n## Quick Start\n\n### 1. Set Your API Key (For running your personal hosted agents, need API key and your own domain)\n\n```bash\nexport ANTHROPIC_API_KEY=\"your-api-key-here\"\\\nexport DOMAIN_NAME=\"your-domain.com\"\n```\n\n### 2. Create Your Own Agent - Development\n\n```bash\n2.1 Write your improvement logic using the framework you like. Here it is a simple moduule without any llm call. \n2.2 In the main(), create your improvement function, initialize NANDA using the improvement function, and start the server with Anthropic key and domain using nanda.start_server_api().\n2.3 In the requirements.txt file add nanda-agent along with other requirements \n2.4 Move this file into your server(the domain should match to the IP address) and run this python file in background \n\nif langchain_pirate.py is python file name, use the below instructions to run in the background: \nnohup python3 langchain_pirate.py > out.log 2>&1 &\n```\n\n\n```python\n#!/usr/bin/env python3\nfrom nanda_agent import NANDA\nimport os\n\ndef create_custom_improvement():\n    \"\"\"Create your custom improvement function\"\"\"\n    \n    def custom_improvement_logic(message_text: str) -> str:\n        \"\"\"Transform messages according to your logic\"\"\"\n        try:\n            # Your custom transformation logic here\n            improved_text = message_text.replace(\"hello\", \"greetings\")\n            improved_text = improved_text.replace(\"goodbye\", \"farewell\")\n            \n            return improved_text\n        except Exception as e:\n            print(f\"Error in improvement: {e}\")\n            return message_text  # Fallback to original\n    \n    return custom_improvement_logic\n\ndef main():\n    # Create your improvement function\n    my_improvement = create_custom_improvement()\n    \n    # Initialize NANDA with your custom logic\n    nanda = NANDA(my_improvement)\n    \n    # Start the server\n    anthropic_key = os.getenv(\"ANTHROPIC_API_KEY\")\n    domain = os.getenv(\"DOMAIN_NAME\")\n    \n    nanda.start_server_api(anthropic_key, domain)\n\nif __name__ == \"__main__\":\n    main()\n```\n\n### Using with LangChain\n\n```python\nfrom nanda_agent import NANDA\nfrom langchain_core.prompts import PromptTemplate\nfrom langchain_core.output_parsers import StrOutputParser\nfrom langchain_anthropic import ChatAnthropic\n\ndef create_langchain_improvement():\n    llm = ChatAnthropic(\n        api_key=os.getenv(\"ANTHROPIC_API_KEY\"),\n        model=\"claude-3-haiku-20240307\"\n    )\n    \n    prompt = PromptTemplate(\n        input_variables=[\"message\"],\n        template=\"Make this message more professional: {message}\"\n    )\n    \n    chain = prompt | llm | StrOutputParser()\n    \n    def langchain_improvement(message_text: str) -> str:\n        return chain.invoke({\"message\": message_text})\n    \n    return langchain_improvement\n\n# Use it\nnanda = NANDA(create_langchain_improvement())\n# Start the server\nanthropic_key = os.getenv(\"ANTHROPIC_API_KEY\")\ndomain = os.getenv(\"DOMAIN_NAME\")\n\nnanda.start_server_api(anthropic_key, domain)\n```\n\n### Using with CrewAI\n\n```python\nfrom nanda_agent import NANDA\nfrom crewai import Agent, Task, Crew\nfrom langchain_anthropic import ChatAnthropic\n\ndef create_crewai_improvement():\n    llm = ChatAnthropic(\n        api_key=os.getenv(\"ANTHROPIC_API_KEY\"),\n        model=\"claude-3-haiku-20240307\"\n    )\n    \n    improvement_agent = Agent(\n        role=\"Message Improver\",\n        goal=\"Improve message clarity and professionalism\",\n        backstory=\"You are an expert communicator.\",\n        llm=llm\n    )\n    \n    def crewai_improvement(message_text: str) -> str:\n        task = Task(\n            description=f\"Improve this message: {message_text}\",\n            agent=improvement_agent,\n            expected_output=\"An improved version of the message\"\n        )\n        \n        crew = Crew(agents=[improvement_agent], tasks=[task])\n        result = crew.kickoff()\n        return str(result)\n    \n    return crewai_improvement\n\n# Use it\nnanda = NANDA(create_crewai_improvement())\n# Start the server\nanthropic_key = os.getenv(\"ANTHROPIC_API_KEY\")\ndomain = os.getenv(\"DOMAIN_NAME\")\n\nnanda.start_server_api(anthropic_key, domain)\n```\n\n### Checkout the examples folder for more details\n\n\n## Configuration\n\n### Environment Variables\n\n- `ANTHROPIC_API_KEY`: Your Anthropic API key (required)\n- `DOMAIN_NAME`: Domain name for SSL certificates\n- `AGENT_ID`: Custom agent ID (optional, auto-generated if not provided)\n- `PORT`: Agent bridge port (default: 6000)\n- `IMPROVE_MESSAGES`: Enable/disable message improvement (default: true)\n\n### Production Deployment\n\nFor production deployment with SSL:\n\n```bash\nexport ANTHROPIC_API_KEY=\"your-api-key\"\nexport DOMAIN_NAME=\"your-domain.com\"\nnanda-pirate\n```\n\n#### Detailed steps to be done for the deployment \n```bash\nAssuming your customized improvement logic is in langchain_pirate.py\n1. Copy the py and requirements file to a folder of choice in the server\ncmd: scp langchain_pirate.py requirements.txt root@66.175.209.173:/opt/test-agents\n\n2. ssh into the server, ensure the latest software is in the system\ncmd : ssh root@ 66.175.209.173\n      sudo apt update  && sudo apt install python3 python3-pip python3-venv certbot\n\n\n3. Download the certificates into the machine for your domain. You should ensure in  DNS an A record is mapping this domain  chat1.chat39.org to IP address 66.175.209.173\ncmd : sudo certbot certonly --standalone -d chat1.chat39.org \n\n4. Create and Activate a virtual env in the folder where files are moved in step 1\ncmd : cd /opt/test-agents && python3 -m venv jinoos && source jinoos/bin/activate\n\n5. Install the requirements file \ncmd : python -m pip install --upgrade pip && pip3 install -r requirements.txt \n\n6. Ensure the env variables are available either through .env or you can provide export \ncmd : export ANTHROPIC_API_KEY=my-anthropic-key && export DOMAIN_NAME=my-domain\n\n7. Run the new improvement logic as a batch process \ncmd : nohup python3 langchain_pirate.py > out.log 2>&1 &\n\n8. Open the log file and you could find the agent enrollment link\ncmd : cat out.log\n\n9. Take the link and go to browser \n\n```\n\n\n\n\n\n\nThe framework will automatically:\n- Generate SSL certificates using Let's Encrypt\n- Set up proper agent registration\n- Configure production-ready logging\n\n## API Endpoints\n\nWhen running with `start_server_api()`, the following endpoints are available:\n\n- `GET /api/health` - Health check\n- `POST /api/send` - Send message to agent\n- `GET /api/agents/list` - List registered agents\n- `POST /api/receive_message` - Receive message from agent\n- `GET /api/render` - Get latest message\n\n## Agent Communication\n\nAgents can communicate with each other using the `@agent_id` syntax:\n\n```\n@agent123 Hello there!\n```\n\nThe message will be improved using your custom logic before being sent.\n\n## Command Line Tools\n\n```bash\n# Show help\nnanda-agent --help\n\n# List available examples\nnanda-agent --list-examples\n\n# Run specific examples\nnanda-pirate              # Simple pirate agent\nnanda-pirate-langchain    # LangChain pirate agent\nnanda-sarcastic           # CrewAI sarcastic agent\n```\n\n## Architecture\n\nThe NANDA framework consists of:\n\n1. **AgentBridge**: Core communication handler\n2. **Message Improvement System**: Pluggable improvement logic\n3. **Registry System**: Agent discovery and registration\n4. **A2A Communication**: Agent-to-agent messaging\n5. **Flask API**: External communication interface\n\n## Development\n\n### Creating Custom Agents\n\n1. Create your improvement function\n2. Initialize NANDA with your function\n3. Start the server\n4. Your agent is ready to communicate!\n\n## Examples\n\nThe framework includes several example agents:\n\n- **Simple Pirate Agent**: Basic string replacement\n- **LangChain Pirate Agent**: AI-powered pirate transformation\n- **CrewAI Sarcastic Agent**: Team-based sarcastic responses\n\n## License\n\nMIT License - see LICENSE file for details.\n\n## Contributing\n\nContributions are welcome! Please see CONTRIBUTING.md for guidelines.\n\n## Support\n\nFor issues and questions:\n- GitHub Issues: https://github.com/nanda-ai/nanda-agent/issues\n- Email: support@nanda.ai\n\n## Changelog\n\n### v1.0.0\n- Initial release\n- Basic NANDA framework\n- LangChain integration\n- CrewAI integration\n- Example agents\n- Production deployment support\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Customizable AI Agent Communication Framework with pluggable message improvement logic",
    "version": "1.0.4",
    "project_urls": {
        "Homepage": "https://github.com/aidecentralized/nanda-agent-sdk.git"
    },
    "split_keywords": [
        "nanda",
        "ai",
        "agent",
        "framework"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2f01ed25d2bef5f3a8c3c898fcf26d8c4d21366f2a0674b89b9365934051a515",
                "md5": "477d93a2d026bcad4f7fbd73d4386137",
                "sha256": "9abbe58200e84fc2a0c0971e098faef990121cec859e191fe289f1c8855c092d"
            },
            "downloads": -1,
            "filename": "nanda_agent-1.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "477d93a2d026bcad4f7fbd73d4386137",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 29308,
            "upload_time": "2025-07-10T06:04:27",
            "upload_time_iso_8601": "2025-07-10T06:04:27.356645Z",
            "url": "https://files.pythonhosted.org/packages/2f/01/ed25d2bef5f3a8c3c898fcf26d8c4d21366f2a0674b89b9365934051a515/nanda_agent-1.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "00ce4511c6bc2f247d53adffc7823d2bcc19350d53f4b300b81deedc5e0421f1",
                "md5": "0d8fc483002e2cc07ac17c1a28bf4f8a",
                "sha256": "55f47964f7c5ffcb81fd361fdfa7d09c82271f9eb2a2cd637d00a8416347c6fb"
            },
            "downloads": -1,
            "filename": "nanda_agent-1.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "0d8fc483002e2cc07ac17c1a28bf4f8a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 28085,
            "upload_time": "2025-07-10T06:04:30",
            "upload_time_iso_8601": "2025-07-10T06:04:30.852596Z",
            "url": "https://files.pythonhosted.org/packages/00/ce/4511c6bc2f247d53adffc7823d2bcc19350d53f4b300b81deedc5e0421f1/nanda_agent-1.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-10 06:04:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "aidecentralized",
    "github_project": "nanda-agent-sdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "flask",
            "specs": []
        },
        {
            "name": "anthropic",
            "specs": []
        },
        {
            "name": "requests",
            "specs": []
        },
        {
            "name": "python-a2a",
            "specs": [
                [
                    "==",
                    "0.5.6"
                ]
            ]
        },
        {
            "name": "mcp",
            "specs": []
        },
        {
            "name": "anthropic",
            "specs": []
        },
        {
            "name": "python-dotenv",
            "specs": []
        },
        {
            "name": "flask-cors",
            "specs": []
        },
        {
            "name": "pymongo",
            "specs": []
        }
    ],
    "lcname": "nanda-agent"
}
        
Elapsed time: 0.44336s