import openai
from aiogram.contrib.fsm_storage.memory import MemoryStorage
from aiogram import Bot, types
from aiogram.dispatcher import Dispatcher
from aiogram.utils import executor
from aiogram.types import ReplyKeyboardMarkup, KeyboardButton, InlineKeyboardButton, InlineKeyboardMarkup
from aiogram.types import callback_query
from aiogram.dispatcher.filters.state import StatesGroup, State
from aiogram.dispatcher import FSMContext
class btns(StatesGroup):
mess = State()
bot = Bot(telegram_token)
dp = Dispatcher(bot)
def update(messages, role, content):
messages.append({"role": role, "content": content})
return messages
@dp.message_handler(commands=['start'])
async def start(message: types.Message):
kb = types.ReplyKeyboardMarkup(resize_keyboard=True)
btn1 = types.KeyboardButton("Текст")
btn2 = types.KeyboardButton("Картинка")
kb.add(btn1, btn2)
await message.answer("Hi, i am ChatGPT 3.5 turbo", reply_markup=kb)
@dp.message_handler(state=btns.mess)
async def text_zap(message:types.Message, state: FSMContext):
if message.text == "Текст":
await btns.mess.set()
question = message.text.strip()
response = openai.Completion.create(
engine="text-davinci-003",
prompt=question,
max_tokens=1024,
n=1,
stop=None,
temperature=0.5,
)
await message.answer(response['choices'][0].text.strip())
помогите пожалуйста, делал запрос сразу после if тогда искало ответы вообще на рандомную тему,
а сейчас вообще не выводит нечего в тг
спасибо