DEV Community

Cover image for The Structure Supreme β€” Lazy File Architecture for the AGI software design pattern
owly
owly

Posted on

The Structure Supreme β€” Lazy File Architecture for the AGI software design pattern

🧠 The Structure Supreme β€” Lazy File Architecture for LivinGrimoire

By Moti Barski

πŸ“Œ Devlog source


this is a unique and super lazy files structure design for the LivinGrimoire.

all the coder needs to do is:

paste the LivinGrimoirePacket into his project.

paste skill files(.py) of skills he wants for his AGI.

finally add the skills you want to the AGI via 1 line of code in:

either the main file or DLC files(.py files with DLC in their name)


πŸ“ see this link

structure supreme example main

import threading
import time
import os
from queue import Queue
import sys  # at the top
import importlib
from LivinGrimoirePacket.livingrimoire import Brain

TICK_INTERVAL = 2  # seconds

def brain_loop():
    while True:
        message = brain_queue.get()
        b1.think_default(message)

def input_loop():
    while True:
        user_input = input("> ")
        if user_input.strip().lower() == "exit":
            print("Exiting...")
            sys.exit(0)
        brain_queue.put(user_input)

def tick_loop():
    next_tick = time.monotonic()
    while True:
        now = time.monotonic()
        if now >= next_tick:
            brain_queue.put("")  # background tick
            next_tick += TICK_INTERVAL
        time.sleep(0.01)  # just enough to keep CPU chill

def call_add_DLC_skills(brain):
    for file in os.listdir('.'):
        if file.endswith('.py') and 'DLC' in file:
            module_name = file[:-3]
            module = importlib.import_module(module_name)  # [SECURE LOAD]
            module.add_DLC_skills(brain)  # [SAFE EXECUTION]

if __name__ == "__main__":
    b1 = Brain()
    brain_queue = Queue()
    call_add_DLC_skills(b1)
    threading.Thread(target=brain_loop, daemon=True).start()
    threading.Thread(target=tick_loop, daemon=True).start()
    input_loop()  # blocks main thread
Enter fullscreen mode Exit fullscreen mode

🧩 example DLC file

from LivinGrimoirePacket.livingrimoire import Brain, DiHelloWorld
from skills_utility import DiSayer, DiTime

def add_DLC_skills(brain: Brain):
    brain.add_skill(DiHelloWorld())
    brain.add_skill(DiSayer())
    brain.add_skill(DiTime())
Enter fullscreen mode Exit fullscreen mode

this is a unique design and optimized for lazy coders.

hence its name: the structure supreme

another advantage of this design is the ability to recategorize skills

by adding them via different DLC files,

or cutting skills into different skill .py files

for better organization, and experimentation.

furthermore, the DLC dynamic dispatch allows for reloading skills while the code runs,

something that was reserved for only niche PLs like LISP.

Top comments (0)