From a0c5f50a1b84b25173ab8a669e3bdb9b264befed Mon Sep 17 00:00:00 2001 From: pranavvuppala Date: Tue, 28 May 2024 12:11:12 +0530 Subject: [PATCH 1/2] Added docstrings for functions in OpenAI base.py --- .../agents/openai_assistant/base.py | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/libs/community/langchain_community/agents/openai_assistant/base.py b/libs/community/langchain_community/agents/openai_assistant/base.py index fc977d7c00c25..754ffc720506d 100644 --- a/libs/community/langchain_community/agents/openai_assistant/base.py +++ b/libs/community/langchain_community/agents/openai_assistant/base.py @@ -61,7 +61,12 @@ def _get_openai_async_client() -> openai.AsyncOpenAI: def _convert_file_ids_into_attachments(file_ids: list) -> list: """ Convert file_ids into attachments - File search and Code interpreter will be turned on by default + File search and Code interpreter will be turned on by default. + + Args: + file_ids (list): List of file_ids that need to be converted into attachments. + Returns: + A list of attachments that are converted from file_ids. """ attachments = [] for id in file_ids: @@ -77,7 +82,14 @@ def _convert_file_ids_into_attachments(file_ids: list) -> list: def _is_assistants_builtin_tool( tool: Union[Dict[str, Any], Type[BaseModel], Callable, BaseTool], ) -> bool: - """Determine if tool corresponds to OpenAI Assistants built-in.""" + """ + Determine if tool corresponds to OpenAI Assistants built-in. + + Args: + tool : Tool that needs to be determined + Returns: + A boolean response of true or false indicating if the tool corresponds to OpenAI Assistants built-in. + """ assistants_builtin_tools = ("code_interpreter", "retrieval") return ( isinstance(tool, dict) @@ -93,6 +105,12 @@ def _get_assistants_tool( Note that OpenAI assistants supports several built-in tools, such as "code_interpreter" and "retrieval." + + Args: + tool: Tools or functions that need to be converted to OpenAI tools. + Returns: + A dictionary of tools that are converted into OpenAI tools. + """ if _is_assistants_builtin_tool(tool): return tool # type: ignore From fdf18dc94bf89d799433e25c3a62e90bb972ab46 Mon Sep 17 00:00:00 2001 From: Bagatur Date: Mon, 3 Jun 2024 17:18:38 -0700 Subject: [PATCH 2/2] fmt --- .../langchain_community/agents/openai_assistant/base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/community/langchain_community/agents/openai_assistant/base.py b/libs/community/langchain_community/agents/openai_assistant/base.py index 754ffc720506d..7b2bfd81c40ae 100644 --- a/libs/community/langchain_community/agents/openai_assistant/base.py +++ b/libs/community/langchain_community/agents/openai_assistant/base.py @@ -88,7 +88,8 @@ def _is_assistants_builtin_tool( Args: tool : Tool that needs to be determined Returns: - A boolean response of true or false indicating if the tool corresponds to OpenAI Assistants built-in. + A boolean response of true or false indicating if the tool corresponds to + OpenAI Assistants built-in. """ assistants_builtin_tools = ("code_interpreter", "retrieval") return (