mirror of
https://github.com/sortedcord/omnia.git
synced 2026-07-22 03:52:48 +05:30
refactor(gui): Use structured logging over string parsing
This commit is contained in:
@@ -29,24 +29,37 @@ export function PromptModal({ entry, onClose }: PromptModalProps) {
|
||||
systemPrompt: string,
|
||||
userContext: string,
|
||||
inputTokens: number,
|
||||
sectionsObj?: {
|
||||
worldInfo: string;
|
||||
memoryLedger: string;
|
||||
cognitiveBuffer: string;
|
||||
},
|
||||
) => {
|
||||
const recentHeader = "=== COGNITIVE BUFFER ===";
|
||||
const ledgerHeader = "=== MEMORY LEDGER ===";
|
||||
|
||||
const recentIdx = userContext.indexOf(recentHeader);
|
||||
let worldStr = userContext;
|
||||
let worldStr = "";
|
||||
let recentStr = "";
|
||||
let ledgerStr = "";
|
||||
|
||||
if (recentIdx !== -1) {
|
||||
worldStr = userContext.substring(0, recentIdx).trim();
|
||||
const rest = userContext.substring(recentIdx).trim();
|
||||
const ledgerIdx = rest.indexOf(ledgerHeader);
|
||||
if (ledgerIdx !== -1) {
|
||||
recentStr = rest.substring(0, ledgerIdx).trim();
|
||||
ledgerStr = rest.substring(ledgerIdx).trim();
|
||||
} else {
|
||||
recentStr = rest;
|
||||
if (sectionsObj) {
|
||||
worldStr = sectionsObj.worldInfo;
|
||||
recentStr = sectionsObj.cognitiveBuffer;
|
||||
ledgerStr = sectionsObj.memoryLedger;
|
||||
} else {
|
||||
const recentHeader = "=== COGNITIVE BUFFER ===";
|
||||
const ledgerHeader = "=== MEMORY LEDGER ===";
|
||||
|
||||
const recentIdx = userContext.indexOf(recentHeader);
|
||||
worldStr = userContext;
|
||||
|
||||
if (recentIdx !== -1) {
|
||||
worldStr = userContext.substring(0, recentIdx).trim();
|
||||
const rest = userContext.substring(recentIdx).trim();
|
||||
const ledgerIdx = rest.indexOf(ledgerHeader);
|
||||
if (ledgerIdx !== -1) {
|
||||
recentStr = rest.substring(0, ledgerIdx).trim();
|
||||
ledgerStr = rest.substring(ledgerIdx).trim();
|
||||
} else {
|
||||
recentStr = rest;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,6 +157,7 @@ export function PromptModal({ entry, onClose }: PromptModalProps) {
|
||||
entry.rawPrompt.systemPrompt,
|
||||
entry.rawPrompt.userContext,
|
||||
entry.usage.inputTokens,
|
||||
entry.rawPrompt.sections,
|
||||
)
|
||||
: null;
|
||||
const decoderBreakdown =
|
||||
|
||||
@@ -20,6 +20,11 @@ export interface LogEntry {
|
||||
rawPrompt?: {
|
||||
systemPrompt: string;
|
||||
userContext: string;
|
||||
sections?: {
|
||||
worldInfo: string;
|
||||
memoryLedger: string;
|
||||
cognitiveBuffer: string;
|
||||
};
|
||||
};
|
||||
usage?: {
|
||||
inputTokens: number;
|
||||
|
||||
@@ -165,6 +165,11 @@ export async function processNpcTurn(
|
||||
narrativeProse: result.narrativeProse,
|
||||
intents: [],
|
||||
timestamp: worldState.clock.get().toISOString(),
|
||||
rawPrompt: {
|
||||
systemPrompt: result.systemPrompt || "",
|
||||
userContext: result.userContext || "",
|
||||
sections: result.promptComponents,
|
||||
},
|
||||
};
|
||||
|
||||
if (
|
||||
@@ -175,10 +180,6 @@ export async function processNpcTurn(
|
||||
session.actorProvider.lastCalls[
|
||||
session.actorProvider.lastCalls.length - 1
|
||||
];
|
||||
entry.rawPrompt = {
|
||||
systemPrompt: actorCall.systemPrompt,
|
||||
userContext: actorCall.userContext,
|
||||
};
|
||||
entry.usage = actorCall.usage;
|
||||
}
|
||||
|
||||
@@ -243,8 +244,9 @@ export async function executePlayerAction(
|
||||
intents: [],
|
||||
timestamp: worldState.clock.get().toISOString(),
|
||||
rawPrompt: {
|
||||
systemPrompt: ctx.systemPrompt,
|
||||
userContext: ctx.userContext,
|
||||
systemPrompt: result.systemPrompt || ctx.systemPrompt,
|
||||
userContext: result.userContext || ctx.userContext,
|
||||
sections: result.promptComponents,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user