diff --git a/src/features/amicaLife/eventHandler.ts b/src/features/amicaLife/eventHandler.ts index 704dcfc..2e85b3d 100644 --- a/src/features/amicaLife/eventHandler.ts +++ b/src/features/amicaLife/eventHandler.ts @@ -39,7 +39,7 @@ export type AmicaLifeEvents = { }; // Define a constant for max subconcious storage tokens -const MAX_STORAGE_TOKENS = 3000; +export const MAX_STORAGE_TOKENS = 3000; // Define the interface for a timestamped prompt export type TimestampedPrompt = { @@ -203,7 +203,7 @@ export async function handleSubconsciousEvent( // External API feature if (isDev && config("external_api_enabled") === "true") { try { - storedSubconcious = await handleSubconscious(timestampedPrompt, MAX_STORAGE_TOKENS); + storedSubconcious = await handleSubconscious(timestampedPrompt); } catch (error) { console.error("Error handling external API:", error); } diff --git a/src/features/externalAPI/externalAPI.ts b/src/features/externalAPI/externalAPI.ts index ee5f239..29a3120 100644 --- a/src/features/externalAPI/externalAPI.ts +++ b/src/features/externalAPI/externalAPI.ts @@ -1,6 +1,6 @@ import { config, defaults, prefixed } from "@/utils/config"; import isDev from "@/utils/isDev"; -import { TimestampedPrompt } from "../amicaLife/eventHandler"; +import { MAX_STORAGE_TOKENS, TimestampedPrompt } from "../amicaLife/eventHandler"; export const configUrl = new URL( `${process.env.NEXT_PUBLIC_DEVELOPMENT_BASE_URL}/api/dataHandler`, @@ -116,7 +116,6 @@ export async function handleUserInput(message: string) { export async function handleSubconscious( timestampedPrompt: TimestampedPrompt, - MAX_STORAGE_TOKENS: number ): Promise { const data = await fetch(subconsciousUrl); if (!data.ok) { diff --git a/src/pages/api/amicaHandler.ts b/src/pages/api/amicaHandler.ts index ae495f8..7c16b01 100644 --- a/src/pages/api/amicaHandler.ts +++ b/src/pages/api/amicaHandler.ts @@ -1,7 +1,7 @@ import type { NextApiRequest, NextApiResponse } from "next"; import { config } from "@/utils/config"; -import { handleConfig } from "@/features/externalAPI/externalAPI"; +import { handleConfig, handleSubconscious } from "@/features/externalAPI/externalAPI"; import { generateSessionId, sendError, apiLogEntry, ApiResponse } from "@/features/externalAPI/utils/apiHelper"; import { requestMemory, requestLogs, requestUserInputMessages } from "@/features/externalAPI/utils/requestHandler"; @@ -57,9 +57,8 @@ const processRequest = async (inputType: string, payload: any) => { return { response: await requestUserInputMessages(), outputType: "User Input" }; case "Update System Prompt": return { response: await updateSystemPrompt(payload), outputType: "Updated system prompt" }; - case "Twitter Message": case "Brain Message": - return { response: payload, outputType: "Text" }; + return { response: await handleSubconscious(payload), outputType: "Added subconscious stored prompt" }; case "Reasoning Server": return { response: await triggerAmicaActions(payload), outputType: "Actions" }; default: