llama-index-llms-bedrock-converse 0.10.5__tar.gz → 0.10.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: llama-index-llms-bedrock-converse
3
- Version: 0.10.5
3
+ Version: 0.10.6
4
4
  Summary: llama-index llms bedrock converse integration
5
5
  Author-email: Your Name <you@example.com>
6
6
  License-Expression: MIT
@@ -167,6 +167,10 @@ class BedrockConverse(FunctionCallingLLM):
167
167
  description="Specifies the thinking configuration of a reasoning model. Only applicable to Anthropic and DeepSeek models",
168
168
  default=None,
169
169
  )
170
+ supports_forced_tool_calls: bool = Field(
171
+ default=True,
172
+ description="Whether the model supports forced tool calls. If True, the model can be forced to call at least 1 or more tools.",
173
+ )
170
174
  additional_kwargs: Dict[str, Any] = Field(
171
175
  default_factory=dict,
172
176
  description="Additional kwargs for the bedrock invokeModel request.",
@@ -210,6 +214,7 @@ class BedrockConverse(FunctionCallingLLM):
210
214
  application_inference_profile_arn: Optional[str] = None,
211
215
  trace: Optional[str] = None,
212
216
  thinking: Optional[ThinkingDict] = None,
217
+ supports_forced_tool_calls: bool = True,
213
218
  ) -> None:
214
219
  additional_kwargs = additional_kwargs or {}
215
220
  callback_manager = callback_manager or CallbackManager([])
@@ -261,6 +266,7 @@ class BedrockConverse(FunctionCallingLLM):
261
266
  application_inference_profile_arn=application_inference_profile_arn,
262
267
  trace=trace,
263
268
  thinking=thinking,
269
+ supports_forced_tool_calls=supports_forced_tool_calls,
264
270
  )
265
271
 
266
272
  self._config = None
@@ -913,6 +919,7 @@ class BedrockConverse(FunctionCallingLLM):
913
919
  tool_choice=tool_choice,
914
920
  tool_required=tool_required,
915
921
  tool_caching=tool_caching,
922
+ supports_forced_tool_calls=self.supports_forced_tool_calls,
916
923
  )
917
924
 
918
925
  return {
@@ -454,6 +454,7 @@ def tools_to_converse_tools(
454
454
  tool_choice: Optional[dict] = None,
455
455
  tool_required: bool = False,
456
456
  tool_caching: bool = False,
457
+ supports_forced_tool_calls: bool = True,
457
458
  ) -> Dict[str, Any]:
458
459
  """
459
460
  Converts a list of tools to AWS Bedrock Converse tools.
@@ -482,11 +483,18 @@ def tools_to_converse_tools(
482
483
  if tool_caching:
483
484
  converse_tools.append({"cachePoint": {"type": "default"}})
484
485
 
486
+ if tool_choice:
487
+ tool_choice = tool_choice
488
+ elif supports_forced_tool_calls and tool_required:
489
+ tool_choice = {"any": {}}
490
+ else:
491
+ tool_choice = {"auto": {}}
492
+
485
493
  return {
486
494
  "tools": converse_tools,
487
495
  # https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ToolChoice.html
488
496
  # e.g. { "auto": {} }
489
- "toolChoice": tool_choice or ({"any": {}} if tool_required else {"auto": {}}),
497
+ "toolChoice": tool_choice,
490
498
  }
491
499
 
492
500
 
@@ -29,7 +29,7 @@ dev = [
29
29
 
30
30
  [project]
31
31
  name = "llama-index-llms-bedrock-converse"
32
- version = "0.10.5"
32
+ version = "0.10.6"
33
33
  description = "llama-index llms bedrock converse integration"
34
34
  authors = [{name = "Your Name", email = "you@example.com"}]
35
35
  requires-python = ">=3.9,<4.0"