Working Code Telegram Bot
CODE for [Link]:
import os
from boltiotai import openai
import asyncio
from aiogram import Bot, Dispatcher, types
from [Link] import CommandStart
from example import example
bot = Bot(token='Replace this with your actual bot token id')
dp = Dispatcher()
openai.api_key = [Link]['OPENAI_API_KEY']
example()
@[Link](CommandStart(['start', 'help']))
async def welcome(message: [Link]):
await [Link]('Hello! I am GPT Chat BOT. You can ask me anything :)')
@[Link]()
async def gpt(message: [Link]):
messages = [{"role": "system", "content": "You are a helpful assistant."}, {"role":"user",
"content":[Link]}]
response = [Link](model="gpt-3.5-turbo", messages=messages)
await [Link](response['choices'][0]['message']['content'])
async def main():
await dp.start_polling(bot)
if __name__ == "__main__":
[Link](main())
CODE for [Link]:
from flask import Flask, render_template
from threading import Thread
app = Flask(__name__)
@[Link]('/')
def index():
return "example"
def run():
[Link](host='[Link]',port=8080)
def example():
t = Thread(target=run)
[Link]()