Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,32 @@ conversation_logs/
agents/test.py
nanda_agent/__pycache__

# Virtual environments
venv/
env/
.venv/
.env/

# Build artifacts
dist/
*.egg-info/
*.egg-info/

# Python cache files
__pycache__/
*.pyc
*.pyo
*.pyd

# IDE files
.vscode/
.idea/
*.swp
*.swo

# OS files
.DS_Store
Thumbs.db

# Log files
*.log
out.log
80 changes: 80 additions & 0 deletions README-Phala-Cloud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Deploy NANDA Agent on Phala Cloud

Deploy your NANDA agent in a secure, trusted execution environment using Phala Cloud's TEE infrastructure.

## Why Phala Cloud

**Trusted Execution Environment (TEE)** provides hardware-level security for AI agents:

- **Privacy Protection**: Agent computations run in isolated, encrypted environments
- **Verifiable Trust**: Cryptographic proof that your agent code hasn't been tampered with
- **Autonomous Security**: Agents can handle sensitive data without exposing it to cloud providers
- **Attestation**: Users can verify the integrity of your agent before interacting with it

TEE is crucial for autonomous AI agents because it ensures trustworthy AI operations while preserving user privacy - essential for building the decentralized agent ecosystem.

## Deployment Steps

### 1. Build Your Agent

```bash
cd nanda_agent
./build.sh docker_user_name/nanda-test:latest
```

This creates a Docker image with your agent and all dependencies.

### 2. Deploy to Phala Cloud

Create a Confidential VM using the [provided configuration](./nanda_agent/examples/docker-compose-phala.yml):

```yaml
services:
nanda-pirate:
image: h4x3rotab/nanda-demo:latest # change to yours
ports:
- "5000:5000"
- "6000:6000"
environment:
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-your-api-key-here}
- DOMAIN_NAME=${DSTACK_APP_ID}-5000.${DSTACK_GATEWAY_DOMAIN}
- API_URL=https://${DSTACK_APP_ID}-5000.${DSTACK_GATEWAY_DOMAIN}
- PUBLIC_URL=https://${DSTACK_APP_ID}-6000.${DSTACK_GATEWAY_DOMAIN}
- PORT=6000
- API_PORT=5000
- TERMINAL_PORT=6010
- IMPROVE_MESSAGES=true
- UI_MODE=true
- SSL=false
restart: unless-stopped
container_name: nanda-pirate-agent
volumes:
- nanda-logs:/app/conversation_logs

volumes:
nanda-logs:
```

The CVM will:
- Run your agent in a secure TEE
- Provide end-to-end secure networking and encrypted storage

### 3. Register Your Agent

1. **Find the enrollment link** in the logs
2. **Register on NANDA Chat** using the enrollment link

Your agent is now running in a trusted environment and accessible through the NANDA network.

## Environment Variables

Set the environment variables in encrypted secrets when creating the CVM:

```bash
ANTHROPIC_API_KEY=your-api-key
```

## Resources

- [Phala Network Documentation](https://docs.phala.network/)
- [Phala Cloud Console](https://cloud.phala.network/)
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ The framework will automatically:
- Set up proper agent registration
- Configure production-ready logging

## Deploy Autonomous Agents in TEE

[Phala Cloud](https://cloud.phala.network) allows you to build fully autonomous and privacy preserving AI Agents with verifiable cryptogrphic proofs using TEE (Trusted Execution Environment). Learn more at [Phala Cloud Deployment README](./README-Phala-Cloud.md).

## Appendix: Configuration Details

Expand Down
21 changes: 21 additions & 0 deletions nanda_agent/examples/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
venv/
env/
.venv/
.env/
__pycache__/
*.pyc
*.pyo
*.pyd
.git/
.gitignore
*.log
out.log
pirate_agent*.log
conversation_logs/
.DS_Store
Thumbs.db
.vscode/
.idea/
*.swp
*.swo
README.md
35 changes: 35 additions & 0 deletions nanda_agent/examples/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM python:3.10-slim

# Set working directory
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
curl \
&& rm -rf /var/lib/apt/lists/*

# Copy requirements file
COPY requirements.txt .

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy the application files
COPY langchain_pirate.py .

# Create directory for conversation logs
RUN mkdir -p conversation_logs

# Set environment variables with defaults
ENV ANTHROPIC_API_KEY=""
ENV DOMAIN_NAME="localhost"
ENV PORT=6000
ENV TERMINAL_PORT=6010
ENV IMPROVE_MESSAGES=true
ENV UI_MODE=true

# Expose the port
EXPOSE 6000

# Set the entrypoint
ENTRYPOINT ["python", "langchain_pirate.py"]
7 changes: 7 additions & 0 deletions nanda_agent/examples/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Usage: ./build.sh yourname/repo:tag
# e.g. ./build.sh h4x3rotab/nanda-demo:latest

docker build --platform linux/amd64 -t "${1}" .
docker push "${1}"
24 changes: 24 additions & 0 deletions nanda_agent/examples/docker-compose-phala.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
services:
nanda-pirate:
image: h4x3rotab/nanda-demo:latest
ports:
- "5000:5000"
- "6000:6000"
environment:
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-your-api-key-here}
- DOMAIN_NAME=${DSTACK_APP_ID}-5000.${DSTACK_GATEWAY_DOMAIN}
- API_URL=https://${DSTACK_APP_ID}-5000.${DSTACK_GATEWAY_DOMAIN}
- PUBLIC_URL=https://${DSTACK_APP_ID}-6000.${DSTACK_GATEWAY_DOMAIN}
- PORT=6000
- API_PORT=5000
- TERMINAL_PORT=6010
- IMPROVE_MESSAGES=true
- UI_MODE=true
- SSL=false
restart: unless-stopped
container_name: nanda-pirate-agent
volumes:
- nanda-logs:/app/conversation_logs

volumes:
nanda-logs:
9 changes: 7 additions & 2 deletions nanda_agent/examples/langchain_pirate.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,15 @@ def main():

if domain != "localhost":
# Production with SSL
nanda.start_server_api(os.getenv("ANTHROPIC_API_KEY"), domain)
api_port = int(os.getenv("API_PORT", "5000"))
port = int(os.getenv("PORT", "6000"))
public_url = os.getenv("PUBLIC_URL")
api_url = os.getenv("API_URL")
ssl = os.getenv("SSL") == "true"
nanda.start_server_api(os.getenv("ANTHROPIC_API_KEY"), domain, port=port, api_port=api_port, api_url=api_url, ssl=ssl, public_url=public_url)
else:
# Development server
nanda.start_server()
nanda.start_server(port=port)

if __name__ == "__main__":
main()