bssagent 0.1.1
BSS Agent – A simple AI agent framework based on LangGraph
License: MIT
Requires Python: >=3.8
Keywords: ai, agent, langchain, langgraph, business, automation

# BSS Agent

A comprehensive AI agent framework built with LangChain and LangGraph for business support systems.

## Features
- **Authentication**: Support client access via API Key.
- **Server API**: 
    - FastAPI-based REST API
    - Support agent response streaming
- **Security**: 
    - Rate limiter to avoid DDOS
    - Data Privacy protector
    - Prompt santinizer.
- **Environment Management**: Configuration and environment handling
- **Database Integration**:
    - For checkpoints
    - For long memory context (store)
    - Multi DB connection
- **RAGPipeline**:
    - Extract data from multi sources
    - Automatic create embedding model based on name
    - Easy to use Vector DB
- **Core Framework**: Base agent and multi user sessions management
- **Testing**: Comprehensive unit test for all features

## Installation

### From PyPI

```bash
pip install bssagent
```

### From Source

```bash
git clone https://github.com/bssagent/bssagent.git
cd bssagent
pip install -e .
```

### Development Installation

```bash
git clone https://github.com/bssagent/bssagent.git
cd bssagent
pip install -e ".[dev]"
```

## Quick Start

```python
from bssagent.core import BSSAgent
from bssagent.environment import EnvironmentManager

# Initialize environment
env_manager = EnvironmentManager()
env_manager.load_config()

# Create agent
agent = BSSAgent(
    name="business_agent",
    description="Business support agent",
    tools=["file_io", "api_integration", "database"]
)

# Run agent
response = agent.run("Analyze the current business metrics")
print(response)
```

## Project Structure

```
bssagent/
├── src/bssagent/
│   ├── core/           # Core agent framework
│   ├── infrastructure/ # Infrastructure management
│   ├── auth/           # Authentication
│   ├── security/       # Security features
│   ├── environment/    # Environment management
│   ├── mcp/           # Model Context Protocol
│   ├── rag/           # Tool ecosystem
│   ├── database/      # Database integration
│   └── shared/        # Shared utilities
├── tests/             # Test suite
├── docs/              # Documentation
```

## Configuration

Setup Environment Variables

Create a `.env` file in your project root with the following configuration:

```env
# LLM API Keys (choose your preferred provider)
OPENAI_API_KEY=your_openai_api_key
ANTHROPIC_API_KEY=your_anthropic_api_key
GOOGLE_API_KEY=your_google_api_key
DEEPSEEK_API_KEY=your_deepseek_api_key
OLLAMA_BASE_URL=http://localhost:11434

# LangSmith Tracing (optional)
LANGCHAIN_API_KEY=your_langsmith_api_key
LANGCHAIN_TRACING_V2=true
LANGCHAIN_PROJECT=your_project_name

# Database Configuration
# Option 1: Use separate databases for checkpointer and store
LANGGRAPH_CHECKPOINTER_TYPE=postgres
LANGGRAPH_CHECKPOINTER_USERNAME=user
LANGGRAPH_CHECKPOINTER_PASSWORD=password
LANGGRAPH_CHECKPOINTER_HOST=localhost
LANGGRAPH_CHECKPOINTER_PORT=5432
LANGGRAPH_CHECKPOINTER_DATABASE=bssagent_checkpoint

LANGGRAPH_STORE_TYPE=postgres
LANGGRAPH_STORE_USERNAME=user
LANGGRAPH_STORE_PASSWORD=password
LANGGRAPH_STORE_HOST=localhost
LANGGRAPH_STORE_PORT=5432
LANGGRAPH_STORE_DATABASE=bssagent_store

# Option 2: Use single database for all purposes
ONE_DB=1
DB_TYPE=postgres
DB_USERNAME=user
DB_PASSWORD=password
DB_HOST=localhost
DB_PORT=5432
DB_NAME=bssagent

```

## Setup Database with Docker

BSS Agent supports multiple database backends. The easiest way to get started is using Docker Compose.

### Quick Database Setup

Use the provided Docker Compose file:

```bash
# Navigate to the examples directory
cd examples/dockerdbfile

# Start the databases
docker compose up -d

# Verify containers are running
docker ps
```

This will start:
- **PostgreSQL** on port 5432
- **MySQL** on port 3306  
- **Redis** on port 6379

### Manual Docker Setup

If you prefer to set up databases manually, create a `docker-compose.yml` file:

```yaml
services:
  postgres_db:
    image: postgres:14.18-bookworm
    container_name: postgres_container
    restart: always
    environment:
      POSTGRES_USER: user
      POSTGRES_PASSWORD: password
      POSTGRES_DB: mydatabase
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data

  mysql_db:
    image: mysql:oracle
    container_name: mysql_container
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: mydatabase
      MYSQL_USER: user
      MYSQL_PASSWORD: password
    ports:
      - "3306:3306"
    volumes:
      - mysql_data:/var/lib/mysql

  redis_db:
    image: redis:bookworm
    container_name: redis_container
    restart: always
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data

volumes:
  postgres_data:
  mysql_data:
  redis_data:
```

Then run:

```bash
docker compose up -d
```

### Database Connection Verification

Test your database connections:

**PostgreSQL:**
```bash
# From host machine
psql -h localhost -U user -d mydatabase

# From Docker container
docker exec -it postgres_container psql -U user -d mydatabase
```

**MySQL:**
```bash
# From host machine
mysql -h localhost -u user -p mydatabase

# From Docker container
docker exec -it mysql_container mysql -u user -p mydatabase
```

**Redis:**
```bash
# From host machine
redis-cli -h localhost -p 6379

# From Docker container
docker exec -it redis_container redis-cli
```

## Supported Database Types

BSS Agent supports the following database backends:

| Database | Type | Use Case |
|----------|------|----------|
| PostgreSQL | `postgres` | Checkpointer and Store |
| MySQL | `mysql` | Checkpointer and Store |
| MongoDB | `mongodb` | Checkpointer only |
| Redis | `redis` | Checkpointer and Store |
| SQLite | `sqlite` | Checkpointer and Store |

## Documentation

- [API Reference](https://bssagent.readthedocs.io/en/latest/api/)
- [User Guide](https://bssagent.readthedocs.io/en/latest/user_guide/)
- [Developer Guide](https://bssagent.readthedocs.io/en/latest/developer/)
- [Deployment Guide](https://bssagent.readthedocs.io/en/latest/deployment/)

## Contributing

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Support

- Documentation: https://bssagent.readthedocs.io
- Issues: https://github.com/bssagent/bssagent/issues
- Discussions: https://github.com/bssagent/bssagent/discussions
- Email: team@bssagent.com

## Changelog

See [CHANGELOG.md](CHANGELOG.md) for a list of changes and version history.