mirror of
https://github.com/sortedcord/omnia.git
synced 2026-07-22 03:52:48 +05:30
refactor: Remove serializer and polymorphed forms from AttributableObject AC in favor of generic helper function
1. Decoupled Attributes Serialization:
• Removed all serialize() methods from AttributableObject
(attribute.ts), WorldState (world.ts), and Entity (entity.ts).
• Implemented a standalone, uncoupled function
serializeAttributes(attributes: Attribute[]): string in attribute.ts.
This function receives an array of attributes and outputs their
formatted
representation.
2. System Objective Serializer:
• Implemented serializeObjectiveWorldState(worldState:
WorldState): string in world.ts for system LLMs that need objective
reality dumps (e.g. validators and intent decoders). It manually
retrieves and formats attributes using serializeAttributes()
alongside class-specific fields like locationId .
3. System prompt updates:
• Updated LLMValidator (llm-validator.ts), TimeDeltaGenerator
(delta.ts), and IntentDecoder (intent-decoder.ts) to use the new
standalone serializeObjectiveWorldState(worldState) helper imported
from @omnia/core .
4. Unit Tests (Tier 1):
• Updated core.test.ts to verify serializeAttributes and
serializeObjectiveWorldState utilities directly.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { z } from "zod";
|
||||
import { WorldState } from "@omnia/core";
|
||||
import { WorldState, serializeObjectiveWorldState } from "@omnia/core";
|
||||
import { ILLMProvider } from "@omnia/llm";
|
||||
|
||||
export const TimeDeltaSchema = z.object({
|
||||
@@ -41,7 +41,7 @@ Return a structured JSON object containing:
|
||||
=== CURRENT WORLD STATE ===
|
||||
Current Time: ${worldState.clock.get().toISOString()}
|
||||
World Details:
|
||||
${worldState.serialize()}
|
||||
${serializeObjectiveWorldState(worldState)}
|
||||
|
||||
=== ACTION ===
|
||||
Actor ID: ${actorId}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from "./llm-validator.js";
|
||||
export * from "./architect.js";
|
||||
export * from "./delta.js";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { z } from "zod";
|
||||
import { WorldState } from "@omnia/core";
|
||||
import { WorldState, serializeObjectiveWorldState } from "@omnia/core";
|
||||
import { ILLMProvider } from "@omnia/llm";
|
||||
|
||||
export const ValidationResultSchema = z.object({
|
||||
@@ -29,7 +29,7 @@ export class LLMValidator {
|
||||
}
|
||||
|
||||
// 1. Serialize the objective world state for the LLM
|
||||
const serializedWorld = worldState.serialize();
|
||||
const serializedWorld = serializeObjectiveWorldState(worldState);
|
||||
|
||||
// 2. Build the prompts
|
||||
const systemPrompt = `
|
||||
|
||||
Reference in New Issue
Block a user