Skip to content

Commit

Permalink
Format Python code with psf/black push
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions authored and github-actions committed Nov 9, 2023
1 parent 3dc9c42 commit 70e6468
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 10 deletions.
4 changes: 3 additions & 1 deletion cogs/code_interpreter_service_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
5 changes: 3 additions & 2 deletions cogs/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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",
Expand Down
1 change: 0 additions & 1 deletion cogs/image_service_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 3 additions & 1 deletion cogs/search_service_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
4 changes: 3 additions & 1 deletion cogs/text_service_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions models/index_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 0 additions & 2 deletions services/usage_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def __init__(self, data_dir: Path):
"curie": 0.002,
"embedding": 0.0001,
"gpt-turbo": 0.03,

}

MODEL_COST_MAP = {
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 70e6468

Please sign in to comment.