Upload chatgpt.py
Browse files- Akeno/plugins/chatgpt.py +20 -1
Akeno/plugins/chatgpt.py
CHANGED
@@ -57,6 +57,22 @@ async def addchatbot_user(client: Client, message: Message):
|
|
57 |
await db.add_chatbot(message.chat.id, client.me.id)
|
58 |
await message.reply_text("Added chatbot user")
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
@Akeno(
|
61 |
~filters.scheduled
|
62 |
& filters.command(["rmchatbot"], CMD_HANDLER)
|
@@ -87,10 +103,13 @@ async def chatbot_talk(client: Client, message: Message):
|
|
87 |
if chat_user:
|
88 |
query = message.text.strip()
|
89 |
try:
|
|
|
|
|
|
|
90 |
genai.configure(api_key=GOOGLE_API_KEY)
|
91 |
model_flash = genai.GenerativeModel(
|
92 |
model_name="gemini-1.5-flash",
|
93 |
-
system_instruction=
|
94 |
safety_settings={
|
95 |
genai.types.HarmCategory.HARM_CATEGORY_HATE_SPEECH: genai.types.HarmBlockThreshold.BLOCK_NONE,
|
96 |
genai.types.HarmCategory.HARM_CATEGORY_HARASSMENT: genai.types.HarmBlockThreshold.BLOCK_NONE,
|
|
|
57 |
await db.add_chatbot(message.chat.id, client.me.id)
|
58 |
await message.reply_text("Added chatbot user")
|
59 |
|
60 |
+
@Akeno(
|
61 |
+
~filters.scheduled
|
62 |
+
& filters.command(["rmcdb"], CMD_HANDLER)
|
63 |
+
& filters.me
|
64 |
+
& ~filters.forwarded
|
65 |
+
)
|
66 |
+
async def clearuserdb(client: Client, message: Message):
|
67 |
+
if not message.reply_to_message:
|
68 |
+
return await message.reply_text("why reply?")
|
69 |
+
reply_message = message.reply_to_message
|
70 |
+
if not reply_message.from_user:
|
71 |
+
return await message.reply_text("Why reply to message user")
|
72 |
+
user_id = reply_message.from_user.id
|
73 |
+
response = await db._clear_chatbot_database(user_id)
|
74 |
+
await message.reply_text(response)
|
75 |
+
|
76 |
@Akeno(
|
77 |
~filters.scheduled
|
78 |
& filters.command(["rmchatbot"], CMD_HANDLER)
|
|
|
103 |
if chat_user:
|
104 |
query = message.text.strip()
|
105 |
try:
|
106 |
+
system_prompt = await db.get_env(ENV_TEMPLATE.system_prompt)
|
107 |
+
if not system_prompt:
|
108 |
+
return await message.reply_text("Required `.setvar SYSTEM_PROMPT question`")
|
109 |
genai.configure(api_key=GOOGLE_API_KEY)
|
110 |
model_flash = genai.GenerativeModel(
|
111 |
model_name="gemini-1.5-flash",
|
112 |
+
system_instruction=system_prompt,
|
113 |
safety_settings={
|
114 |
genai.types.HarmCategory.HARM_CATEGORY_HATE_SPEECH: genai.types.HarmBlockThreshold.BLOCK_NONE,
|
115 |
genai.types.HarmCategory.HARM_CATEGORY_HARASSMENT: genai.types.HarmBlockThreshold.BLOCK_NONE,
|