Sovereign AI Ecosystem

USAGE_EXAMPLES.md [component] deterministic

# Sovereign Intelligence Stack — Usage Examples **Version:** 1.0.0 **Last Updated:** July 5, 2026 **Repository:** [sovereign-intelligence-stack](https://gi

stackdocusage

Sovereign Intelligence Stack — Usage Examples

**Version:** 1.0.0 **Last Updated:** July 5, 2026 **Repository:** [sovereign-intelligence-stack](https://github.com/kliewerdaniel/sovereign-intelligence-stack)

---

Overview

This document provides usage examples for all components of the Sovereign Intelligence Stack. Each example demonstrates how to use a component in a real-world scenario.

**Prerequisites:** - Python 3.11+ - Installed dependencies (pip install -r requirements.txt) - Running Ollama server (for Ollama examples)

---

1. Recipe Compiler

Basic Usage

```python from src.recipe_compiler.models import Recipe from src.recipe_compiler.storage import RecipeStorage

Initialize storage storage = RecipeStorage("recipes.db")

Create a recipe recipe = Recipe( objective="Explain quantum computing", model="qwen3.5", memory_version=1, evaluation_score=0.92, outcome="accepted", tags=["quantum", "explanation"] )

Store the recipe recipe_id = storage.create_recipe(recipe) print(f"Recipe created: {recipe_id}") ```

Searching Recipes

```python # Search for recipes about quantum computing results = storage.search("quantum computing", top_k=10)

Filter by outcome accepted_recipes = [r for r in results if r.outcome == "accepted"]

Filter by model qwen_recipes = [r for r in results if r.model == "qwen3.5"] ```

Version Tracking

```python # Update a recipe recipe = storage.get_recipe(recipe_id) recipe.evaluation_score = 0.95 recipe.updated_at = datetime.now() storage.update_recipe(recipe.id, **recipe.__dict__)

Check version history versions = storage.get_version_history(recipe_id) print(f"Recipe has been updated {len(versions)} times") ```

---

2. Signal Router

Classifying Signals

```python from src.signal_router.classifier import SignalClassifier, SignalType

classifier = SignalClassifier()

Classify a signal signal_type = classifier.classify( objective="Explain quantum computing", context="user_query", available_models=["qwen3.5", "llama3.1", "gpt-4"] )

print(f"Signal type: {signal_type}")

Route based on signal type if signal_type == SignalType.CHEAP: print("Route to fast, lightweight model") elif signal_type == SignalType.EXPERT: print("Route to capable model with full context") elif signal_type == SignalType.HYBRID: print("Route to multi-stage evaluation") ```

Routing Logic

```python from src.signal_router.router import SignalRouter

router = SignalRouter()

Route a signal routing_result = router.route( signal_type=SignalType.CHEAP, available_models=["qwen3.5"], context="user_query" )

print(f"Recommended model: {routing_result.recommended_model}") print(f"Evaluation path: {routing_result.evaluation_path}") ```

---

3. Evaluation Loop

Running Evaluation

```python from src.evaluation.loop import EvaluationLoop

loop = EvaluationLoop()

Run evaluation on recent recipes results = loop.run( recipes=storage.search("quantum", limit=50), evaluation_metrics=["accuracy", "completeness", "relevance"] )

Get summary print(results.summary())

Get drift alerts print(results.drift_alerts) ```

Drift Detection

```python from src.evaluation.drifter import DriftDetector

detector = DriftDetector()

Detect drift between old and new recipes drift_report = detector.detect_drift( old_recipes=storage.search("quantum", limit=100, offset=0), new_recipes=storage.search("quantum", limit=100, offset=100) )

if drift_report.drift_detected: print(f"Drift detected: {drift_report.drift_score:.3f}") print(f"Drift type: {drift_report.drift_type}") print(f"Affected signals: {drift_report.affected_signals}") else: print("No significant drift detected") ```

---

4. Knowledge Systems

Graph Store

```python from src.knowledge.graph_store import GraphStore

graph = GraphStore()

Add nodes graph.add_node("quantum_computing", type="concept", importance=0.8) graph.add_node("qubit", type="concept", importance=0.7) graph.add_node("superposition", type="concept", importance=0.6)

Add edges graph.add_edge("quantum_computing", "qubit", relation="uses") graph.add_edge("qubit", "superposition", relation="can_be")

Query graph subgraph = graph.get_subgraph("quantum_computing", depth=2) print(f"Nodes: {[n.data['concept'] for n in subgraph.nodes.values()]}") print(f"Edges: {[(e.source, e.target, e.relation) for e in subgraph.edges]}") ```

Vector Store

```python from src.knowledge.vector_store import VectorStore

store = VectorStore("chroma.db")

Add documents store.add_documents([ {"id": "doc_1", "content": "Quantum computing uses qubits"}, {"id": "doc_2", "content": "Qubits can be in superposition"}, {"id": "doc_3", "content": "Quantum entanglement connects qubits"} ])

Search documents results = store.search("quantum", top_k=3) for result in results: print(f"{result.id}: {result.content} (score: {result.score:.3f})") ```

GraphRAG

```python from src.knowledge.graphrag import GraphRAG

graphrag = GraphRAG( graph_store=graph, vector_store=store )

Retrieve using GraphRAG query = "How do qubits work?" results = graphrag.retrieve(query, top_k=5)

for result in results: print(f"Type: {result.type}") print(f"Content: {result.content}") print(f"Score: {result.score:.3f}") print("---") ```

---

5. Memory Management

Memory Storage

```python from src.memory.storage import MemoryStorage

storage = MemoryStorage("memory.db")

Store memory memory_id = storage.store_memory( content="User asked about quantum computing", source="user_query", timestamp=datetime.now() )

Retrieve memories memories = storage.get_memories( query="quantum computing", limit=10 )

for memory in memories: print(f"{memory.content} (relevance: {memory.relevance_score:.3f})") ```

Memory Lifecycle

```python from src.memory.management import MemoryManager, MemoryLayer

manager = MemoryManager()

#

Sources

sovereign-intelligence-stack · source

Related (0)

No recorded relationships.

← all Stack