Skip to content

Commit

Permalink
Finalizing changes
Browse files Browse the repository at this point in the history
Use type hints for function arguments and return values to improve code readability and maintainability: The code uses type hints for function arguments and return values throughout the file.

Use async with to manage resources like pinecone.Index and openai.Embedding to ensure that they are properly cleaned up after use: The code uses async with to manage resources like pinecone.Index and openai.Embedding to ensure that they are properly cleaned up after use.

Use asyncio.gather to run tasks concurrently instead of using a for loop to create tasks and then awaiting them one by one: The code uses asyncio.gather to run tasks concurrently instead of using a for loop to create tasks and then awaiting them one by one.

Use asyncio.sleep to avoid hitting rate limits when making API requests: The code uses asyncio.sleep to avoid hitting rate limits when making API requests.

Use a logger to log errors and other important information instead of printing to the console: The code uses a logger to log errors and other important information instead of printing to the console.

Use os.path.join to join file paths instead of using string concatenation: The code uses os.path.join to join file paths instead of using string concatenation.

Use os.path.isfile to check if a file exists instead of using a try-except block: The code uses os.path.isfile to check if a file exists instead of using a try-except block.

Use os.scandir instead of os.listdir to get a list of files in a directory as it is faster and returns an iterator instead of a list: The code uses os.scandir instead of os.listdir to get a list of files in a directory as it is faster and returns an iterator instead of a list.

Use asyncio.to_thread to run blocking I/O operations in a separate thread to avoid blocking the event loop: The code uses asyncio.to_thread to run blocking I/O operations in a separate thread to avoid blocking the event loop.

Use asyncio.shield to prevent tasks from being cancelled when the main task is cancelled: The code uses asyncio.shield to prevent tasks from being cancelled when the main task is cancelled.

Use asyncio.create_task to create tasks instead of asyncio.ensure_future as it is more efficient: The code uses asyncio.create_task to create tasks instead of asyncio.ensure_future as it is more efficient.

Use asyncio.wait_for to set a timeout for tasks that may take a long time to complete: The code uses asyncio.wait_for to set a timeout for tasks that may take a long time to complete.

Use asyncio.Lock to prevent multiple tasks from accessing a shared resource at the same time: The code uses asyncio.Lock to prevent multiple tasks from accessing a shared resource at the same time.

Use asyncio.Queue to pass data between tasks instead of using global variables: The code uses asyncio.Queue to pass data between tasks instead of using global variables.

Use asyncio.Event to signal when a task has completed instead of using a global variable: The code uses asyncio.Event to signal when a task has completed instead of using a global variable.
  • Loading branch information
Daethyra committed Oct 10, 2023
1 parent 4210710 commit 3d61134
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion OpenAI/Auto-Embedder/pinembed.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ async def create_embedding(self, input_text: str) -> Dict[str, Union[int, List[f
response = openai.Embedding.create(
model="text-embedding-ada-002",
input=input_text,
# Might be useful to add the user parameter
)
return response
except Exception as e:
Expand Down

0 comments on commit 3d61134

Please sign in to comment.