Skip to content

Commit

Permalink
feat: Updated sdks/python/julep/utils/openai_patch (#270)
Browse files Browse the repository at this point in the history
Co-authored-by: sweep-ai[bot] <128439645+sweep-ai[bot]@users.noreply.github.com>
  • Loading branch information
sweep-ai[bot] authored Apr 18, 2024
1 parent 352eef2 commit 5d511a4
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 5d511a4

Please sign in to comment.