Add forgetting and personality change

This commit is contained in:
Aslan 2025-12-29 18:52:20 +01:00
parent 6ab8dbd19e
commit 76e496bd38
3 changed files with 103 additions and 4 deletions

View file

@ -3,6 +3,7 @@ import { config, packageConfig } from "../../config.js";
import type { AIToolFunction } from "./types.js";
import { save, state } from "../../store/store.js";
import { EventType, RelationType } from "matrix-js-sdk";
import { changePersonality } from "../../helpers.js";
const tools: FunctionDeclaration[] = [
{
@ -44,7 +45,7 @@ const tools: FunctionDeclaration[] = [
},
{
name: "remember",
description: "Gets information about this AI bot",
description: "Remembers information",
parametersJsonSchema: {
type: "object",
properties: {
@ -57,6 +58,21 @@ const tools: FunctionDeclaration[] = [
required: ["knowledge"],
},
},
{
name: "forget",
description: "Forgets information",
parametersJsonSchema: {
type: "object",
properties: {
knowledge: {
type: "string",
description:
"knowledge to forget (has to be exactly word for word, every character)",
},
},
required: ["knowledge"],
},
},
{
name: "changeUsername",
description: "Changes the username of this AI bot",
@ -71,6 +87,20 @@ const tools: FunctionDeclaration[] = [
required: ["username"],
},
},
{
name: "changePersonality",
description: "Changes the personality of this AI bot",
parametersJsonSchema: {
type: "object",
properties: {
personalityName: {
type: "string",
description: "name of the personality to switch to",
},
},
required: ["personalityName"],
},
},
{
name: "getFullUserData",
description: "Gets the full user data about all users",
@ -140,10 +170,40 @@ const toolFunctions: AIToolFunction[] = [
if (!state.aiMemory) {
state.aiMemory = [];
}
if (args.knowledge) {
state.aiMemory.push(args.knowledge);
if (!args.knowledge) {
return {
message: "failed",
};
}
state.aiMemory.push(args.knowledge);
return {
message: "success",
};
},
},
{
name: "forget",
function: (_matrix, args) => {
if (!state.aiMemory) {
state.aiMemory = [];
}
if (!args.knowledge) {
return {
message: "failed",
};
}
const index = state.aiMemory.indexOf(args.knowledge);
if (index === -1) {
return {
message: "cannot find that memory",
};
}
state.aiMemory.splice(index, 1);
return {
message: "success",
};
@ -163,6 +223,21 @@ const toolFunctions: AIToolFunction[] = [
};
},
},
{
name: "changePersonality",
function: (matrix, args) => {
const result = changePersonality(
matrix.client,
args.personalityName,
);
return {
message: result
? "success"
: "personality with that name does not exist",
};
},
},
{
name: "getFullUserData",
function: (_matrix, _args) => {