Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import telebot
- import openai
- bot = telebot.TeleBot("ключ")
- openai.api_key = "ключ"
- model_engine = "gpt-3.5-turbo"
- @bot.message_handler(content_types=['text'])
- def lalala(message):
- print(message.chat.title, message.chat.username)
- if message.chat.id == 00000000:
- print(message.text)
- if "вася" in message.text.lower():
- message.text = (message.text).replace("вася ", "")
- #print(message.text)
- response = openai.Completion.create(
- engine=model_engine,
- prompt=message.text,
- max_tokens=1000,
- n=1,
- stop=None,
- temperature=0.7,
- )
- full_response = response.choices[0].text
- lines = full_response.splitlines()
- for line in lines: # Iterate over the lines
- try:
- #print(line)
- bot.send_message(message.chat.id, line)
- except Exception as e:
- print(e)
- else:
- bot.send_message(message.chat.id, "Вибачте, я був створений не для всіх охочих 🥺")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement