From 70e64681af76b67891072c64330fdfa9bed99aa4 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Thu, 9 Nov 2023 23:50:34 +0000 Subject: [PATCH] Format Python code with psf/black push --- cogs/code_interpreter_service_cog.py | 4 +++- cogs/commands.py | 5 +++-- cogs/image_service_cog.py | 1 - cogs/search_service_cog.py | 4 +++- cogs/text_service_cog.py | 4 +++- models/index_model.py | 8 ++++++-- services/usage_service.py | 2 -- 7 files changed, 18 insertions(+), 10 deletions(-) diff --git a/cogs/code_interpreter_service_cog.py b/cogs/code_interpreter_service_cog.py index 52372f91..354de0cb 100644 --- a/cogs/code_interpreter_service_cog.py +++ b/cogs/code_interpreter_service_cog.py @@ -219,7 +219,9 @@ async def on_message(self, message): agent = self.chat_agents[message.channel.id] try: # Start listening to STDOUT before this call. We wanna track all the output for this specific call below - self.usage_service.update_usage_memory(message.guild.name, "code_interpreter_message", 1) + self.usage_service.update_usage_memory( + message.guild.name, "code_interpreter_message", 1 + ) response, stdout_output = await capture_stdout( self.bot.loop.run_in_executor, None, agent.run, prompt ) diff --git a/cogs/commands.py b/cogs/commands.py index 06a17e82..725a136b 100644 --- a/cogs/commands.py +++ b/cogs/commands.py @@ -1028,7 +1028,9 @@ async def help(self, ctx: discord.ApplicationContext): @add_to_group("system") @discord.slash_command( - name="usage_metrics", description="Usage count by functionality", guild_ids=ALLOWED_GUILDS + name="usage_metrics", + description="Usage count by functionality", + guild_ids=ALLOWED_GUILDS, ) @discord.guild_only() async def usage_metrics(self, ctx: discord.ApplicationContext): @@ -1053,7 +1055,6 @@ async def usage_metrics(self, ctx: discord.ApplicationContext): for embed in embed_list: await ctx.channel.send(embed=embed) - @discord.slash_command( name="setup", description="Setup your API key for use with GPT3Discord", diff --git a/cogs/image_service_cog.py b/cogs/image_service_cog.py index 449e31df..39d136c9 100644 --- a/cogs/image_service_cog.py +++ b/cogs/image_service_cog.py @@ -82,7 +82,6 @@ async def draw_command( ) self.usage_service.update_usage_memory(ctx.guild.name, "image_drawn", 1) - except Exception as e: print(e) traceback.print_exc() diff --git a/cogs/search_service_cog.py b/cogs/search_service_cog.py index 69058647..d03b8559 100644 --- a/cogs/search_service_cog.py +++ b/cogs/search_service_cog.py @@ -362,7 +362,9 @@ async def on_message(self, message): used_tools = [] try: # Start listening to STDOUT before this call. We wanna track all the output for this specific call below - self.usage_service.update_usage_memory(message.guild.name, "internet_chat_message", 1) + self.usage_service.update_usage_memory( + message.guild.name, "internet_chat_message", 1 + ) response, stdout_output = await capture_stdout( self.bot.loop.run_in_executor, None, agent.run, prompt ) diff --git a/cogs/text_service_cog.py b/cogs/text_service_cog.py index b629ee85..050e0a86 100644 --- a/cogs/text_service_cog.py +++ b/cogs/text_service_cog.py @@ -705,7 +705,9 @@ async def on_message(self, message): files=None if not file else message.attachments, ): print("Processing a conversation message in server", message.guild.name) - self.usage_service.update_usage_memory(message.guild.name, "conversation_message", 1) + self.usage_service.update_usage_memory( + message.guild.name, "conversation_message", 1 + ) original_message[message.author.id] = message.id # If the user tagged the bot and the tag wasn't an @here or @everyone, retrieve the message diff --git a/models/index_model.py b/models/index_model.py index 7fd72ba7..9771f9da 100644 --- a/models/index_model.py +++ b/models/index_model.py @@ -429,7 +429,9 @@ async def index_chat_file(self, message: discord.Message, file: discord.Attachme ), ) print("Done Indexing") - self.usage_service.update_usage_memory(message.guild.name, "index_chat_file", 1) + self.usage_service.update_usage_memory( + message.guild.name, "index_chat_file", 1 + ) summary = await index.as_query_engine( response_mode="tree_summarize", @@ -976,7 +978,9 @@ async def index_link(self, link, summarize=False, index_chat_ctx=None): if index_chat_ctx: try: print("Getting transcript summary") - self.usage_service.update_usage_memory(index_chat_ctx.guild.name, "index_chat_link", 1) + self.usage_service.update_usage_memory( + index_chat_ctx.guild.name, "index_chat_link", 1 + ) summary = await index.as_query_engine( response_mode="tree_summarize", service_context=get_service_context_with_llm( diff --git a/services/usage_service.py b/services/usage_service.py index c30d2b89..74cea605 100644 --- a/services/usage_service.py +++ b/services/usage_service.py @@ -26,7 +26,6 @@ def __init__(self, data_dir: Path): "curie": 0.002, "embedding": 0.0001, "gpt-turbo": 0.03, - } MODEL_COST_MAP = { @@ -133,7 +132,6 @@ def get_usage_memory(self, guild_name): def get_usage_memory_all(self): return self.usage - @staticmethod def count_tokens_static(text): tokenizer = tiktoken.get_encoding("cl100k_base")