Skip to content

Examples

Practical examples demonstrating FactDb usage patterns.

Getting Started

  • Basic Usage - Simple introduction to core functionality

Use Cases

Common Patterns

Ingest and Extract

facts = FactDb.new

# Ingest content
source = facts.ingest(document_text, type: :document)

# Extract facts
extracted = facts.extract_facts(source.id, extractor: :llm)

Query Current State

# What do we know about Paula now?
current = facts.current_facts_for(paula.id)

Historical Query

# What did we know on a specific date?
historical = facts.facts_at(Date.parse("2023-06-15"), entity: paula.id)

Timeline

# Build complete timeline
timeline = facts.timeline_for(paula.id)
timeline.each do |fact|
  puts "#{fact.valid_at}: #{fact.text}"
end

Entity Resolution

# Resolve names to entities
entity = facts.resolve_entity("Paula Chen", type: :person)

Batch Processing

# Process multiple documents
results = facts.batch_extract(source_ids, parallel: true)