|
| 1 | +import { google } from "@ai-sdk/google"; |
| 2 | +import { generateText } from "ai"; |
1 | 3 | import dayjs from "dayjs"; |
2 | 4 | import { Message, ThreadChannel } from "discord.js"; |
3 | | -import { GOOGLE_GEN_AI } from "../../gemini"; |
4 | 5 | import { prisma } from "../../prisma"; |
5 | 6 | import { ConfigValidator } from "../config-validator"; |
6 | 7 | import { deleteUserMessages } from "../messages/delete-user-messages"; |
@@ -106,21 +107,19 @@ Respond with only "yes" if spam, "no" if legitimate.`; |
106 | 107 |
|
107 | 108 | Message: "${message.content}"`; |
108 | 109 |
|
109 | | - const response = await GOOGLE_GEN_AI?.models.generateContent({ |
110 | | - model: "gemini-2.5-flash-lite-preview-06-17", |
111 | | - contents: [context], |
112 | | - config: { |
113 | | - systemInstruction: this.SYSTEM_PROMPT, |
114 | | - temperature: 0.1, |
115 | | - maxOutputTokens: 10, |
116 | | - }, |
| 110 | + const { text } = await generateText({ |
| 111 | + model: google("gemini-2.5-flash"), |
| 112 | + system: this.SYSTEM_PROMPT, |
| 113 | + prompt: context, |
| 114 | + temperature: 0.1, |
| 115 | + maxOutputTokens: 10, |
117 | 116 | }); |
118 | 117 |
|
119 | 118 | console.log( |
120 | | - `[${dayjs().format("YYYY-MM-DD HH:mm:ss")}] Spam detection - User: ${message.author.username} (${message.author.globalName || ""}) - Response: ${response?.text?.trim()}` |
| 119 | + `[${dayjs().format("YYYY-MM-DD HH:mm:ss")}] Spam detection - User: ${message.author.username} (${message.author.globalName || ""}) - Response: ${text.trim()}` |
121 | 120 | ); |
122 | 121 |
|
123 | | - return response?.text?.trim().toLowerCase() === "yes"; |
| 122 | + return text.trim().toLowerCase() === "yes"; |
124 | 123 | } catch (error) { |
125 | 124 | console.error("Spam detection error:", error); |
126 | 125 | return false; |
|
0 commit comments