You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
swarms/apps/discord.py

46 lines
1.1 KiB

1 year ago
from discord.ext import commands
from swarms.models import OpenAIChat
1 year ago
from swarms.agents import OmniModalAgent
# Setup
1 year ago
TOKEN = "YOUR_DISCORD_BOT_TOKEN"
bot = commands.Bot(command_prefix="!")
1 year ago
# Initialize the OmniModalAgent
llm = OpenAIChat(model_name="gpt-4")
agent = OmniModalAgent(llm)
1 year ago
1 year ago
@bot.event
async def on_ready():
1 year ago
print(f"We have logged in as {bot.user}")
1 year ago
@bot.command()
async def greet(ctx):
"""Greets the user."""
1 year ago
await ctx.send(f"Hello, {ctx.author.name}!")
1 year ago
@bot.command()
1 year ago
async def run(ctx, *, description: str):
1 year ago
"""Generates a video based on the given description."""
1 year ago
response = agent.run(
description
) # Assuming the response provides information or a link to the generated video
1 year ago
await ctx.send(response)
1 year ago
1 year ago
@bot.command()
async def help_me(ctx):
"""Provides a list of commands and their descriptions."""
help_text = """
- `!greet`: Greets you.
1 year ago
- `!run [description]`: Generates a video based on the given description.
1 year ago
- `!help_me`: Provides this list of commands and their descriptions.
"""
await ctx.send(help_text)
1 year ago
1 year ago
bot.run(TOKEN)