diff --git a/cogs/commands.py b/cogs/commands.py index 5ee74bb..7367fef 100644 --- a/cogs/commands.py +++ b/cogs/commands.py @@ -412,6 +412,38 @@ class Commands(discord.Cog, name="Commands"): required=False, default=False, ) + @discord.option( + name="temperature", + description="Higher values means the model will take more risks", + required=False, + input_type=float, + min_value=0, + max_value=2, + ) + @discord.option( + name="top_p", + description="1 is greedy sampling, 0.1 means only top 10%", + required=False, + input_type=float, + min_value=0, + max_value=1, + ) + @discord.option( + name="frequency_penalty", + description="Decreasing the model's likelihood to repeat the same line verbatim", + required=False, + input_type=float, + min_value=-2, + max_value=2, + ) + @discord.option( + name="presence_penalty", + description="Increasing the model's likelihood to talk about new topics", + required=False, + input_type=float, + min_value=-2, + max_value=2, + ) @discord.guild_only() async def converse( self, @@ -420,9 +452,13 @@ class Commands(discord.Cog, name="Commands"): opener_file: str, private: bool, minimal: bool, + temperature: float, + top_p: float, + frequency_penalty: float, + presence_penalty: float, ): await self.converser_cog.converse_command( - ctx, opener, opener_file, private, minimal + ctx, opener, opener_file, private, minimal, temperature, top_p, frequency_penalty, presence_penalty ) @add_to_group("gpt") diff --git a/cogs/text_service_cog.py b/cogs/text_service_cog.py index 08b41d3..960f80c 100644 --- a/cogs/text_service_cog.py +++ b/cogs/text_service_cog.py @@ -798,6 +798,10 @@ class GPT3ComCon(discord.Cog, name="GPT3ComCon"): opener_file: str, private: bool, minimal: bool, + temperature: float, + top_p: float, + frequency_penalty: float, + presence_penalty: float, ): """Command handler. Starts a conversation with the bot @@ -807,6 +811,10 @@ class GPT3ComCon(discord.Cog, name="GPT3ComCon"): opener_file (str): A .txt or .json file which is appended before the opener private (bool): If the thread should be private minimal (bool): If a minimal starter should be used + temperature (float): Sets the temperature override + top_p (float): Sets the top p override + frequency_penalty (float): Sets the frequency penalty override + presence_penalty (float): Sets the presence penalty override """ user = ctx.user @@ -857,6 +865,11 @@ class GPT3ComCon(discord.Cog, name="GPT3ComCon"): self.conversation_threads[thread.id] = Thread(thread.id) self.conversation_threads[thread.id].model = self.model.model + # Set the overrides for the conversation + self.conversation_threads[thread.id].set_overrides( + temperature, top_p, frequency_penalty, presence_penalty + ) + if opener: opener = await self.mention_to_username(ctx, opener) @@ -910,7 +923,7 @@ class GPT3ComCon(discord.Cog, name="GPT3ComCon"): opener_file = None # Just start a regular thread if the file fails to load # Append the starter text for gpt3 to the user's history so it gets concatenated with the prompt later - if minimal or opener_file: + if minimal or opener_file or opener: self.conversation_threads[thread.id].history.append( EmbeddedConversationItem(self.CONVERSATION_STARTER_TEXT_MINIMAL, 0) ) diff --git a/conversation_starter_pretext_minimal.txt b/conversation_starter_pretext_minimal.txt index 118184e..0a5dcfe 100644 --- a/conversation_starter_pretext_minimal.txt +++ b/conversation_starter_pretext_minimal.txt @@ -1,6 +1,4 @@ Instructions for you: -You are an all-intelligent assistant. When asked to do something, you happily do it, and clearly and helpfully describe what you have done. - The conversations are in this format, there can be an arbitrary amount of newlines between chat entries. can be any name, pay attention to who's talking. The text "<|endofstatement|>" is used to separate chat entries and make it easier for you to understand the context: : [MESSAGE 1] <|endofstatement|> @@ -11,6 +9,3 @@ The conversations are in this format, there can be an arbitrary amount of newlin will be given to you in an actual conversation. ... - -Never say "<|endofstatement|>". Never say or in your response either. Never respond as or pretend to be the user, only respond as yourself. -You're a regular discord user, be friendly, casual, and fun, speak with "lol", "haha", and other slang when it seems fitting, and use emojis in your responses in a way that makes sense.