Pro model role check
This commit is contained in:
parent
a711aec42b
commit
40cc798afa
1 changed files with 21 additions and 7 deletions
|
|
@ -51,8 +51,14 @@ const onAI = async (
|
|||
|
||||
let personality = config.app.ai.personalities[state.personality.index];
|
||||
|
||||
const useSmartModel =
|
||||
text.startsWith("!aipro") && checkRoles(["MODERATOR", "ADMIN"], sender);
|
||||
const useSmartModel = text.startsWith("!aipro");
|
||||
const hasProRoles = checkRoles(["MODERATOR", "ADMIN"], sender);
|
||||
if (useSmartModel && !hasProRoles) {
|
||||
client.sendTextMessage(
|
||||
roomId,
|
||||
"You are not allowed to use smart model",
|
||||
);
|
||||
}
|
||||
|
||||
let textMod = text.replace("!aipro", "").replace("!ai", "").trim();
|
||||
let instructions = {
|
||||
|
|
@ -80,7 +86,7 @@ const onAI = async (
|
|||
roomId: roomId,
|
||||
sender: sender,
|
||||
},
|
||||
useSmartModel,
|
||||
useSmartModel && hasProRoles,
|
||||
instructions,
|
||||
`${username}: ${textMod}`,
|
||||
`${repliedUsername}: ${repliedMessage}`,
|
||||
|
|
@ -109,9 +115,14 @@ const onAI = async (
|
|||
const onImageGen = async (text: string, roomId: string, sender: string) => {
|
||||
const user = getUserById(sender);
|
||||
|
||||
const useSmartModel =
|
||||
text.startsWith("!imgpro") &&
|
||||
checkRoles(["MODERATOR", "ADMIN"], sender);
|
||||
const useSmartModel = text.startsWith("!imgpro");
|
||||
const hasProRoles = checkRoles(["MODERATOR", "ADMIN"], sender);
|
||||
if (useSmartModel && !hasProRoles) {
|
||||
client.sendTextMessage(
|
||||
roomId,
|
||||
"You are not allowed to use smart model",
|
||||
);
|
||||
}
|
||||
|
||||
let textMod = text
|
||||
.replace("!imgpro", "")
|
||||
|
|
@ -124,7 +135,10 @@ const onImageGen = async (text: string, roomId: string, sender: string) => {
|
|||
});
|
||||
});
|
||||
|
||||
const responseAI = await getImageGemini(textMod, useSmartModel);
|
||||
const responseAI = await getImageGemini(
|
||||
textMod,
|
||||
useSmartModel && hasProRoles,
|
||||
);
|
||||
|
||||
user.aiCost += responseAI.tokens * prices.image;
|
||||
if (!responseAI.image || responseAI.image.length < 10) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue