Baicai Base: AI Agent Framework Foundation
Baicai Base is the foundational framework for building intelligent AI agents for education using the LangGraph architecture. It provides a extensible foundation for creating multi-agent workflows that can collaborate, reason, and execute complex tasks.
🚀 Key Features
🤖 Multi-Agent Architecture
- ReAct Pattern Implementation: Built-in ReAct (Reasoning + Acting) agent framework
- Modular Node System: Extensible node-based architecture for custom agent behaviors
- State Management: Sophisticated state handling with memory persistence
- Conditional Routing: Intelligent routing logic with fail-fast and retry mechanisms
🔧 Core Components
- Base Graph Framework: Abstract base classes for building custom agent graphs
- Code Execution Engine: Safe code execution with debugging capabilities
- LLM Integration: Support for OpenAI-compatible APIs and Groq
- Configuration Management: Flexible configuration system with environment-based settings
🛠️ Developer Tools
- Rich Logging: Comprehensive logging with color-coded output
- Graph Visualization: Built-in Mermaid.js graph visualization
- Code Interpreter: Integrated code execution and debugging
- Memory Management: Persistent state and conversation memory
📋 Requirements
- Python: 3.10 or higher (tested up to 3.11)
- Dependencies: Managed via Poetry
- LLM Access: OpenAI API key or Groq API key
🛠️ Installation
1. Clone the Repository
git clone https://github.com/yourusername/baicai.git
cd baicai/baicai_base
2. Install Poetry (if not already installed)
# macOS/Linux
curl -sSL https://install.python-poetry.org | python3 -
# Windows (PowerShell)
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -
3. Install Dependencies
poetry install
4. Set Up Environment
# Set up your API keys
export OPENAI_API_KEY="your-openai-api-key"
# or
export GROQ_API_KEY="your-groq-api-key"
🏗️ Architecture Overview
Core Components
baicai_base/
├── agents/
│ ├── graphs/ # Graph implementations
│ │ ├── base_graph.py # Abstract base class
│ │ ├── react_coder_graph.py # ReAct pattern implementation
│ │ └── nodes/ # Node implementations
│ └── roles/ # Agent role definitions
├── configs/ # Configuration management
├── services/ # Core services (LLM, etc.)
└── utils/ # Utility functions and helpers
🚀 Quick Start
Basic ReAct Agent Usage
from baicai_base.agents.graphs import ReActCoder
from baicai_base.services import LLM
# Initialize LLM
llm_service = LLM()
# Create ReAct agent
agent = ReActCoder(
graph_name="MyAgent",
llm=llm_service.llm,
need_helper=True
)
# Define a question for the AI model to predict
question = "code a simple function to calculate the sum of two numbers"
# Invoke the AI model with the question and get the results
results = agent.app.invoke({"messages": [("user", question)]}, agent.config)
See react_coder_builder.ipynb for more
📚 Documentation
Core Concepts
- Agent Graphs: Understanding the graph-based architecture
- Node System: Building custom nodes and behaviors
- State Management: Managing agent state and memory
- Configuration: Setting up and managing configurations
API Reference
- BaseGraph: Abstract base class for all agent graphs
- ReActCoder: ReAct pattern implementation
- LLM Service: Language model integration
- Node Classes: Available node types and interfaces
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
Special thanks to:
- LangGraph Team: For the foundational graph framework
- LangChain Community: For the excellent LLM integration tools
- OpenAI & Groq: For providing powerful language models
- All Contributors: For helping build and improve this framework
Metadata
Release files for baicai-base 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| baicai_base-0.1.2.tar.gz | 36.0 kB | Without provenance | Details for baicai_base-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| baicai_base-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for baicai_base-0.1.2-py3-none-any.whl |
Total release size: 83.9 kB
Release files / baicai_base-0.1.2.tar.gz
| Download URL | baicai_base-0.1.2.tar.gz |
|---|---|
| Size | 36.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
18643b6844118ca367676b96ab6393977cf618735a281ae61fed1b5507933a66
|
|
BLAKE2b-256 checksum How to use checksums |
9ab91611776ba1ca92a81cf453db332cb85799ae950e43ca4fa37ec62d9d7c53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.13
|
Release files / baicai_base-0.1.2-py3-none-any.whl
| Download URL | baicai_base-0.1.2-py3-none-any.whl |
|---|---|
| Size | 47.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
76597587728a484ec9bc6f3702733a8ad3c804f2c20f548a04195dbd75dc0a34
|
|
BLAKE2b-256 checksum How to use checksums |
15adae4f062b5fc2bdee609f3c730689d8879c644e670716232ea4c09a9dd6e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.13
|
Security for baicai-base 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.