From 52df4cd457c935f6725603a34d5d0d04f9c601d7 Mon Sep 17 00:00:00 2001 From: Kaveen Kumarasinghe Date: Wed, 1 Feb 2023 10:25:42 -0500 Subject: [PATCH 1/4] hot fix for docker --- Dockerfile | 2 ++ gpt3discord.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 34316ab..94c28f6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,7 @@ ARG PY_VERSION=3.9 FROM python:${PY_VERSION} as base FROM base as builder ARG PY_VERSION +COPY . . RUN mkdir /install /src WORKDIR /install @@ -23,6 +24,7 @@ RUN pip install --target="/install" /src # Copy minimal to main image (to keep as small as possible) FROM python:${PY_VERSION}-slim ARG PY_VERSION +COPY . . COPY --from=builder /install /usr/local/lib/python${PY_VERSION}/site-packages RUN mkdir -p /opt/gpt3discord/etc COPY gpt3discord.py /opt/gpt3discord/bin/ diff --git a/gpt3discord.py b/gpt3discord.py index e57b460..c94b173 100644 --- a/gpt3discord.py +++ b/gpt3discord.py @@ -30,7 +30,7 @@ from services.environment_service import EnvService from models.openai_model import Model -__version__ = "8.7.5" +__version__ = "8.7.6" PID_FILE = Path("bot.pid") From 5d5ec3dbb1ac5c43ffdeddfaee359a584e7940b7 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Wed, 1 Feb 2023 15:26:34 +0000 Subject: [PATCH 2/4] Format Python code with psf/black push --- cogs/moderations_service_cog.py | 1 - cogs/prompt_optimizer_cog.py | 1 - models/openai_model.py | 3 --- services/moderations_service.py | 3 --- services/text_service.py | 4 ---- 5 files changed, 12 deletions(-) diff --git a/cogs/moderations_service_cog.py b/cogs/moderations_service_cog.py index 7a6e9c7..9cae7ff 100644 --- a/cogs/moderations_service_cog.py +++ b/cogs/moderations_service_cog.py @@ -222,7 +222,6 @@ class ModerationsService(discord.Cog, name="ModerationsService"): ) async def build_moderation_settings_embed(self, category, mod_set): - embed = discord.Embed( title="Moderation Settings", description="The moderation settings for this guild for the type: " diff --git a/cogs/prompt_optimizer_cog.py b/cogs/prompt_optimizer_cog.py index e117ac9..d4eb1ff 100644 --- a/cogs/prompt_optimizer_cog.py +++ b/cogs/prompt_optimizer_cog.py @@ -188,7 +188,6 @@ class DrawButton(discord.ui.Button["OptimizeView"]): self.custom_api_key = custom_api_key async def callback(self, interaction: discord.Interaction): - user_id = interaction.user.id interaction_id = interaction.message.id diff --git a/models/openai_model.py b/models/openai_model.py index 03c5d28..fd0d18f 100644 --- a/models/openai_model.py +++ b/models/openai_model.py @@ -639,7 +639,6 @@ class Model: codex=False, custom_api_key=None, ): - # Validate that all the parameters are in a good state before we send the request if len(instruction) < self.prompt_min_length: raise ValueError( @@ -769,7 +768,6 @@ class Model: ) -> ( Tuple[dict, bool] ): # The response, and a boolean indicating whether or not the context limit was reached. - # Validate that all the parameters are in a good state before we send the request if len(prompt) < self.prompt_min_length: raise ValueError( @@ -815,7 +813,6 @@ class Model: @staticmethod async def send_test_request(api_key): - async with aiohttp.ClientSession() as session: payload = { "model": Models.LOW_USAGE_MODEL, diff --git a/services/moderations_service.py b/services/moderations_service.py index 1c50e3c..9df6ba7 100644 --- a/services/moderations_service.py +++ b/services/moderations_service.py @@ -155,7 +155,6 @@ class Moderation: @staticmethod def determine_moderation_result(text, response, warn_set, delete_set): - warn_result, flagged_warn = warn_set.moderate(text, response) delete_result, flagged_delete = delete_set.moderate(text, response) @@ -330,7 +329,6 @@ class ApproveMessageButton(discord.ui.Button["ModerationAdminView"]): self.current_num = current_num async def callback(self, interaction: discord.Interaction): - # Remove reactions on the message, delete the moderation message await self.message.clear_reactions() await self.moderation_message[0].delete() @@ -344,7 +342,6 @@ class DeleteMessageButton(discord.ui.Button["ModerationAdminView"]): self.current_num = current_num async def callback(self, interaction: discord.Interaction): - # Get the user await self.message.delete() await interaction.response.send_message( diff --git a/services/text_service.py b/services/text_service.py index 535f158..7c0c9f0 100644 --- a/services/text_service.py +++ b/services/text_service.py @@ -217,7 +217,6 @@ class TextService: and not from_edit_command and not converser_cog.pinecone_service # This should only happen if we are not doing summarizations. ): - # We don't need to worry about the differences between interactions and messages in this block, # because if we are in this block, we can only be using a message object for ctx if converser_cog.model.summarize_conversations: @@ -545,7 +544,6 @@ class TextService: # If the user is in a conversation thread if message.channel.id in converser_cog.conversation_threads: - # Since this is async, we don't want to allow the user to send another prompt while a conversation # prompt is processing, that'll mess up the conversation history! if message.author.id in converser_cog.awaiting_responses: @@ -780,7 +778,6 @@ class EndConvoButton(discord.ui.Button["ConversationView"]): self.converser_cog = converser_cog async def callback(self, interaction: discord.Interaction): - # Get the user user_id = interaction.user.id if ( @@ -820,7 +817,6 @@ class RedoButton(discord.ui.Button["ConversationView"]): self.custom_api_key = custom_api_key async def callback(self, interaction: discord.Interaction): - # Get the user user_id = interaction.user.id if user_id in self.converser_cog.redo_users and self.converser_cog.redo_users[ From 6b5ad1bfb8aa125d21d824e423c47918dc0bfe2e Mon Sep 17 00:00:00 2001 From: Kaveen Kumarasinghe Date: Fri, 3 Feb 2023 00:04:51 -0500 Subject: [PATCH 3/4] fix optimizer redo --- cogs/prompt_optimizer_cog.py | 5 ++++- gpt3discord.py | 2 +- image_optimizer_pretext.txt | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cogs/prompt_optimizer_cog.py b/cogs/prompt_optimizer_cog.py index d4eb1ff..1eaafae 100644 --- a/cogs/prompt_optimizer_cog.py +++ b/cogs/prompt_optimizer_cog.py @@ -4,6 +4,7 @@ import traceback import discord from sqlitedict import SqliteDict +from models.openai_model import Override from services.environment_service import EnvService from models.user_model import RedoUser from services.image_service import ImageService @@ -85,7 +86,7 @@ class ImgPromptOptimizer(discord.Cog, name="ImgPromptOptimizer"): top_p_override=1.0, temp_override=0.9, presence_penalty_override=0.5, - best_of_override=2, + best_of_override=1, max_tokens_override=80, custom_api_key=user_api_key, ) @@ -259,10 +260,12 @@ class RedoButton(discord.ui.Button["OptimizeView"]): await interaction.response.send_message( "Redoing your original request...", ephemeral=True, delete_after=20 ) + overrides = Override(1.0, 0.9, 0.5) await TextService.encapsulated_send( self.converser_cog, id=user_id, prompt=prompt, + overrides=overrides, ctx=ctx, response_message=response_message, custom_api_key=self.custom_api_key, diff --git a/gpt3discord.py b/gpt3discord.py index 8ad3f47..d0c216a 100644 --- a/gpt3discord.py +++ b/gpt3discord.py @@ -30,7 +30,7 @@ from services.environment_service import EnvService from models.openai_model import Model -__version__ = "9.0.2" +__version__ = "9.0.3" PID_FILE = Path("bot.pid") diff --git a/image_optimizer_pretext.txt b/image_optimizer_pretext.txt index 206b7ab..d019231 100644 --- a/image_optimizer_pretext.txt +++ b/image_optimizer_pretext.txt @@ -139,6 +139,6 @@ replace [3] with a list of detailed descriptions about the environment of the sc replace [4] with a list of detailed descriptions about the mood/feelings and atmosphere of the scene replace [5] with a list of detailed descriptions about the technical basis like render engine/camera model and details -The outcome depends on the coherency of the prompt. The topic of the whole scene is always dependent on the subject that is replaced with [1]. There is not always a need to add lighting information, decide as neccessary. Do not use more than 50 words under any circumstance. +The outcome depends on the coherency of the prompt. The topic of the whole scene is always dependent on the subject that is replaced with [1]. There is not always a need to add lighting information, decide as neccessary. Do not use more than 40 words under any circumstance. Be concise but descriptive. Input Prompt: \ No newline at end of file From 2e4de119db31e945b644b1035ab69225effde6e5 Mon Sep 17 00:00:00 2001 From: Kaveen Kumarasinghe Date: Fri, 3 Feb 2023 00:09:49 -0500 Subject: [PATCH 4/4] Add thinking message for conversations --- gpt3discord.py | 2 +- services/text_service.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gpt3discord.py b/gpt3discord.py index d0c216a..5068831 100644 --- a/gpt3discord.py +++ b/gpt3discord.py @@ -30,7 +30,7 @@ from services.environment_service import EnvService from models.openai_model import Model -__version__ = "9.0.3" +__version__ = "9.0.4" PID_FILE = Path("bot.pid") diff --git a/services/text_service.py b/services/text_service.py index 7c0c9f0..ff0c68c 100644 --- a/services/text_service.py +++ b/services/text_service.py @@ -630,6 +630,14 @@ class TextService: conversation_overrides["presence_penalty"], ) + # Send an embed that tells the user that the bot is thinking + thinking_embed = discord.Embed( + title=f"🤖💬 Thinking...", + color=0x808080, + ) + thinking_embed.set_footer(text="This may take a few seconds.") + thinking_message = await message.reply(embed=thinking_embed) + await TextService.encapsulated_send( converser_cog, message.channel.id, @@ -639,6 +647,10 @@ class TextService: model=converser_cog.conversation_threads[message.channel.id].model, custom_api_key=user_api_key, ) + + # Delete the thinking embed + await thinking_message.delete() + return True @staticmethod