diff --git a/cogs/code_interpreter_service_cog.py b/cogs/code_interpreter_service_cog.py index 344a32ad..1a09607a 100644 --- a/cogs/code_interpreter_service_cog.py +++ b/cogs/code_interpreter_service_cog.py @@ -455,7 +455,12 @@ async def code_interpreter_chat_command( ) ) - llm = ChatOpenAI(model=model, temperature=temperature, top_p=top_p, openai_api_key=OPENAI_API_KEY) + llm = ChatOpenAI( + model=model, + temperature=temperature, + top_p=top_p, + openai_api_key=OPENAI_API_KEY, + ) max_token_limit = 29000 if "gpt-4" in model else 7500 diff --git a/cogs/commands.py b/cogs/commands.py index 71f53494..85669ccd 100644 --- a/cogs/commands.py +++ b/cogs/commands.py @@ -761,7 +761,7 @@ async def load_index( input_type=discord.SlashCommandOptionType.number, max_value=1, min_value=0, - default=0 + default=0, ) @discord.option( name="top_p", @@ -770,7 +770,7 @@ async def load_index( input_type=discord.SlashCommandOptionType.number, max_value=1, min_value=0, - default=1 + default=1, ) async def talk( self, @@ -1137,7 +1137,7 @@ async def draw_action(self, ctx, message: discord.Message): input_type=discord.SlashCommandOptionType.number, max_value=1, min_value=0, - default=0 + default=0, ) @discord.option( name="top_p", @@ -1146,7 +1146,7 @@ async def draw_action(self, ctx, message: discord.Message): input_type=discord.SlashCommandOptionType.number, max_value=1, min_value=0, - default=1 + default=1, ) async def chat_code( self, @@ -1160,7 +1160,9 @@ async def chat_code( "Code interpretation is disabled on this server.", ephemeral=True ) return - await self.code_interpreter_cog.code_interpreter_chat_command(ctx, model=model, temperature=temperature, top_p=top_p) + await self.code_interpreter_cog.code_interpreter_chat_command( + ctx, model=model, temperature=temperature, top_p=top_p + ) """ Translation commands and actions @@ -1284,7 +1286,7 @@ async def summarize_action(self, ctx, message: discord.Message): input_type=discord.SlashCommandOptionType.number, max_value=1, min_value=0, - default=0 + default=0, ) @discord.option( name="top_p", @@ -1293,7 +1295,7 @@ async def summarize_action(self, ctx, message: discord.Message): input_type=discord.SlashCommandOptionType.number, max_value=1, min_value=0, - default=1 + default=1, ) async def chat( self, @@ -1304,7 +1306,11 @@ async def chat( top_p: float = 1, ): await self.search_cog.search_chat_command( - ctx, search_scope=search_scope, model=model, temperature=temperature, top_p=top_p, + ctx, + search_scope=search_scope, + model=model, + temperature=temperature, + top_p=top_p, ) # Search slash commands @@ -1371,7 +1377,7 @@ async def search( nodes: int = 4, deep: bool = False, response_mode: str = "refine", - model: str ="gpt-4-1106-preview", + model: str = "gpt-4-1106-preview", multistep: bool = False, ): await self.search_cog.search_command( diff --git a/cogs/index_service_cog.py b/cogs/index_service_cog.py index 4ffbb775..7cd3ce52 100644 --- a/cogs/index_service_cog.py +++ b/cogs/index_service_cog.py @@ -152,7 +152,8 @@ async def on_message(self, message): prompt += ( "\n{System Message: the user has just uploaded the file " - + str(file.filename) + "\n" + + str(file.filename) + + "\n" ) # Link operations, allow for user link upload, we connect and download the content at the link. diff --git a/cogs/search_service_cog.py b/cogs/search_service_cog.py index 05f07b31..05c13d53 100644 --- a/cogs/search_service_cog.py +++ b/cogs/search_service_cog.py @@ -419,7 +419,12 @@ async def on_message(self, message): safe_remove_list(self.thread_awaiting_responses, message.channel.id) async def search_chat_command( - self, ctx: discord.ApplicationContext, model, search_scope=2, temperature=0, top_p=1, + self, + ctx: discord.ApplicationContext, + model, + search_scope=2, + temperature=0, + top_p=1, ): await ctx.defer() embed_title = f"{ctx.user.name}'s internet-connected conversation with GPT" @@ -477,7 +482,12 @@ async def search_chat_command( traceback.print_exc() print("Wolfram tool not added to internet-connected conversation agent.") - llm = ChatOpenAI(model=model, temperature=temperature, top_p=top_p, openai_api_key=OPENAI_API_KEY) + llm = ChatOpenAI( + model=model, + temperature=temperature, + top_p=top_p, + openai_api_key=OPENAI_API_KEY, + ) max_token_limit = 29000 if "gpt-4" in model else 7500 diff --git a/models/index_model.py b/models/index_model.py index bce8e9bc..c2828eb0 100644 --- a/models/index_model.py +++ b/models/index_model.py @@ -511,8 +511,12 @@ async def start_index_chat(self, ctx, model, temperature, top_p): preparation_message = await ctx.channel.send( embed=EmbedStatics.get_index_chat_preparation_message() ) - llm = ChatOpenAI(model=model, temperature=temperature, top_p=top_p, max_retries=2) - llm_predictor = LLMPredictor(llm=ChatOpenAI(temperature=temperature, top_p=top_p, model_name=model)) + llm = ChatOpenAI( + model=model, temperature=temperature, top_p=top_p, max_retries=2 + ) + llm_predictor = LLMPredictor( + llm=ChatOpenAI(temperature=temperature, top_p=top_p, model_name=model) + ) max_token_limit = 29000 if "gpt-4" in model else 7500 diff --git a/models/search_model.py b/models/search_model.py index 810eac9c..109950b4 100644 --- a/models/search_model.py +++ b/models/search_model.py @@ -228,7 +228,6 @@ async def search( os.environ["OPENAI_API_KEY"] = user_api_key openai.api_key = os.environ["OPENAI_API_KEY"] - # Initialize the search cost price = 0 @@ -340,7 +339,9 @@ async def search( embedding_model = OpenAIEmbedding() if "vision" in model: - llm_predictor = LLMPredictor(llm=ChatOpenAI(temperature=0, model=model, max_tokens=4096)) + llm_predictor = LLMPredictor( + llm=ChatOpenAI(temperature=0, model=model, max_tokens=4096) + ) else: llm_predictor = LLMPredictor(llm=ChatOpenAI(temperature=0, model=model))