@@ -171,14 +171,23 @@ def test_parallel_and_sequential_tool_calling(self, model: BaseChatModel) -> Non
171171 "I need to find flights for March 15th, accommodation from March 15th to March 20th, and things to do there." ,
172172 "Search for accomodations, flights and attractions in parallel. Don't repeat the same tool call." ,
173173 )
174- model_with_tools_parallel = model .bind_tools (
175- tools ,
176- tool_choice = {"type" : "any" , "disable_parallel_tool_use" : False }, # type: ignore
177- )
178- model_with_tools_sequential = model .bind_tools (
179- tools ,
180- tool_choice = {"type" : "any" , "disable_parallel_tool_use" : True }, # type: ignore
181- )
174+ if isinstance (model , UiPathChatAnthropicBedrock ):
175+ # UiPathChatAnthropicBedrock uses parallel_tool_calls as a top-level param
176+ model_with_tools_parallel = model .bind_tools (
177+ tools , tool_choice = "any" , parallel_tool_calls = True
178+ )
179+ model_with_tools_sequential = model .bind_tools (
180+ tools , tool_choice = "any" , parallel_tool_calls = False
181+ )
182+ else :
183+ model_with_tools_parallel = model .bind_tools (
184+ tools ,
185+ tool_choice = {"type" : "any" , "disable_parallel_tool_use" : False }, # type: ignore
186+ )
187+ model_with_tools_sequential = model .bind_tools (
188+ tools ,
189+ tool_choice = {"type" : "any" , "disable_parallel_tool_use" : True }, # type: ignore
190+ )
182191
183192 parallel_response = model_with_tools_parallel .invoke (prompt )
184193 sequential_response = model_with_tools_sequential .invoke (prompt )
@@ -196,14 +205,22 @@ async def test_parallel_and_sequential_tool_calling_async(self, model: BaseChatM
196205 "I need to find flights for March 15th, accommodation from March 15th to March 20th, and things to do there." ,
197206 "Search for accomodations, flights and attractions in parallel. Don't repeat the same tool call." ,
198207 )
199- model_with_tools_parallel = model .bind_tools (
200- tools ,
201- tool_choice = {"type" : "any" , "disable_parallel_tool_use" : False }, # type: ignore
202- )
203- model_with_tools_sequential = model .bind_tools (
204- tools ,
205- tool_choice = {"type" : "any" , "disable_parallel_tool_use" : True }, # type: ignore
206- )
208+ if isinstance (model , UiPathChatAnthropicBedrock ):
209+ model_with_tools_parallel = model .bind_tools (
210+ tools , tool_choice = "any" , parallel_tool_calls = True
211+ )
212+ model_with_tools_sequential = model .bind_tools (
213+ tools , tool_choice = "any" , parallel_tool_calls = False
214+ )
215+ else :
216+ model_with_tools_parallel = model .bind_tools (
217+ tools ,
218+ tool_choice = {"type" : "any" , "disable_parallel_tool_use" : False }, # type: ignore
219+ )
220+ model_with_tools_sequential = model .bind_tools (
221+ tools ,
222+ tool_choice = {"type" : "any" , "disable_parallel_tool_use" : True }, # type: ignore
223+ )
207224
208225 parallel_response = await model_with_tools_parallel .ainvoke (prompt )
209226 sequential_response = await model_with_tools_sequential .ainvoke (prompt )
0 commit comments