Update Akeno/plugins/chatgpt.py
Browse files- Akeno/plugins/chatgpt.py +45 -0
Akeno/plugins/chatgpt.py
CHANGED
@@ -44,6 +44,9 @@ from config import *
|
|
44 |
import google.generativeai as genai
|
45 |
from google.api_core.exceptions import InvalidArgument
|
46 |
|
|
|
|
|
|
|
47 |
|
48 |
async def mistraai(messagestr):
|
49 |
url = "https://private-akeno.randydev.my.id/akeno/mistralai"
|
@@ -86,6 +89,48 @@ async def geni_files_delete(name: str):
|
|
86 |
return None
|
87 |
return response.text
|
88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
@Akeno(
|
90 |
~filters.scheduled
|
91 |
& command(["askweb"])
|
|
|
44 |
import google.generativeai as genai
|
45 |
from google.api_core.exceptions import InvalidArgument
|
46 |
|
47 |
+
import datetime
|
48 |
+
from openai import AsyncOpenAI as openai
|
49 |
+
import akenoai.openai as akeno
|
50 |
|
51 |
async def mistraai(messagestr):
|
52 |
url = "https://private-akeno.randydev.my.id/akeno/mistralai"
|
|
|
89 |
return None
|
90 |
return response.text
|
91 |
|
92 |
+
async def openailatest(message_str):
|
93 |
+
response = await akeno.OpenAI.run(
|
94 |
+
...,
|
95 |
+
openai_meta=openai,
|
96 |
+
model="gpt-4o-mini-2024-07-18",
|
97 |
+
messages=[
|
98 |
+
{"role": "system", "content": f"You are my name Akeno AI and python language powered by @xtdevs on telegram support and language models GPT-5-ULTRA\n\n{datetime.datetime.now()}"},
|
99 |
+
{"role": "user", "content": message_str}
|
100 |
+
]
|
101 |
+
)
|
102 |
+
return response
|
103 |
+
|
104 |
+
@Akeno(
|
105 |
+
~filters.scheduled
|
106 |
+
& command(["askren"])
|
107 |
+
& filters.me
|
108 |
+
& ~filters.forwarded
|
109 |
+
)
|
110 |
+
async def askren(client: Client, message: Message):
|
111 |
+
if len(message.command) > 1:
|
112 |
+
prompt = message.text.split(maxsplit=1)[1]
|
113 |
+
elif message.reply_to_message:
|
114 |
+
prompt = message.reply_to_message.text
|
115 |
+
else:
|
116 |
+
return await message.reply_text("Give ask from GPT-5")
|
117 |
+
try:
|
118 |
+
response = await openailatest(prompt)
|
119 |
+
output = response
|
120 |
+
if len(output) > 4096:
|
121 |
+
with open("chat.txt", "w+", encoding="utf8") as out_file:
|
122 |
+
out_file.write(output)
|
123 |
+
await message.reply_document(
|
124 |
+
document="chat.txt",
|
125 |
+
disable_notification=True
|
126 |
+
)
|
127 |
+
os.remove("chat.txt")
|
128 |
+
else:
|
129 |
+
await message.reply_text(output)
|
130 |
+
except Exception as e:
|
131 |
+
LOGS.error(str(e))
|
132 |
+
return await message.reply_text(str(e))
|
133 |
+
|
134 |
@Akeno(
|
135 |
~filters.scheduled
|
136 |
& command(["askweb"])
|