Skip to content

Commit

Permalink
Merge main into sweep/update_the_docstrings_and_comments_in_sd_1f1fd
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Apr 18, 2024
2 parents 39d04fa + 5d511a4 commit 339e01d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions sdks/python/julep/utils/openai_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@


def patch_completions_acreate(client: OpenAI):
"""
Asynchronously patches the `completions.create` method of the OpenAI client.
This function replaces the original `completions.create` method with a custom asynchronous version that allows for additional parameters and custom behavior.
Parameters:
- client (OpenAI): The OpenAI client instance to be patched.
Returns:
- OpenAI: The patched OpenAI client instance with the modified `completions.create` method.
"""
original_completions_create = client.completions.create

async def completions_create(
Expand Down Expand Up @@ -82,6 +93,17 @@ async def completions_create(


def patch_chat_acreate(client: OpenAI):
"""
Asynchronously patches the `chat.completions.create` method of the OpenAI client.
This function updates the `chat.completions.create` method to an asynchronous version, enabling the inclusion of additional parameters and adjustments to its behavior.
Parameters:
- client (OpenAI): The OpenAI client instance to be patched.
Returns:
- OpenAI: The patched OpenAI client instance with the updated `chat.completions.create` method.
"""
original_chat_create = client.chat.completions.create

async def chat_create(
Expand Down Expand Up @@ -171,6 +193,17 @@ async def chat_create(


def patch_completions_create(client: OpenAI):
"""
Patches the `completions.create` method (non-async version) of the OpenAI client.
This function replaces the original `completions.create` method with a custom version that supports additional parameters and custom behavior, without changing it to an asynchronous function.
Parameters:
- client (OpenAI): The OpenAI client instance to be patched.
Returns:
- OpenAI: The patched OpenAI client instance with the modified `completions.create` method.
"""
original_completions_create = client.completions.create

def completions_create(
Expand Down

0 comments on commit 339e01d

Please sign in to comment.