# πŸ₯­ Mangaba AI β€” DocumentaΓ§Γ£o Completa > **Professional multi-agent orchestration framework with ReAct reasoning, RAG, memory, and function calling.** **VersΓ£o:** 3.2.0 | **LicenΓ§a:** MIT | **Python:** β‰₯3.9 --- ## πŸ“š Índice | SeΓ§Γ£o | DescriΓ§Γ£o | |---|---| | [Home](docs/Home.md) | VisΓ£o geral e introduΓ§Γ£o | | [Getting Started](docs/Getting-Started.md) | InstalaΓ§Γ£o e primeiro projeto | | [Core Components](docs/Core-Components.md) | Agent, Task, Crew | | [LLM Providers](docs/LLM-Providers.md) | Google, OpenAI, Anthropic, HuggingFace, OpenRouter | | [Tools](docs/Tools.md) | Sistema de ferramentas | | [Memory](docs/Memory.md) | Short-term, Long-term, Entity | | [RAG](docs/RAG.md) | Retrieval-Augmented Generation | | [Vector Stores](docs/Vector-Stores.md) | InMemory, Redis, PostgreSQL | | [Workflows](docs/Workflows.md) | Pipeline, Stage, ParallelStage | | [Events](docs/Events.md) | EventBus e Callbacks | | [Guardrails](docs/Guardrails.md) | ValidaΓ§Γ£o de entrada/saΓ­da | | [Protocols](docs/Protocols.md) | A2A e MCP | | [API Reference](docs/API-Reference.md) | ReferΓͺncia completa da API | | [Examples](docs/Examples.md) | Exemplos prΓ‘ticos | --- ## πŸ—οΈ Arquitetura ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Mangaba AI Framework β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ Agent β”‚ Crew β”‚ Workflow β”‚ RAG β”‚ Protocols β”‚ β”‚ (ReAct) β”‚(Orchestr)β”‚(Pipeline)β”‚(Retrieval)β”‚ (A2A/MCP) β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ Core Engine β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ LLM β”‚ β”‚Tools β”‚ β”‚Memory β”‚ β”‚Events β”‚ β”‚Guardrailsβ”‚ β”‚ β”‚ β”‚Client β”‚ β”‚Systemβ”‚ β”‚System β”‚ β”‚ Bus β”‚ β”‚ Parsers β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ LLM Providers (5 backends) β”‚ β”‚ Google β”‚ OpenAI β”‚ Anthropic β”‚ HF β”‚ OpenRouter β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ Vector Stores (3 backends) β”‚ β”‚ InMemory β”‚ Redis (RediSearch) β”‚ PostgreSQL(pgvector)β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` --- ## ✨ Recursos Principais | Recurso | DescriΓ§Γ£o | |---|---| | **Multi-Agent** | Orquestre mΓΊltiplos agents com 4 modos: Sequential, Hierarchical, Parallel, Consensual | | **ReAct Reasoning** | Thought β†’ Action β†’ Observation loop para uso inteligente de ferramentas | | **5 LLM Providers** | Google Gemini, OpenAI, Anthropic Claude, HuggingFace, OpenRouter | | **Function Calling** | Tool use nativo em todos os providers | | **RAG** | Pipeline completo: loaders, splitters, retriever, chain | | **3 Vector Stores** | InMemory, Redis (RediSearch HNSW), PostgreSQL (pgvector) | | **Memory** | Short-term (sliding window), Long-term (SQLite), Entity | | **Workflows** | Pipeline com Stage, ParallelStage, ConditionalStage | | **Event Bus** | Sistema de eventos para observabilidade e logging | | **Guardrails** | ValidaΓ§Γ£o de entrada/saΓ­da com cadeias de guardrails | | **A2A Protocol** | Agent-to-Agent communication | | **MCP Protocol** | Model Context Protocol integration | | **Streaming** | Suporte a streaming em todos os providers | | **Caching** | Cache de respostas LLM (InMemory, Disk) | | **Retry** | Retry automΓ‘tico com backoff exponencial | --- ## πŸš€ Quick Start ```python from mangaba import Agent, Task, Crew, Process from mangaba.core.types import LLMConfig from mangaba.core.llm import create_llm_client # 1. ConfiguraΓ§Γ£o via LLMConfig llm_config = LLMConfig( provider="google", model="gemini-2.5-flash", api_key="YOUR_KEY", temperature=0.7, max_tokens=4096, ) llm = create_llm_client( provider=llm_config.provider, api_key=llm_config.api_key, model=llm_config.model, temperature=llm_config.temperature, max_output_tokens=llm_config.max_tokens, ) # 2. Create agent researcher = Agent( role="Senior Researcher", goal="Discover cutting-edge developments in AI", backstory="Expert AI researcher with deep knowledge of the field", llm=llm, verbose=True, ) # 3. Create task task = Task( description="Research the latest trends in AI agents for 2026", expected_output="A comprehensive report with 10 key findings", agent=researcher, ) # 4. Create crew and run crew = Crew( agents=[researcher], tasks=[task], process=Process.SEQUENTIAL, ) result = crew.kickoff() print(result) ``` --- ## πŸ“¦ InstalaΓ§Γ£o ```bash # Instalar via pip pip install mangaba # Com RAG support pip install mangaba[rag] # Com Redis vector store pip install mangaba[redis] # Com PostgreSQL vector store pip install mangaba[postgres] # Todas as dependΓͺncias pip install mangaba[all] ``` --- ## πŸ“ Estrutura do Projeto ``` mangaba_ai/ β”œβ”€β”€ mangaba/ # Main package β”‚ β”œβ”€β”€ __init__.py # Public API exports β”‚ β”œβ”€β”€ core/ # Core framework β”‚ β”‚ β”œβ”€β”€ agent.py # Agent with ReAct reasoning β”‚ β”‚ β”œβ”€β”€ task.py # Task definitions β”‚ β”‚ β”œβ”€β”€ crew.py # Multi-agent orchestration β”‚ β”‚ β”œβ”€β”€ workflow.py # Pipeline engine β”‚ β”‚ β”œβ”€β”€ events.py # Event bus & callbacks β”‚ β”‚ β”œβ”€β”€ reasoning.py # ReAct engine β”‚ β”‚ β”œβ”€β”€ guardrails.py # Input/output validation β”‚ β”‚ β”œβ”€β”€ output_parsers.py # JSON, Pydantic parsers β”‚ β”‚ β”œβ”€β”€ planner.py # Task planning β”‚ β”‚ β”œβ”€β”€ types.py # Pydantic models β”‚ β”‚ β”œβ”€β”€ exceptions.py # Custom exceptions β”‚ β”‚ └── llm/ # LLM providers β”‚ β”‚ β”œβ”€β”€ client.py # Multi-provider engine β”‚ β”‚ β”œβ”€β”€ cache.py # Response caching β”‚ β”‚ β”œβ”€β”€ retry.py # Retry logic β”‚ β”‚ β”œβ”€β”€ token_counter.py# Token tracking β”‚ β”‚ └── prompt_templates.py β”‚ β”œβ”€β”€ tools/ # Tool system β”‚ β”‚ β”œβ”€β”€ base.py # BaseTool abstract class β”‚ β”‚ β”œβ”€β”€ decorator.py # @tool decorator β”‚ β”‚ β”œβ”€β”€ toolkit.py # Tool collections β”‚ β”‚ β”œβ”€β”€ math_tools.py # Calculator β”‚ β”‚ β”œβ”€β”€ text_tools.py # Text utilities β”‚ β”‚ β”œβ”€β”€ file_tools.py # File operations β”‚ β”‚ └── web_search.py # Web search β”‚ β”œβ”€β”€ memory/ # Memory systems β”‚ β”‚ β”œβ”€β”€ base.py # BaseMemory abstract class β”‚ β”‚ β”œβ”€β”€ short_term.py # Sliding window β”‚ β”‚ β”œβ”€β”€ long_term.py # SQLite + vector search β”‚ β”‚ └── entity.py # Entity tracking β”‚ β”œβ”€β”€ embeddings/ # Embedding providers β”‚ β”‚ β”œβ”€β”€ base.py # BaseEmbedding interface β”‚ β”‚ β”œβ”€β”€ openai_embed.py # OpenAI embeddings β”‚ β”‚ └── google_embed.py # Google embeddings β”‚ β”œβ”€β”€ vectorstores/ # Vector stores β”‚ β”‚ β”œβ”€β”€ base.py # BaseVectorStore interface β”‚ β”‚ β”œβ”€β”€ in_memory.py # Pure Python implementation β”‚ β”‚ β”œβ”€β”€ redis.py # Redis Stack (RediSearch) β”‚ β”‚ β”œβ”€β”€ postgres.py # PostgreSQL (pgvector) β”‚ β”‚ └── factory.py # create_vectorstore() β”‚ β”œβ”€β”€ rag/ # RAG pipeline β”‚ β”‚ β”œβ”€β”€ document.py # Document model β”‚ β”‚ β”œβ”€β”€ loaders.py # Text, CSV loaders β”‚ β”‚ β”œβ”€β”€ splitters.py # Text splitting β”‚ β”‚ β”œβ”€β”€ retriever.py # Embedding + vector store β”‚ β”‚ └── chain.py # RAG chain for Q&A β”‚ └── callbacks/ # Observability β”œβ”€β”€ protocols/ # Communication protocols β”‚ β”œβ”€β”€ a2a.py # Agent-to-Agent protocol β”‚ └── mcp.py # Model Context Protocol β”œβ”€β”€ examples/ # Example scripts β”œβ”€β”€ tests/ # Test suite β”œβ”€β”€ docs/ # Documentation (this wiki) β”œβ”€β”€ pyproject.toml # Project config └── docker-compose.vectorstores.yml ```