Skip to content

Commit

Permalink
Added brain inputs.
Browse files Browse the repository at this point in the history
External API
  • Loading branch information
slowsynapse authored Jan 20, 2025
2 parents 6b53bf5 + 347c55b commit 745dd7d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/features/amicaLife/eventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 1 addition & 2 deletions src/features/externalAPI/externalAPI.ts
Original file line number Diff line number Diff line change
@@ -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`,
Expand Down Expand Up @@ -116,7 +116,6 @@ export async function handleUserInput(message: string) {

export async function handleSubconscious(
timestampedPrompt: TimestampedPrompt,
MAX_STORAGE_TOKENS: number
): Promise<TimestampedPrompt[]> {
const data = await fetch(subconsciousUrl);
if (!data.ok) {
Expand Down
5 changes: 2 additions & 3 deletions src/pages/api/amicaHandler.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 745dd7d

Please sign in to comment.