Arshai Documentation¶
Arshai is an AI framework built on a clean three-layer architecture that provides direct control over components through explicit instantiation and dependency injection. It empowers developers to build AI systems without hidden abstractions or forced patterns.
Core Features¶
- Three-Layer Architecture
Clean separation with Layer 1 (LLM Clients), Layer 2 (Agents), and Layer 3 (Agentic Systems) providing progressive developer authority
- Interface-Driven Design
Protocol-based interfaces that define clear contracts, enabling you to implement and integrate any component that respects the structure
- Direct Instantiation Philosophy
You create, configure, and control all components explicitly - no hidden factories, no magic configuration, no framework lock-in
- Developer Authority
Complete control over component lifecycle, dependencies, and behavior through explicit composition and dependency injection
Quick Start¶
Installation¶
pip install arshai
Three-Layer Example¶
Arshai’s power comes from its three-layer architecture where you build exactly what you need:
import os
from arshai.llms.openai import OpenAIClient
from arshai.core.interfaces.illm import ILLMConfig, ILLMInput
from arshai.agents.base import BaseAgent
from arshai.core.interfaces.iagent import IAgentInput
# Layer 1: LLM Client - You create and configure
os.environ["OPENAI_API_KEY"] = "your-api-key"
llm_config = ILLMConfig(model="gpt-4", temperature=0.7)
llm_client = OpenAIClient(llm_config)
# Layer 2: Agent - You implement your logic
class MyCustomAgent(BaseAgent):
async def process(self, input: IAgentInput) -> str:
# Your business logic here
llm_input = ILLMInput(
system_prompt=self.system_prompt,
user_message=f"Process this: {input.message}"
)
result = await self.llm_client.chat(llm_input)
return result['llm_response']
# Layer 3: System - You orchestrate components
class MyAISystem:
def __init__(self):
# You control component creation
self.agent = MyCustomAgent(
llm_client=llm_client,
system_prompt="You are a helpful assistant"
)
async def handle_request(self, message: str) -> str:
# You control the flow
return await self.agent.process(IAgentInput(message=message))
# Usage - You're in complete control
system = MyAISystem()
response = await system.handle_request("Hello!")
The Framework Philosophy¶
You’re the Architect: Arshai provides interfaces and building blocks, but you decide how to use them, when to use them, and whether to use them at all.
No Hidden Magic: Every component is created explicitly by you. No factories, no global state, no configuration files that hide behavior.
Interface Respect: Any component you build that implements our interfaces works seamlessly with the framework.
Documentation¶
Getting Started
Philosophy
- Philosophy
- Introduction
- Three-Layer Architecture
- Developer Authority
- Design Decisions
- Why We Removed the Settings Pattern
- Why Direct Instantiation Over Factories
- Why Agents Are Stateless
- Why Interface-First Design
- Why Environment Variables for Secrets
- Why Three Layers Instead of More (or Fewer)
- Why Python Protocols Over ABC
- Why Async-First Design
- Why Minimal Base Classes
- Summary of Design Principles
Framework (Core)
- Framework Core
- LLM Clients (Layer 1)
- Agents (Layer 2)
- BaseAgent Class
- Creating Agents
- Tools and Callables
- Agent Patterns
- Stateless Agent Design
- Agent Examples
- Agent Reference Implementations
- Core Philosophy
- What IS the Agent Framework
- What is NOT the Framework
- Basic Agent Structure
- Agent Creation Patterns
- Tools and Callables
- Advanced Patterns
- Agent Testing
- Usage Examples
- Benefits of This Architecture
- Reference Implementations
- Next Steps
- Building Systems (Layer 3)
Implementations (Reference)
- Reference Implementations
- Agent Reference Implementations
- WorkingMemoryAgent Reference Implementation
- Available Reference Implementations
- Common Patterns Demonstrated
- Using Reference Implementations
- Framework Integration Patterns
- Key Design Principles
- Testing Reference Implementations
- Best Practices from Reference Implementations
- Contributing Reference Implementations
- Orchestration Reference Implementations
- Workflow System
- Building Your Own Orchestration
- Available Reference Implementations
- Core Orchestration Capabilities
- Key Orchestration Patterns
- When to Use Orchestration
- Framework Integration
- Basic Orchestration Example
- Testing Orchestration Systems
- Best Practices for Orchestration
- Common Orchestration Challenges
- Memory Reference Implementations
- Component Reference Implementations
Tutorials
API Reference
Links¶
Documentation: https://felesh-ai.github.io/arshai/
License¶
This project is licensed under the MIT License - see the LICENSE file for details.