# Sasefied Agent Library

[![Python Version](https://img.shields.io/badge/python-3.8+-blue.svg)](https://python.org)
[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
[![Status](https://img.shields.io/badge/status-active-brightgreen.svg)]()

A comprehensive, production-ready library for building intelligent AI agents and complete **agentic systems** with industry-specific capabilities. Sasefied provides a robust framework for creating specialized agents, orchestrating multi-agent collaborations, complete with pre-built industry solutions, advanced tools, and a sophisticated prompt management system.

## 🚀 Features

### Core Agent Framework
- **BaseAgent Class**: Extensible foundation for all agent types
- **ReAct Architecture**: Built on LangGraph for reasoning and acting
- **Tool Integration**: Seamless integration with LangChain tools
- **Multi-LLM Support**: Compatible with any LangChain-compatible chat model

### Multi-Agent Orchestration
- **Agentic Systems**: Complete multi-agent ecosystems for complex workflows
- **Agent Orchestration**: Coordinate multiple specialized agents working together
- **Industry Orchestrators**: Pre-built systems for airlines, EV batteries, and agriculture
- **Communication Protocols**: Structured agent-to-agent interactions
- **Task Distribution**: Intelligent workload management across agents
- **Workflow Coordination**: Complex multi-step process automation

### Industry-Specific Agents
- **Airlines**: Complete suite of 8 specialized agents for airline operations
  - Passenger Service, Revenue Management, Flight Operations
  - Safety Compliance, Maintenance Engineering, Network Planning
  - Crew Management, Ancillary Revenue
- **EV Batteries**: Specialized agents for electric vehicle battery lifecycle
  - Battery Technology, Manufacturing & Supply, Safety & Compliance
  - Lifecycle Management, System Orchestrator
- **Fruits & Agriculture**: Supply chain and quality management agents
  - Customer Service, Market Control, Quality Control
  - Supply Chain, Sustainability Management

### Advanced Tools
- **DeepSearchAgent**: Multi-step web research with DuckDuckGo integration
- **HTTP Tool**: Generic HTTP request tool for API interactions
- **Web Scraping**: Static and dynamic content extraction (Selenium support)

### Prompt Management Hub
- **Agent Prompt Hub**: Comprehensive library of pre-built prompts
- **CLI Interface**: Command-line tools for prompt exploration and management
- **Web Interface**: Browser-based prompt management system
- **Search & Filter**: Advanced search across industries and categories
- **Export Capabilities**: Multiple export formats for prompts

## 📦 Installation

```bash
pip install sasefied
```

### Optional Dependencies

For enhanced web scraping capabilities:
```bash
pip install sasefied[scraping]
```

For web interface:
```bash
pip install sasefied[web]
```

## 🎯 Quick Start

### Basic Agent Usage

```python
from sasefied.agents import DeepSearchAgent
from langchain_openai import ChatOpenAI

# Initialize LLM
llm = ChatOpenAI(model="gpt-4")

# Create a deep search agent
search_agent = DeepSearchAgent(llm=llm)

# Use the agent
result = search_agent.invoke([
    {"role": "user", "content": "Research the latest developments in quantum computing"}
])
print(result["messages"][-1].content)
```

### Industry-Specific Agents

```python
from sasefied.industry.airlines import create_passenger_service_agent
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(model="gpt-4")

# Create airline passenger service agent
agent = create_passenger_service_agent(llm=llm)

# Handle passenger inquiry
response = agent.invoke([
    {"role": "user", "content": "What are the baggage policies for international flights?"}
])
```

### Multi-Agent Agentic Systems

```python
from sasefied.industry.airlines import create_airline_orchestrator
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(model="gpt-4")

# Create complete airline management system
orchestrator = create_airline_orchestrator(llm)

# Coordinate multiple agents for complex operations
result = orchestrator.handle_flight_disruption(
    flight_id="AA123",
    issue="weather_delay",
    passengers=150
)
# Automatically coordinates: Operations, Crew, Passenger Service, Revenue Management
```

### Using the Prompt Hub

```python
from sasefied.hub import AgentPromptExplorerHub

# Initialize the hub
hub = AgentPromptExplorerHub()

# Search for prompts
prompts = hub.search_prompts("customer service", industry="retail")

# Export prompts
hub.export_prompts(prompts, format="json", output_file="customer_prompts.json")
```

### CLI Usage

```bash
# Explore available prompts
sasefied-hub explore

# Search for specific prompts
sasefied-hub search "revenue management" --industry airlines

# Export prompts
sasefied-hub export --industry healthcare --format yaml
```

## 🏗️ Architecture

```
sasefied/
├── agents/                 # Core agent framework
│   ├── base.py            # BaseAgent class
│   └── deep_search.py     # DeepSearchAgent implementation
├── industry/              # Industry-specific agents
│   ├── airlines/          # Airline industry agents
│   ├── ev_batteries/      # EV battery industry agents
│   └── fruits/            # Agriculture industry agents
├── hub/                   # Prompt management system
│   ├── core/              # Core models and repository
│   ├── cli.py             # Command-line interface
│   ├── web.py             # Web interface
│   └── hub.py             # Main hub functionality
├── tools/                 # Utility tools
│   └── http.py            # HTTP request tool
└── agentic_systems/       # Multi-agent orchestration
```

## 🔧 Configuration

### Environment Variables

```bash
# OpenAI API (if using OpenAI models)
OPENAI_API_KEY=your_api_key_here

# Optional: Custom model configurations
DEFAULT_MODEL=gpt-4
DEFAULT_TEMPERATURE=0.7
```

### Custom Agent Development

```python
from sasefied.agents.base import BaseAgent
from langchain_core.tools import BaseTool
from langchain_openai import ChatOpenAI

class CustomAgent(BaseAgent):
    def __init__(self, llm: ChatOpenAI, tools: List[BaseTool] = None):
        super().__init__(
            name="CustomAgent",
            description="Your custom agent description",
            tools=tools or [],
            llm=llm
        )
    
    def get_system_prompt(self) -> str:
        return "You are a specialized agent for..."
```

## 📚 Documentation

- [API Reference](docs/api.md)
- [Agent Development Guide](docs/agent-development.md)
- [Industry Solutions](docs/industry-solutions.md)
- [Prompt Hub Guide](docs/prompt-hub.md)

## 🤝 Contributing

We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.

### Development Setup

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

## 📄 License

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

## 🆘 Support

- 📖 [Documentation](docs/)
- 🐛 [Issue Tracker](https://github.com/your-org/sasefied/issues)
- 💬 [Discussions](https://github.com/your-org/sasefied/discussions)

## 🌟 Roadmap

- [ ] Additional industry modules (Healthcare, Finance, Manufacturing)
- [ ] Advanced orchestration patterns
- [ ] Performance monitoring and analytics
- [ ] Integration with more LLM providers
- [ ] Enhanced web scraping capabilities
- [ ] Agent marketplace and sharing platform

## 🏆 Acknowledgments

Built with:
- [LangChain](https://langchain.com/) - LLM framework
- [LangGraph](https://langchain-ai.github.io/langgraph/) - Agent orchestration
- [DuckDuckGo](https://duckduckgo.com/) - Search integration

---

**Sasefied** - Empowering the next generation of intelligent agents.