From 5d511a426a68d72fa3161731bd7b7238bdff97e0 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Thu, 18 Apr 2024 13:22:17 +0800 Subject: [PATCH] feat: Updated sdks/python/julep/utils/openai_patch (#270) Co-authored-by: sweep-ai[bot] <128439645+sweep-ai[bot]@users.noreply.github.com> --- sdks/python/julep/utils/openai_patch.py | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/sdks/python/julep/utils/openai_patch.py b/sdks/python/julep/utils/openai_patch.py index f2636fbe5..628ce1ec0 100644 --- a/sdks/python/julep/utils/openai_patch.py +++ b/sdks/python/julep/utils/openai_patch.py @@ -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( @@ -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( @@ -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(