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(