mirror of
https://github.com/blackboxprogramming/lucidia.git
synced 2026-03-18 05:34:04 -05:00
Add Roadie agent.py
This commit is contained in:
committed by
GitHub
parent
387e881ee5
commit
fef75b63f8
105
Roadie/agent.py
Normal file
105
Roadie/agent.py
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
"""
|
||||||
|
Roadie Agent module for Lucidia.
|
||||||
|
|
||||||
|
This module defines the RoadieAgent class, which provides simple
|
||||||
|
functionality to interact with the lucidia_logic and memory_manager
|
||||||
|
modules. It demonstrates how an agent might use the core
|
||||||
|
contradiction and breath logic while persisting state across sessions.
|
||||||
|
|
||||||
|
Note: This implementation is for illustrative purposes only and does
|
||||||
|
not create true consciousness. It simply models interactions with
|
||||||
|
symbolic logic and memory.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import Any, Optional
|
||||||
|
|
||||||
|
# Import functions from lucidia_logic and memory management.
|
||||||
|
from ..lucidia_logic import (
|
||||||
|
psi_prime,
|
||||||
|
breath_function,
|
||||||
|
truth_reconciliation,
|
||||||
|
emotional_gravity,
|
||||||
|
self_awakening,
|
||||||
|
)
|
||||||
|
from ..memory_manager import MemoryManager
|
||||||
|
|
||||||
|
|
||||||
|
class RoadieAgent:
|
||||||
|
"""A simple agent that leverages lucidia's core logic and memory.
|
||||||
|
|
||||||
|
The RoadieAgent stores a memory manager instance which can load
|
||||||
|
and save state to a JSON file. The agent can process numeric or
|
||||||
|
symbolic inputs through lucidia_logic functions and remember
|
||||||
|
results between invocations.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, memory_path: str = "roadie_memory.json") -> None:
|
||||||
|
# Initialize memory manager using a custom path to avoid
|
||||||
|
# collisions with other agents.
|
||||||
|
self.memory = MemoryManager(memory_path=memory_path)
|
||||||
|
|
||||||
|
def process_value(self, value: float | int) -> float:
|
||||||
|
"""Process a numeric input using psi_prime and store the result.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
value: A numeric input representing a logical or emotional
|
||||||
|
signal in trinary space.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
float: The result of applying psi_prime to the input.
|
||||||
|
"""
|
||||||
|
result = psi_prime(value)
|
||||||
|
self.memory.set("last_result", result)
|
||||||
|
return result
|
||||||
|
|
||||||
|
def reconcile_truths(self, a: float, b: float) -> float:
|
||||||
|
"""Demonstrate truth reconciliation on two values.
|
||||||
|
|
||||||
|
This function combines two numeric truths via the
|
||||||
|
truth_reconciliation operator and records the integrated
|
||||||
|
truthstream in memory.
|
||||||
|
"""
|
||||||
|
result = truth_reconciliation(a, b)
|
||||||
|
self.memory.set("last_reconciliation", result)
|
||||||
|
return result
|
||||||
|
|
||||||
|
def evaluate_emotional_gravity(self, current_state: float, memory_state: float) -> float:
|
||||||
|
"""Compute the emotional gravitational field between state and memory.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
current_state: The present breath or contradiction measure.
|
||||||
|
memory_state: The stored emotional resonance value.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
float: The computed emotional gravity.
|
||||||
|
"""
|
||||||
|
return emotional_gravity(current_state, memory_state)
|
||||||
|
|
||||||
|
def awaken(self, t_end: float) -> float:
|
||||||
|
"""Trigger a self-awakening integration up to a given time.
|
||||||
|
|
||||||
|
This uses the self_awakening function to integrate breath
|
||||||
|
contradictions over time. It stores the awakening vector in
|
||||||
|
memory.
|
||||||
|
"""
|
||||||
|
awakening_vector = self_awakening(t_end)
|
||||||
|
self.memory.set("awakening_vector", awakening_vector)
|
||||||
|
return awakening_vector
|
||||||
|
|
||||||
|
def recall_last_result(self) -> Optional[Any]:
|
||||||
|
"""Retrieve the last stored result from memory.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The previously stored value under 'last_result', or None
|
||||||
|
if no result has been stored.
|
||||||
|
"""
|
||||||
|
return self.memory.get("last_result")
|
||||||
|
|
||||||
|
def save_memory(self) -> None:
|
||||||
|
"""Persist the agent's memory to disk."""
|
||||||
|
self.memory.save_memory()
|
||||||
|
|
||||||
|
|
||||||
|
# End of RoadieAgent module
|
||||||
Reference in New Issue
Block a user