Add function calling
This commit is contained in:
parent
f3a74bc46c
commit
a5d6163ef9
13 changed files with 272 additions and 32 deletions
|
|
@ -59,19 +59,17 @@ const onAI = async (
|
|||
|
||||
personality = config.app.ai.personalities[state.personality.index];
|
||||
|
||||
let textMod = text.replace("!ai", "").trim().toLowerCase();
|
||||
let textMod = text.replace("!ai", "").trim();
|
||||
let instructions = {
|
||||
prefferedLanguages: ["english", "slovak"],
|
||||
users: alts.map((alt) => ({
|
||||
names: alt.keys,
|
||||
alt: alt.alt,
|
||||
backstory: alt.id
|
||||
? getUserById(`${alt.id}:${config.server}`).information
|
||||
: undefined,
|
||||
})),
|
||||
aiPersonality: personality?.personality ?? "",
|
||||
aiLikes: personality?.likes ?? "",
|
||||
aiDislikes: personality?.dislikes ?? "",
|
||||
aiMemory: state.aiMemory ?? [],
|
||||
} as IAIInstructions;
|
||||
|
||||
const username = getUserName(user);
|
||||
|
|
@ -81,6 +79,11 @@ const onAI = async (
|
|||
}
|
||||
|
||||
const responseAI = await getTextGemini(
|
||||
{
|
||||
client: client,
|
||||
roomId: roomId,
|
||||
sender: sender,
|
||||
},
|
||||
instructions,
|
||||
`${username}: ${textMod}`,
|
||||
`${repliedUsername}: ${repliedMessage}`,
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
export * from "./ai.js";
|
||||
export * from "./types.js";
|
||||
export * from "./alts.js";
|
||||
export * from "./prices.js";
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ interface IAIInstructions {
|
|||
aiPersonality: string;
|
||||
aiLikes: string;
|
||||
aiDislikes: string;
|
||||
aiMemory: string[];
|
||||
}
|
||||
|
||||
export { type IAIAlt, type IAIUser, type IAIInstructions };
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ const onHelp = (_text: string, roomId: string) => {
|
|||
<li><b>!bowling {text}</b> - Repeats your message in bowling</li>
|
||||
<li><b>!help</b> - Prints this help message</li>
|
||||
<li><b>!me / !me {mention}</b> - Prints data about you</li>
|
||||
<li><b>!myinfo {newinfo}</b> - Updates your description</li>
|
||||
<li><b>!leaderboard</b> - Prints total user ranking</li>
|
||||
<li><b>!aileaderboard</b> - Prints total user ai cost</li>
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -21,10 +21,6 @@ const registerModuleUser = (
|
|||
startConditions: [`${config.app.triggerPrefix}me`],
|
||||
callbackFunc: onMe,
|
||||
});
|
||||
callbackStore.messageCallbacks.push({
|
||||
startConditions: [`${config.app.triggerPrefix}myinfo `],
|
||||
callbackFunc: onMyInfo,
|
||||
});
|
||||
callbackStore.messageCallbacks.push({
|
||||
startConditions: [`${config.app.triggerPrefix}leaderboard`],
|
||||
callbackFunc: onLeaderboard,
|
||||
|
|
@ -55,22 +51,6 @@ const onMe = (text: string, roomId: string, sender: string) => {
|
|||
);
|
||||
};
|
||||
|
||||
const onMyInfo = (text: string, roomId: string, sender: string) => {
|
||||
const user = getUserById(sender);
|
||||
const newInformation = text.replace(
|
||||
`${config.app.triggerPrefix}myinfo `,
|
||||
"",
|
||||
);
|
||||
|
||||
if (!user || newInformation.length < 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
user.information = newInformation;
|
||||
|
||||
client.sendTextMessage(roomId, "Information updated");
|
||||
};
|
||||
|
||||
const onLeaderboard = (_text: string, roomId: string) => {
|
||||
const mapUsersToLeaderboard = (user: IUser): string => {
|
||||
const level = getLevel(user.experience);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue