Base package for Baicai development and tutor
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file baicai_base-0.1.2.tar.gz.
File metadata
- Download URL: baicai_base-0.1.2.tar.gz
- Upload date:
- Size: 36.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18643b6844118ca367676b96ab6393977cf618735a281ae61fed1b5507933a66
|
|
| MD5 |
69f02a3d450dbbcbd4f3fbcbec615700
|
|
| BLAKE2b-256 |
9ab91611776ba1ca92a81cf453db332cb85799ae950e43ca4fa37ec62d9d7c53
|
File details
Details for the file baicai_base-0.1.2-py3-none-any.whl.
File metadata
- Download URL: baicai_base-0.1.2-py3-none-any.whl
- Upload date:
- Size: 47.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76597587728a484ec9bc6f3702733a8ad3c804f2c20f548a04195dbd75dc0a34
|
|
| MD5 |
4278f36d3a3037be2f251d1cca710adc
|
|
| BLAKE2b-256 |
15adae4f062b5fc2bdee609f3c730689d8879c644e670716232ea4c09a9dd6e0
|