API Reference¶
The DreamLog API provides a comprehensive set of classes and functions for logic programming with wake-sleep optimization cycles.
Core Modules¶
Terms¶
Term- Base class for all termsAtom- Atomic constantsVariable- Logic variablesCompound- Compound terms with functors and arguments- Factory functions:
atom(),var(),compound()
Parser¶
parse_s_expression()- Parse S-expression syntaxparse_prefix_notation()- Parse JSON prefix arraysterm_to_sexp()- Convert terms to S-expressionsterm_to_prefix_json()- Convert terms to JSON
Knowledge Base¶
KnowledgeBase- Main storage for facts and rulesFact- Ground termsRule- Head-body implications- Indexing and retrieval methods
Unification¶
unify()- Standard unificationmatch()- One-way matchingsubsumes()- Subsumption checkingUnifier- Stateful unification operations
Evaluator¶
PrologEvaluator- SLD resolution with backtrackingSolution- Query results with variable bindings- Query evaluation strategies
Engine¶
DreamLogEngine- High-level API combining all componentsadd_fact(),add_rule(),query()methods- Persistence with
save_to_prefix(),load_from_prefix()
LLM Integration¶
LLM Providers¶
LLMProvider- Protocol for all providersMockLLMProvider- Testing providerOpenAIProvider- OpenAI API integrationAnthropicProvider- Anthropic Claude integrationOllamaProvider- Local LLM support
LLM Hook¶
LLMHook- Automatic knowledge generation- Context extraction and management
- Caching and rate limiting
Prompt Templates¶
PromptTemplateManager- Manage prompt templates- Template variables and substitution
- Custom template creation
Wake-Sleep System¶
KB Dreamer¶
KnowledgeBaseDreamer- Wake-sleep optimizationDreamSession- Dream cycle resultsDreamInsight- Individual optimizations- Compression, abstraction, and generalization
Configuration¶
DreamLogConfig- Main configurationLLMSamplingConfig- Sampling strategies- YAML configuration support
Pythonic Interface¶
Pythonic API¶
dreamlog()- Fluent API factory- Method chaining for facts and rules
- Query execution and results
Integration Modules¶
TUI¶
- Interactive terminal user interface
- Commands for queries, facts, rules
- LLM and dreaming support
MCP Server¶
- Model Context Protocol integration
- Tool definitions for DreamLog operations
- WebSocket communication
REST API¶
- HTTP endpoints for DreamLog
- WebSocket REPL support
- JSON request/response format