Skip to main content
This page details the configuration system of the Palyra daemon and the abstraction layer used to interface with Large Language Models (LLMs) and embedding services.

Configuration System

Palyra uses a TOML-based configuration system centered around the RootFileConfig schema. The configuration is loaded during daemon startup, supporting versioned migrations and sensitive data redaction.

RootFileConfig Schema

The RootFileConfig struct defines the top-level sections of the palyra.toml file. Each field is optional, allowing the daemon to fall back to hardcoded defaults defined in crates/palyra-daemon/src/config/schema.rs.
SectionDescription
deploymentDefines the environment mode (e.g., local_desktop, remote_vps) crates/palyra-common/src/daemon_config_schema.rs#85-88.
daemonNetwork binding settings for the internal HTTP server crates/palyra-common/src/daemon_config_schema.rs#92-95.
gatewaygRPC and QUIC transport settings, including TLS and identity store paths crates/palyra-common/src/daemon_config_schema.rs#99-112.
model_providerCredentials and parameters for LLM and embedding providers crates/palyra-common/src/daemon_config_schema.rs#195-212.
memoryLimits and retention policies for the RAG (Retrieval-Augmented Generation) system crates/palyra-common/src/daemon_config_schema.rs#145-151.
Sources: crates/palyra-common/src/daemon_config_schema.rs#64-81, crates/palyra-daemon/src/config/schema.rs#87-105

Secret Redaction and Safety

To prevent accidental exposure of credentials in logs or exported configurations, Palyra implements a multi-layered redaction strategy.
  1. Path-based Redaction: The SECRET_CONFIG_PATHS constant identifies specific TOML paths (e.g., model_provider.openai_api_key) that must be overwritten with <redacted> before serialization crates/palyra-common/src/daemon_config_schema.rs#6-14.
  2. Marker-based Redaction: The is_sensitive_key function checks for substrings like api_key, token, secret, or password in any key name to trigger redaction crates/palyra-common/src/redaction.rs#5-28.
  3. URL Redaction: The redact_url function strips user information (passwords) and sensitive query parameters from URLs crates/palyra-common/src/redaction.rs#63-86.
Sources: crates/palyra-common/src/daemon_config_schema.rs#22-26, crates/palyra-common/src/redaction.rs#1-30

Model Provider Abstraction

The ModelProvider trait (and its implementation) abstracts the complexities of communicating with LLMs. It supports two primary modes: OpenAiCompatible and Deterministic.

ModelProvider Logic Flow

The following diagram bridges the high-level request to the internal implementation classes. Diagram: Model Provider Request Pipeline Sources: crates/palyra-daemon/src/model_provider.rs#32-35, crates/palyra-daemon/src/model_provider.rs#184-195

Provider Types

  1. OpenAiCompatible: Targets any API following the OpenAI schema. It handles vision inputs (base64 encoding), tool calls (function calling), and streaming events crates/palyra-daemon/src/model_provider.rs#59-79.
  2. Deterministic: Used primarily for testing or highly constrained scenarios where a predictable output is required based on the input hash crates/palyra-daemon/src/model_provider.rs#41.

Reliability Patterns

The ModelProvider implementation includes built-in resilience features: Sources: crates/palyra-daemon/src/model_provider.rs#123-140, crates/palyra-daemon/src/model_provider.rs#195

Embeddings Provider

The EmbeddingsProvider interface is responsible for converting text into high-dimensional vectors used for semantic search in the JournalStore.

Implementation Details

Embeddings Data Flow

The system maps incoming text chunks to vector space for persistence. Diagram: Text to Embedding Mapping Sources: crates/palyra-daemon/src/model_provider.rs#198-208, crates/palyra-daemon/src/cron.rs#57-58

Background Backfill

The daemon runs a background task defined in crates/palyra-daemon/src/cron.rs that identifies journal events missing embeddings and processes them in batches using the configured EmbeddingsProvider crates/palyra-daemon/src/cron.rs#57-58. Sources: crates/palyra-daemon/src/cron.rs#57-58, crates/palyra-daemon/src/model_provider.rs#198-208