Add support for replied messages
This commit is contained in:
parent
6264567ec9
commit
791883f580
5 changed files with 46 additions and 8 deletions
|
|
@ -28,7 +28,12 @@ const registerModuleAI = (
|
|||
});
|
||||
};
|
||||
|
||||
const onAI = async (text: string, roomId: string, sender: string) => {
|
||||
const onAI = async (
|
||||
text: string,
|
||||
roomId: string,
|
||||
sender: string,
|
||||
repliedMessage?: string,
|
||||
) => {
|
||||
const user = getUserById(sender);
|
||||
|
||||
if (text.trim().length < 5) {
|
||||
|
|
@ -66,9 +71,13 @@ const onAI = async (text: string, roomId: string, sender: string) => {
|
|||
} as IAIInstructions;
|
||||
|
||||
const username = getUserName(user);
|
||||
textMod = `${username}:\n${textMod}`;
|
||||
textMod = `${username}: ${textMod}`;
|
||||
|
||||
const responseAI = await getTextGemini(instructions, textMod);
|
||||
const responseAI = await getTextGemini(
|
||||
instructions,
|
||||
textMod,
|
||||
repliedMessage,
|
||||
);
|
||||
|
||||
user.aiCost += responseAI.tokens * prices.text;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue