# DIAF **Repository Path**: dunimd/diaf ## Basic Information - **Project Name**: DIAF - **Description**: No description available - **Primary Language**: Python - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2026-01-01 - **Last Updated**: 2026-01-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README
# DIAF (Dunimd Intelligent Agent Framework) English | [δΈ­ζ–‡](README.zh.md) BiliBili Gitee GitHub PyPI **DIAF (Dunimd Intelligent Agent Framework)** β€” A comprehensive Python framework for building enterprise-grade AI Agent applications. Features modular architecture, intelligent routing, multi-level memory system, and seamless integration with major LLM frameworks.

πŸ—οΈ Core Architecture

### πŸ“ Modular Design DIAF adopts a highly modular architecture with 17 core modules, enabling on-demand composition and seamless extension:
| Module | Description | |:--------|:-------------| | **config** | Configuration management with environment variable support | | **core** | Base component abstraction, lifecycle management, and error handling | | **agent** | Agent factory, collaboration system, and specialized agents | | **tool** | Tool registry, execution, and sandboxed operations | | **memory** | Multi-level memory system (episodic, semantic, procedural, working) | | **planning** | Task planning engine with goal decomposition | | **execution** | Workflow builder, flow controller, and task scheduling | | **routing** | Smart routing with performance profiling and ML prediction | | **orchestration** | Unified orchestrator for complex multi-agent workflows | | **session** | Stateful session management with multiple storage backends | | **merging** | Multi-result merging with confidence scoring | | **integration** | Integrated framework combining all components | | **model** | Model connectors and providers for various LLM backends | | **monitoring** | Metrics collection, health checks, and alerting | | **adapters** | LangChain, AutoGen, CrewAI, and OpenAI Agents integration | | **dxml** | DIAF XML format parser, generator, and validator |
### πŸš€ Key Features #### πŸ€– Unified Agent Abstraction - Consistent interface across different LLM providers - Template-based agent creation with configurable capabilities - Built-in support for reasoning, planning, tool-use, and memory - Multi-agent collaboration with team management #### 🧠 Multi-Level Memory System - **Working Memory** - Short-term context for active reasoning - **Episodic Memory** - Event sequences and experience storage - **Semantic Memory** - Knowledge and concept storage - **Procedural Memory** - Skills and method storage - Adaptive memory consolidation strategies #### ⚑ Intelligent Routing - Performance profiling with latency tracking - Cost optimization for token usage - ML-based success rate and latency prediction - Multiple load balancing strategies (round-robin, least-connections, adaptive) #### πŸ”§ Tool Management - Comprehensive tool registry with categorization - Sandboxed execution environment - Circuit breaker pattern for fault tolerance - Automatic tool selection and validation #### πŸ“Š Workflow Orchestration - Visual workflow builder with dependency management - Parallel and sequential task execution - Workflow monitoring and state persistence - Error handling with configurable retry policies #### οΏ½ Framework Integration - Native adapters for LangChain, AutoGen, CrewAI - OpenAI Agents SDK support - Unified adapter interface for extensibility - Cross-framework tool and message translation #### πŸ“ˆ Enterprise Observability - Metrics collection for all components - Health checks and dependency monitoring - Alert management with severity levels - Performance analysis and benchmarking

πŸ› οΈ Installation & Environment

### Prerequisites - **Python**: 3.8+ - **pip**: Latest version - **Platforms**: Linux, macOS, Windows ### Quick Setup Install DIAF Python package: ```bash pip install DIAF ``` Or add to your `requirements.txt`: ``` DIAF==0.0.1 ``` ### Dependencies DIAF requires Python 3.7 or later. Core dependencies include:
| πŸ“¦ Package | πŸ“œ Version | πŸ“ Description | |:-----------|:-----------|:---------------| | pydantic | >=2.0.0 | Data validation and settings | | numpy | >=1.24.0 | Numerical computing | | scikit-learn | >=1.3.0 | Machine learning utilities |
Optional dependencies (install with `pip install DIAF[all]`):
| πŸ“¦ Package | πŸ“œ Version | πŸ“ Description | |:-----------|:-----------|:---------------| | faiss-cpu | >=1.7.0 | Vector similarity search | | faiss-gpu | >=1.7.0 | GPU-accelerated vector search | | redis | >=4.5.0 | Session storage backend | | lz4 | >=4.3.0 | Fast compression |

⚑ Quick Start

