diff --git a/Pipfile b/Pipfile index 9365f42..fa85b71 100644 --- a/Pipfile +++ b/Pipfile @@ -28,6 +28,7 @@ openai = "~=0.27.2" psycopg = {extras = ["binary"], version = "~=3.1"} pytimeparse = "*" markovify = "*" +deep-translator = "*" [dev-packages] black = "~=22.12" diff --git a/Pipfile.lock b/Pipfile.lock index f959580..7d021a1 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "49c245fc11d7950f9bc11fdd8f5baa70c0f96c330a80348dd80ae7abd92fa339" + "sha256": "eac3d39a1fb37dece12c6539288fef4fb4e17c26013c51adfd066834497c1941" }, "pipfile-spec": 6, "requires": { @@ -304,6 +304,14 @@ "index": "pypi", "version": "==1.1.8" }, + "deep-translator": { + "hashes": [ + "sha256:801260c69231138707ea88a0955e484db7d40e210c9e0ae0f77372ffda5f4bf5", + "sha256:d635df037e23fa35d12fd42dab72a0b55c9dd19e6292009ee7207e3f30b9e60a" + ], + "index": "pypi", + "version": "==1.11.4" + }, "discord.py": { "hashes": [ "sha256:792bdcfe71cfe013c446cf379b2e83e08b5050604322ad6fb592864e63511abd", diff --git a/cogs/commands/misc.py b/cogs/commands/misc.py index d32069b..84b7544 100644 --- a/cogs/commands/misc.py +++ b/cogs/commands/misc.py @@ -1,6 +1,7 @@ import random import markovify +from deep_translator import GoogleTranslator from discord.ext import commands from discord.ext.commands import Bot, Context @@ -129,8 +130,18 @@ async def babbage(self, ctx: Context): ) @commands.hybrid_command() - async def chat(self, ctx: Context, message: str = None): - await ctx.send(self.model.make_sentence()) + async def chat(self, ctx: Context, message: str = None, gpt4: bool = False): + message = self.model.make_sentence() + translated = ( + GoogleTranslator(source="en", target="en").translate(message) + if gpt4 + else message + ) + await ctx.send(translated) + + @commands.hybrid_command() + async def gpt4(self, ctx: Context, message: str): + await self.chat(ctx, message, True) async def setup(bot: Bot):