2023-02-06 21:54:41 +10:00
|
|
|
|
import openai
|
|
|
|
|
from aiogram import types, Dispatcher
|
|
|
|
|
from create_bot import dp, bot
|
2023-07-21 06:10:49 +10:00
|
|
|
|
import logging
|
2023-02-06 21:54:41 +10:00
|
|
|
|
|
2023-07-17 15:18:56 +10:00
|
|
|
|
|
2023-07-18 07:39:15 +10:00
|
|
|
|
|
2023-02-06 21:54:41 +10:00
|
|
|
|
token = '5947963644:AAF_GKgMmU5ovqMpc1KXIpcf4aN0JMyKPqc'
|
2023-07-17 15:19:03 +10:00
|
|
|
|
#openai.api_key = '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'
|
2023-07-17 15:18:56 +10:00
|
|
|
|
openai.api_key = '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'
|
2023-07-18 06:52:36 +10:00
|
|
|
|
ban_comands = ['/dick','/topdick']
|
2023-07-17 15:21:28 +10:00
|
|
|
|
|
2023-07-21 06:10:49 +10:00
|
|
|
|
# Image_promt =['тупица сгенерируй','тупица сгенерируй картинку',\
|
|
|
|
|
# 'тупица отправь картинку', 'тупица отправь картинку']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dp.message_handler(commands=['image'])
|
|
|
|
|
async def send_image(message: types.Message):
|
|
|
|
|
try:
|
|
|
|
|
description = message.text.replace('/image', '').strip()
|
|
|
|
|
|
|
|
|
|
if not description:
|
|
|
|
|
await message.reply('Ты даун, описание запроса напиши после пробела')
|
|
|
|
|
return
|
|
|
|
|
except Exception as e:
|
|
|
|
|
logging.error(f'Error in send_image: {e}')
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
response = openai.Image.create(
|
|
|
|
|
prompt=message.text,
|
|
|
|
|
n=1,
|
|
|
|
|
size="1024x1024",
|
|
|
|
|
response_format="url",
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
|
image_url = response['data'][0]['url']
|
|
|
|
|
await message.answer('Генерирую изображение...')
|
|
|
|
|
await message.reply_photo(image_url)
|
|
|
|
|
except Exception as e:
|
|
|
|
|
await message.reply('у меня не получилось')
|
|
|
|
|
|
2023-02-06 21:54:41 +10:00
|
|
|
|
@dp.message_handler()
|
2023-02-06 22:45:18 +10:00
|
|
|
|
async def send(message: types.Message):
|
2023-07-18 06:52:36 +10:00
|
|
|
|
if message.text.lower().startswith('тупица'):
|
2023-02-06 21:54:41 +10:00
|
|
|
|
|
2023-07-12 21:54:24 +10:00
|
|
|
|
## TODO уточнить остатки токенов и денег
|
2023-07-18 06:39:33 +10:00
|
|
|
|
response = openai.Completion.create(
|
|
|
|
|
model="text-davinci-003",
|
2023-07-18 07:39:15 +10:00
|
|
|
|
prompt=message.text[7:],
|
2023-07-18 06:39:33 +10:00
|
|
|
|
temperature=0.7,
|
|
|
|
|
max_tokens=1000,
|
|
|
|
|
top_p=1.0,
|
|
|
|
|
frequency_penalty=0.0,
|
|
|
|
|
presence_penalty=0.6,
|
|
|
|
|
stop=["сброс"]
|
|
|
|
|
)
|
|
|
|
|
await message.reply(response['choices'][0]['text'])
|
2023-07-18 06:52:36 +10:00
|
|
|
|
|
2023-07-19 01:42:04 +10:00
|
|
|
|
elif message.reply_to_message.from_user.is_bot:
|
|
|
|
|
response = openai.Completion.create(
|
|
|
|
|
model="text-davinci-003",
|
|
|
|
|
prompt=message.text,
|
|
|
|
|
temperature=0.7,
|
|
|
|
|
max_tokens=1000,
|
|
|
|
|
top_p=1.0,
|
|
|
|
|
frequency_penalty=0.0,
|
|
|
|
|
presence_penalty=0.6,
|
|
|
|
|
stop=["сброс"]
|
|
|
|
|
)
|
|
|
|
|
await message.reply(response['choices'][0]['text'])
|
2023-07-21 06:10:49 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-07-18 06:39:33 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-02-06 21:54:41 +10:00
|
|
|
|
|
|
|
|
|
|