Anda KIP
A Rust implementation of KIP (Knowledge Interaction Protocol) for building sustainable AI knowledge memory systems.
Overview
🧬 KIP (Knowledge Interaction Protocol) is a knowledge memory interaction protocol designed for Large Language Models (LLMs), aimed at building sustainable learning and self-evolving knowledge memory systems for AI Agents.
This crate provides a complete Rust implementation of the KIP specification, offering:
- Parser: Full KIP command parsing with comprehensive error handling
- AST: Rich Abstract Syntax Tree structures for all KIP command types
- Executor Framework: Trait-based execution system for implementing KIP backends
- Request/Response: Standardized JSON-based communication structures
- Type Safety: Leverages Rust's type system for reliable KIP command processing
Specification
This implementation follows the official KIP specification. For detailed information about the protocol, syntax, and semantics, please refer to:
Features
🔍 KQL (Knowledge Query Language)
Powerful graph-based query language for knowledge retrieval and reasoning:
- Complex graph pattern matching with variables
- Aggregation functions (COUNT, COLLECT, SUM, AVG, MIN, MAX)
- Filtering, sorting, and pagination
- Optional and union clauses for flexible querying
- Subqueries and nested operations
🔧 KML (Knowledge Manipulation Language)
Declarative language for knowledge evolution and updates:
- Atomic UPSERT operations for concepts and propositions
- Knowledge Capsules for encapsulating related knowledge
- Precise DELETE operations with safety mechanisms
- Local handles for intra-transaction references
- Rich metadata support
📊 META Commands
Introspection and schema exploration capabilities:
- DESCRIBE commands for schema information
- SEARCH functionality for concept discovery
- Cognitive Primer generation for LLM guidance
Quick Start
Add this to your Cargo.toml:
[]
= "0.3"
Basic Usage
use ;
// Parse a KQL query
let query = parse_kip?;
// Parse a KML statement
let statement = parse_kip?;
// Parse a META command
let meta = parse_kip?;
Implementing an Executor
use ;
use async_trait;
High-Level Execution
use ;
// Using the high-level execution function
let executor = new;
let response = execute_kip.await?;
// Using structured requests with parameters
let request = Request ;
let response = request.execute.await?;
Architecture
The crate is organized into several key modules:
ast: Abstract Syntax Tree definitions for all KIP constructserror: Comprehensive error types and handlingexecutor: Execution framework and traitsparser: Nom-based parsers for KQL, KML, and META commandsrequest: Request/Response structures for JSON-based communication
Contributing
We welcome contributions! Please feel free to submit issues, feature requests, or pull requests.
License
Copyright © 2025 LDC Labs.
anda_kip is licensed under the MIT License. See LICENSE for the full license text.