How sonnh96/saio works
Project Type and Purpose
• SAIO is a Python library and framework for building AI agents, workflows, and intelligent systems.
• It provides a modular, plug-and-play architecture: “Core Engine” (agents, workflows, runners), “Layers” (model abstraction, memory, knowledge, tools, storage), plus frontends (CLI, API server, GUI/playground).
• Use case: embed into other applications or run via CLI/API/playground to build, orchestrate, and evaluate AI-driven workflows.
File Structure Analysis
• Top-level directories:
• agent, workflow, run: Core engine components
• models, embedder: Model‐provider abstractions & embedding adapters
• memory, knowledge, tools: Business logic layers
• storage, vectordb: Persistence adapters (SQL, NoSQL, vector DBs)
• api, app, cli, playground: Entry points / UIs
• utils, document, eval, reasoning, reranker: Supporting services
• Pattern: Layered, hexagonal/adaptor style. Each layer defines interfaces (e.g., memory/db/base.py) and multiple backends (e.g., mongodb, postgres).
• Config & orchestration: pyproject.toml, setup.py, run/, cli/entrypoint.py.
README Insights
• Explicit mentions of the modular architecture:
• Core Engine
• Model Layer
• Storage Layer
• Tool Layer
• Memory Layer
• Lists core modules matching directories, confirming separation of concerns.
a. Main Components
• Frontends:
• CLI (cli/)
• API Server (api/, app/fastapi/)
• GUI/Playground (app/agui/, playground/)
• Core Engine:
• Agent Manager (agent/)
• Workflow Engine (workflow/, run/)
• Layers & Services:
• Model Abstraction (models/)
• Embedding Service (embedder/)
• Knowledge Systems (knowledge/, document/)
• Memory Management (memory/)
• Tool Integrations (tools/)
• Vector Stores (vectordb/)
• General Storage (storage/)
• External Dependencies:
• Third-party AI providers (OpenAI, Anthropic, etc.)
• Databases (Postgres, MongoDB, Redis, etc.)
• External APIs via tools (e.g., Gmail, Twitter, AWS)
b. Relationships & Data Flow
• Frontend → Core Engine: user requests or workflow definitions are passed to Agent/Workflow Engine.
• Core Engine ↔ Layers:
• Agent invokes memory for context/history.
• Agent/Workflow calls model abstraction to generate text.
• Workflows may call tools, knowledge retrieval, embeddings.
• Storage layers persist sessions, memory, vector embeddings.
• Core Engine ↔ External Services: HTTP/SDK calls to AI providers and tool APIs.
c. Architectural Patterns & Principles
• Hexagonal (ports & adapters) for each layer: interface definitions + multiple backend adapters.
• Modular layering: clear separation of concerns, easy to swap providers.
• Dependency inversion: Core engine depends on interfaces, not concrete classes.
• Asynchronous/synchronous router patterns in API and playground modules.
d. Key Technologies & Frameworks
• Python 3.9+
• FastAPI (api/, app/fastapi/)
• Click / Rich for CLI (cli/)
• Pydantic schemas (api/schemas/)
• Multiple third-party SDKs: OpenAI, Anthropic, AWS, etc.
• Vector DB clients: Chroma, Milvus, Pinecone, etc.