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];
|
let personality = config.app.ai.personalities[state.personality.index];
|
||||||
|
|
||||||
const useSmartModel =
|
const useSmartModel = text.startsWith("!aipro");
|
||||||
text.startsWith("!aipro") && checkRoles(["MODERATOR", "ADMIN"], sender);
|
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 textMod = text.replace("!aipro", "").replace("!ai", "").trim();
|
||||||
let instructions = {
|
let instructions = {
|
||||||
|
|
@ -80,7 +86,7 @@ const onAI = async (
|
||||||
roomId: roomId,
|
roomId: roomId,
|
||||||
sender: sender,
|
sender: sender,
|
||||||
},
|
},
|
||||||
useSmartModel,
|
useSmartModel && hasProRoles,
|
||||||
instructions,
|
instructions,
|
||||||
`${username}: ${textMod}`,
|
`${username}: ${textMod}`,
|
||||||
`${repliedUsername}: ${repliedMessage}`,
|
`${repliedUsername}: ${repliedMessage}`,
|
||||||
|
|
@ -109,9 +115,14 @@ const onAI = async (
|
||||||
const onImageGen = async (text: string, roomId: string, sender: string) => {
|
const onImageGen = async (text: string, roomId: string, sender: string) => {
|
||||||
const user = getUserById(sender);
|
const user = getUserById(sender);
|
||||||
|
|
||||||
const useSmartModel =
|
const useSmartModel = text.startsWith("!imgpro");
|
||||||
text.startsWith("!imgpro") &&
|
const hasProRoles = checkRoles(["MODERATOR", "ADMIN"], sender);
|
||||||
checkRoles(["MODERATOR", "ADMIN"], sender);
|
if (useSmartModel && !hasProRoles) {
|
||||||
|
client.sendTextMessage(
|
||||||
|
roomId,
|
||||||
|
"You are not allowed to use smart model",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let textMod = text
|
let textMod = text
|
||||||
.replace("!imgpro", "")
|
.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;
|
user.aiCost += responseAI.tokens * prices.image;
|
||||||
if (!responseAI.image || responseAI.image.length < 10) {
|
if (!responseAI.image || responseAI.image.length < 10) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue