- HOW TO GET OpenAI API KEY?
Code:https://platform.openai.com/account/api-keys
- Requirements:
Python 3.11.2
Windows OS - Install Pakages
Code:pip install -U py-cord pip install -U openai
- Python CODE:
Python:
import #forbidden# import openai from #forbidden#.ext import commands openai.api_key = YOUR_API client = #forbidden#.Client() bot = commands.Bot(command_prefix='!', intents=#forbidden#.Intents.all()) @bot.command() async def ask(ctx, *, message : str): response = openai.Completion.create( model="text-davinci-003", prompt=message, temperature=0.7, max_tokens=256, top_p=1, frequency_penalty=0, presence_penalty=0 ) embed=#forbidden#.Embed(title="🔰 MY BOT", url="YOUR_SITE_URL", description="Powered by OpenAI") embed.set_thumbnail(url="YOUR_IMAGE_URL") embed.add_field(name="✔ Question", value=message, inline=False) embed.add_field(name="✔ Resoponse", value=response['choices'][0]['text'], inline=True) await ctx.send(embed=embed) @bot.event async def on_command_error(ctx, error): if isinstance(error, commands.CommandNotFound): await ctx.send("Unknown command.") bot.run(TOKEN)
- COMMAND: !ask
Ex: !ask what is AI?
Attachments
-
You do not have permission to view the full content of this post. Log in or register now.