diff --git a/cogs/commands.py b/cogs/commands.py index 99e50e5..fc85c81 100644 --- a/cogs/commands.py +++ b/cogs/commands.py @@ -684,7 +684,9 @@ class Commands(discord.Cog, name="Commands"): @add_to_group("index") @discord.slash_command( - name="recurse-link", description="Recursively index a link", guild_ids=ALLOWED_GUILDS + name="recurse-link", + description="Recursively index a link", + guild_ids=ALLOWED_GUILDS, ) @discord.guild_only() @discord.option( diff --git a/cogs/index_service_cog.py b/cogs/index_service_cog.py index 414b9fb..3a129f3 100644 --- a/cogs/index_service_cog.py +++ b/cogs/index_service_cog.py @@ -121,7 +121,7 @@ class IndexService(discord.Cog, name="IndexService"): ) async def set_index_link_recurse_command( - self, ctx, link: str = None, depth:int = 1 + self, ctx, link: str = None, depth: int = 1 ): await ctx.defer() """Command handler to set a file as your personal index""" @@ -129,7 +129,6 @@ class IndexService(discord.Cog, name="IndexService"): await ctx.respond("Please provide a link") return - user_api_key = None if USER_INPUT_API_KEYS: user_api_key = await TextService.get_user_api_key( diff --git a/models/index_model.py b/models/index_model.py index 082c49f..5644eb2 100644 --- a/models/index_model.py +++ b/models/index_model.py @@ -40,7 +40,8 @@ from llama_index import ( IndexStructType, OpenAIEmbedding, GithubRepositoryReader, - MockEmbedding, download_loader, + MockEmbedding, + download_loader, ) from llama_index.readers.web import DEFAULT_WEBSITE_EXTRACTOR @@ -399,7 +400,9 @@ class Index_handler: suffix = value break if not suffix: - await ctx.send("Could not determine the file type of the attachment, attempting a dirty index..") + await ctx.send( + "Could not determine the file type of the attachment, attempting a dirty index.." + ) return # Send indexing message @@ -412,11 +415,16 @@ class Index_handler: async with aiofiles.tempfile.NamedTemporaryFile( suffix=suffix, dir=temp_path, delete=False ) as temp_file: - await file.save(temp_file.name) embedding_model = OpenAIEmbedding() index = await self.loop.run_in_executor( - None, partial(self.index_file, Path(temp_file.name), embedding_model, suffix) + None, + partial( + self.index_file, + Path(temp_file.name), + embedding_model, + suffix, + ), ) await self.usage_service.update_usage( embedding_model.last_token_usage, embeddings=True @@ -479,7 +487,9 @@ class Index_handler: # Check if the link contains youtube in it loader = RemoteDepthReader(depth=depth) - documents = await self.loop.run_in_executor(None, partial(loader.load_data, [link])) + documents = await self.loop.run_in_executor( + None, partial(loader.load_data, [link]) + ) index = await self.loop.run_in_executor( None, functools.partial(