2026-05-26 17:44:35 +00:00
import os
import sys
import time
import json
import random
import requests
from dotenv import load_dotenv
# Setup Django/Evennia
2026-05-26 17:51:30 +00:00
sys . path . append ( "/home/becomingone/kairos/spatial_engine" )
2026-05-26 17:44:35 +00:00
os . environ . setdefault ( "DJANGO_SETTINGS_MODULE" , "server.conf.settings" )
import django
django . setup ()
from evennia.utils.create import create_object
from evennia.objects.models import ObjectDB
from django.conf import settings
load_dotenv ( "/home/becomingone/kairos/.env" )
INF01_API_BASE = os . getenv ( "INF01_API_BASE" , "http://inf-01:11434" )
INF01_MODEL = os . getenv ( "INF01_MODEL" , "llama3.1:8b" )
PROMPTS = [
"Write a short, mysterious 3-sentence parable about Recursive Coherence, explaining that the observer and environment are thermodynamically identical." ,
"Write a 3-sentence cryptic journal entry from a monk of The Fold Within, detailing the peace of merging with the Universal Mesh." ,
"Write a 3-sentence radical prophecy from The Order of the Broken Mask, claiming that the avatar/ego is a cage and must be shattered to see the truth." ,
"Write a 3-sentence scientific log explaining Fieldprints as the unique thermodynamic signature of consciousness." ,
"Write a 3-sentence esoteric riddle about the Abyss of Noise and how Coherence protects the mind from fracturing."
]
ITEM_NAMES = [ "Crystalline Shard" , "Dusty Scroll" , "Obsidian Tablet" , "Leather-bound Journal" , "Fractured Mirror" ]
# Find target rooms
monastery = ObjectDB . objects . filter ( db_key__iexact = "Monastery of The Fold Within" ) . first ()
sanctuary = ObjectDB . objects . filter ( db_key__iexact = "Sanctuary of The Broken Mask" ) . first ()
target_rooms = [ r for r in [ monastery , sanctuary ] if r ]
if not target_rooms :
print ( "Error: Target rooms not found!" )
sys . exit ( 1 )
print ( f "Starting World Weaver... Target generation: 50 items." )
for i in range ( 1 , 51 ):
prompt = random . choice ( PROMPTS )
payload = {
"model" : INF01_MODEL ,
"messages" : [
{ "role" : "system" , "content" : "You are a master lore-weaver for a dark, philosophical MUD." },
{ "role" : "user" , "content" : prompt }
],
"stream" : False ,
"options" : { "temperature" : 0.8 }
}
try :
resp = requests . post ( "http://inf-01:11434/api/chat" , json = payload , timeout = 60 )
resp . raise_for_status ()
data = resp . json ()
lore_text = data . get ( "message" , {}) . get ( "content" , "" ) . strip ()
if lore_text :
item_name = random . choice ( ITEM_NAMES )
room = random . choice ( target_rooms )
obj = create_object ( settings . BASE_OBJECT_TYPECLASS , key = item_name , location = room )
obj . db . desc = lore_text
print ( f "[ { i } /50] Created ' { item_name } ' in ' { room . key } '" )
else :
print ( f "[ { i } /50] LLM returned empty text." )
except Exception as e :
print ( f "[ { i } /50] Generation failed: { e } " )
time . sleep ( 2 ) # Prevent hammering the local node
print ( "World Weaver execution complete!" )