### Core API Usage ```python import asyncio from DIAF import DIAFConfig, DIAFToolRegistry, DIAFMemoryManager async def main(): # Initialize configuration config = DIAFConfig( framework_name="MyAgentApp", max_concurrent_agents=10, ) # Initialize tool registry tool_registry = DIAFToolRegistry() # Initialize memory manager memory_manager = DIAFMemoryManager() print("DIAF initialized successfully!") if __name__ == "__main__": asyncio.run(main()) ``` ### Creating an Agent ```python from DIAF import ( DIAFAgentConfig, DIAFAgentFactory, DIAFAgentCapability, ) from DIAF.memory import DIAFMemoryType async def create_agent(): # Configure agent config = DIAFAgentConfig( agent_id="my_agent", agent_name="My AI Agent", agent_type="general", capabilities={ DIAFAgentCapability.REASONING, DIAFAgentCapability.PLANNING, DIAFAgentCapability.TOOL_USE, }, memory_types={ DIAFMemoryType.EPISODIC, DIAFMemoryType.SEMANTIC, }, ) # Create agent factory factory = DIAFAgentFactory() agent = await factory.create_agent(config) return agent ``` ### Building Workflows ```python from DIAF.execution import ( DIAFFlowController, DIAFWorkflowBuilder, DIAFTaskType, DIAFPriority, DIAFTaskDependencyType, ) async def create_workflow(): # Initialize flow controller flow_controller = DIAFFlowController() await flow_controller.initialize() # Create workflow builder = DIAFWorkflowBuilder() workflow_def = await builder.create_workflow( workflow_id="my_workflow", workflow_name="My Workflow", description="A demonstration workflow", ) # Add tasks await builder.add_task( task_id="task_1", task_name="First Task", task_type=DIAFTaskType.CHAT, agent_type="chat", parameters={"message": "Hello!"}, priority=DIAFPriority.HIGH, ) await builder.add_task( task_id="task_2", task_name="Second Task", task_type=DIAFTaskType.TASK, agent_type="task", parameters={"operation": "process"}, dependencies=["task_1"], dependency_type=DIAFTaskDependencyType.SEQUENTIAL, ) # Validate and submit is_valid, errors = await builder.validate_workflow() if is_valid: await flow_controller.register_workflow(workflow_def) execution_id = await flow_controller.submit_workflow("my_workflow") print(f"Workflow submitted: {execution_id}") ``` ### Multi-Agent Collaboration ```python from DIAF.agent import ( DIAFAgentCollaborationSystem, DIAFTeamConfig, DIAFTeamMemberConfig, DIAFAgentRole, DIAFCollaborationMode, ) async def create_team(): # Create collaboration system collaboration = DIAFAgentCollaborationSystem() # Create team team_config = DIAFTeamConfig( team_id="research_team", team_name="Research Team", collaboration_mode=DIAFCollaborationMode.HIERARCHICAL, ) team = await collaboration.create_team(team_config) # Add team members await collaboration.add_team_member( team.team_id, DIAFTeamMemberConfig( member_id="researcher_001", agent_role=DIAFAgentRole.RESEARCHER, ), ) return collaboration, team ``` ### Framework Adapters ```python from DIAF.adapters import DIAFAdapterRegistry, DIAFLangChainAdapter # Create adapter registry registry = DIAFAdapterRegistry() # Register LangChain adapter registry.register_adapter_info(DIAFLangChainAdapter.get_adapter_info()) # Get available adapters adapters = registry.list_adapters() print(f"Available adapters: {[a.name for a in adapters]}") ```

πŸ”§ Configuration

### Configuration Example DIAF can be configured through Python code, environment variables, or config files: ```python from DIAF import DIAFConfig config = DIAFConfig( framework_name="MyApp", max_concurrent_agents=100, session_timeout_seconds=3600, ) ``` ### Configuration Sources DIAF supports multiple configuration sources in order of priority (highest to lowest): 1. Runtime parameters (Python code) 2. Environment variables (prefixed with `DIAF_`) 3. Configuration files (YAML, TOML, JSON) 4. Default values ### Environment Variables ```bash export DIAF_FRAMEWORK_NAME="MyApp" export DIAF_MAX_CONCURRENT_AGENTS=100 export DIAF_SESSION_TIMEOUT=3600 export DIAF_LOG_LEVEL="INFO" ```

πŸ§ͺ Development & Testing

### Running Tests ```bash # Install development dependencies pip install DIAF[dev] # Run all tests pytest # Run with coverage pytest --cov=DIAF --cov-report=html # Run specific test module pytest tests/test_config.py # Run slow tests pytest -m slow ```

πŸ“š Documentation

| οΏ½ Documentation | πŸ”— Link | |:-----------------|:--------| | Architecture Overview | [docs/architecture.md](docs/architecture.md) | | API Reference | [docs/api/](docs/api/) | | Examples | [examples/](examples/) |

πŸ“ Examples

| οΏ½ Example | πŸ“– Description | |:-----------|:---------------| | [workflow_example.py](examples/workflow_example.py) | Basic workflow creation and execution | | [advanced_workflow_example.py](examples/advanced_workflow_example.py) | Advanced workflow patterns | | [basic_example.py](examples/basic_example.py) | Core API usage examples | | [agent_collaboration_example.py](examples/agent_collaboration_example.py) | Multi-agent collaboration |

❓ Frequently Asked Questions

**Q: How to add a custom agent?** A: Use DIAFAgentFactory with a custom DIAFAgentConfig, specifying the desired capabilities. **Q: How to configure memory backend?** A: Set `memory_config` in DIAFConfig with your preferred storage backend. **Q: How to enable metrics export?** A: Configure `telemetry_config` in DIAFConfig to enable metrics collection. **Q: How to extend with custom adapters?** A: Implement DIAFAbstractAdapter and register with DIAFAdapterRegistry. **Q: What LLM providers are supported?** A: OpenAI, Anthropic, Google Gemini, and any provider through custom adapters. **Q: How to handle async operations?** A: DIAF uses asyncio throughout; use async/await patterns consistently. **Q: Is DIAF compatible with FastAPI/other frameworks?** A: Yes, DIAF components can be integrated with any async Python framework.

🌏 Community & Citation

- Welcome to submit Issues and PRs! - Gitee: https://gitee.com/dunimd/diaf.git
## πŸ“„ License & Open Source Agreements ### πŸ›οΈ Project License

Apache License 2.0

This project uses **Apache License 2.0** open source agreement, see [LICENSE](LICENSE) file. ### πŸ“‹ Dependencies License
| πŸ“¦ Package | πŸ“œ License | |:-----------|:-----------| | pydantic | MIT | | numpy | BSD-3 | | scikit-learn | BSD-3 | | pytest | MIT | | pytest-asyncio | Apache 2.0 | | black | MIT | | mypy | MIT |