1.0.0 โข Published 4 months ago
@edgemaker/core v1.0.0
Edgemaker
A TypeScript knowledge graph library inspired by Graphiti, designed for building temporally-aware AI memory systems.
๐ Quick Start
Prerequisites
- Node.js 18+
- Supabase project with pgvector enabled
- OpenAI API key
Installation
npm install
Environment Setup
Create a .env.development
file with your credentials:
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
OPENAI_API_KEY=sk-your-openai-key
NODE_ENV=development
Database Setup
The database schema migration is located at:
supabase/migrations/20250101000001_edgemaker_initial_schema.sql
To apply the schema to your Supabase project, run this SQL in the Supabase Dashboard SQL Editor.
Basic Usage
import { Edgemaker, createEdgemakerConfig } from '@edgemaker/core';
// Create configuration
const config = createEdgemakerConfig({
supabase: {
url: process.env.SUPABASE_URL!,
serviceKey: process.env.SUPABASE_SERVICE_ROLE_KEY!,
anonKey: process.env.SUPABASE_ANON_KEY!,
},
llm: {
openai: {
apiKey: process.env.OPENAI_API_KEY!,
},
},
});
// Initialize Edgemaker
const edgemaker = new Edgemaker(config);
// Add an episode
const result = await edgemaker.addEpisode({
content: "John bought coffee at Starbucks this morning",
group_id: "project-1",
});
// Search the knowledge graph with different strategies
const searchResults = await edgemaker.search("coffee shops", {
groupIds: ["project-1"],
searchType: "story", // 'quick', 'story', 'character', 'factual', 'exploratory'
limit: 10
});
// Advanced search with custom configuration
const advancedResults = await edgemaker.advancedSearch("character relationships", {
searchConfig: {
node_config: { method: 'cosine_similarity', limit: 15 },
edge_config: { method: 'bm25', limit: 10 },
reranking_strategy: 'node_distance'
},
filters: { groupIds: ["project-1"] }
});
๐งช Testing
# Run all tests
npm test
# Run only unit tests (fast, no external APIs)
npm run test:unit
# Run only integration tests (requires API keys)
npm run test:integration
# Run tests in watch mode
npm run test:watch
npm run test:watch:unit
npm run test:watch:integration
# Quick test (unit tests only)
npm run test:quick
# Build the project
npm run build
๐ Project Structure
src/
โโโ core/ # Core Edgemaker class
โโโ infrastructure/ # External integrations
โ โโโ supabase/ # Database client
โ โโโ llm/ # LLM clients
โโโ processors/ # Episode processing pipeline
โโโ search/ # Search and retrieval
โโโ prompts/ # LLM prompt templates
โโโ types/ # TypeScript definitions
โโโ utils/ # Utility functions
supabase/
โโโ migrations/ # Database schema
โโโ functions/ # Edge functions (optional)
๐๏ธ Database Schema
The system uses PostgreSQL with pgvector for:
- Episodes: Raw input episodes
- Entities: Extracted entities with embeddings
- Entity Edges: Relationships between entities
- Communities: Clustered entity groups
Key features:
- Temporal relationship tracking
- Vector similarity search
- Current/historical edge management
- Row-level security for multi-tenancy
๐ง Core Concepts
Episodes
Raw input data that gets processed into the knowledge graph.
Entities
Extracted people, places, objects, and concepts with:
- Name embeddings for semantic search
- Summaries and attributes
- Temporal context
Edges
Relationships between entities with:
- Fact embeddings
- Temporal validity periods
- Episode provenance
Search
Hybrid retrieval combining:
- Vector similarity (embeddings)
- Full-text search (PostgreSQL)
- Graph traversal
๐ง Current Status
Implemented:
- โ Project structure and TypeScript setup
- โ Database schema with pgvector support
- โ Supabase client configuration
- โ OpenAI LLM client integration
- โ Entity and edge extraction using LLM prompts
- โ Deduplication and conflict resolution
- โ Hybrid search implementation (vector + full-text + reranking)
- โ Core Edgemaker class with full pipeline
- โ Comprehensive test suite (unit + integration)
- โ Health checks and monitoring
TODO:
- Graph traversal search (BFS)
- Community detection algorithms
- Advanced documentation and examples
- Performance optimization
๐ Documentation
See the docs/
directory for detailed architecture and implementation guides:
๐ค Contributing
This is a work-in-progress project. Feel free to contribute by:
- Implementing missing features
- Adding tests
- Improving documentation
- Optimizing performance
๐ License
MIT
1.0.0
4 months ago