From af129974a35bbb064fde046bab4151eff2d0ea09 Mon Sep 17 00:00:00 2001 From: ccurme Date: Wed, 5 Jun 2024 14:19:41 -0400 Subject: [PATCH] community: update how OpenAIAssistantV2Runnable creates threads with tool_resources (#22549) https://github.com/langchain-ai/langchain/issues/22503 --- .../langchain_community/agents/openai_assistant/base.py | 8 ++++++-- 1 file changed, 6 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 7b2bfd81c4..806fef2bd8 100644 --- a/libs/community/langchain_community/agents/openai_assistant/base.py +++ b/libs/community/langchain_community/agents/openai_assistant/base.py @@ -507,8 +507,10 @@ class OpenAIAssistantV2Runnable(OpenAIAssistantRunnable): params = { k: v for k, v in input.items() - if k in ("instructions", "model", "tools", "tool_resources", "run_metadata") + if k in ("instructions", "model", "tools", "run_metadata") } + if tool_resources := input.get("tool_resources"): + thread["tool_resources"] = tool_resources run = self.client.beta.threads.create_and_run( assistant_id=self.assistant_id, thread=thread, @@ -532,8 +534,10 @@ class OpenAIAssistantV2Runnable(OpenAIAssistantRunnable): params = { k: v for k, v in input.items() - if k in ("instructions", "model", "tools", "tool_resources", "run_metadata") + if k in ("instructions", "model", "tools", "run_metadata") } + if tool_resources := input.get("tool_resources"): + thread["tool_resources"] = tool_resources run = await self.async_client.beta.threads.create_and_run( assistant_id=self.assistant_id, thread=thread,