Skip to main content
TypeAgent implements a conversation-based knowledge processing system with dual storage backends and structured retrieval. The architecture consists of four main layers that work together to transform raw conversation data into searchable, structured knowledge.

Architectural Overview

The system follows a clear data flow pipeline:
Input → Storage Layer → Knowledge Extractor → Query Pipeline → Response
  ↓          ↓               ↓                    ↓             ↓
Text    Collections+    Entities/Topics      Parallel      Generated
Audio   6 Indexes       Actions/Relations    Index         Answer +
Images                                        Queries       Citations

Four Core Layers

The storage layer provides a dual-implementation pattern with identical interfaces but different backing stores:

Collections (2 types)

  • MessageCollection - Stores conversation messages with ordinal indexing
  • SemanticRefCollection - Stores semantic references and knowledge artifacts

Indexes (6 types)

Each index serves a specific query pattern:
  • SemanticRefIndex - Term → SemanticRef mappings for content discovery
  • PropertyIndex - Property name → SemanticRef mappings for structured queries
  • TimestampToTextRangeIndex - Temporal navigation and filtering
  • MessageTextIndex - Embedding-based semantic similarity search
  • RelatedTermsIndex - Term expansion and alias resolution
  • ConversationThreads - Thread organization and context grouping

Storage Providers

# Memory provider - fast, no persistence
from typeagent.storage.memory import MemoryStorageProvider

provider = MemoryStorageProvider(
    message_text_settings=message_settings,
    related_terms_settings=related_settings
)

# SQLite provider - persistent with identical API
from typeagent.storage.sqlite import SqliteStorageProvider

provider = SqliteStorageProvider(
    db_path="conversation.db",
    message_text_index_settings=message_settings
)
Both providers expose identical APIs through the IStorageProvider interface, enabling seamless switching between in-memory and persistent storage.

Key Design Principles

Identical APIs for memory vs persistent storage enable seamless switching. Both MemoryStorageProvider and SqliteStorageProvider implement the same IStorageProvider interface, so your code works with either backend without changes.
# Transaction support works identically
async with storage_provider:
    await conversation.add_messages_with_indexing(messages)
    # SQLite: committed on success, rolled back on error
    # Memory: no rollback support
Six specialized indexes support different query patterns and access paths:
  • SemanticRefIndex - Fast term lookup
  • PropertyIndex - Structured property queries (name, type, facets)
  • TimestampIndex - Temporal filtering
  • MessageTextIndex - Embedding similarity
  • RelatedTermsIndex - Fuzzy matching and synonyms
  • ConversationThreads - Context grouping
All indexes are updated incrementally during message ingestion.
The system operates with basic extraction when AI models are unavailable:
  • Metadata extraction always works (titles, timestamps, basic fields)
  • LLM extraction is optional (controlled by auto_extract_knowledge setting)
  • Query fallback to text similarity when structured search finds nothing
This ensures the system remains functional even with limited resources.
Combines semantic similarity with structured knowledge for precision and recall:
  1. Structured first: Query specific properties (entities, actions, topics)
  2. Semantic fallback: Use embeddings when structured search fails
  3. Score fusion: Merge results from multiple indexes
  4. Context building: Assemble relevant knowledge for LLM
  5. Answer synthesis: Generate natural language response

Implementation Status

The architecture is fully implemented with production-ready components:
  • ✅ Dual storage providers with full API parity
  • ✅ Six-index architecture with unified testing
  • ✅ Multi-mode knowledge extraction pipeline
  • ✅ Natural language query processing with fallbacks
  • ✅ Thread-aware search and context building
  • ✅ Incremental indexing with transaction support
  • ✅ Embedding consistency validation

Next Steps

Structured RAG

Learn how TypeAgent’s structured RAG differs from traditional RAG

Knowledge Extraction

Understand how AI models extract structured knowledge

Indexing

Deep dive into the six specialized indexes

API Reference

Explore the complete API documentation

Build docs developers (and LLMs) love