Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -538,10 +538,9 @@ def gen() -> ChatResponseGen:
content = join_two_dicts(content, content_delta)

thinking_delta_value = None
if "reasoningContent" in content_delta:
if reasoning_content := content_delta.get("reasoningContent"):
# For ConverseStream (streaming) requests, reasoning text, signature,
# redacted content are stored within `reasoningContent`.
reasoning_content = content_delta.get("reasoningContent", {})
reasoning_text = reasoning_content.get("text", "")
thinking += reasoning_text
thinking_delta_value = reasoning_text
Expand Down Expand Up @@ -580,7 +579,7 @@ def gen() -> ChatResponseGen:
blocks: List[Union[TextBlock, ThinkingBlock, ToolCallBlock]] = [
TextBlock(text=content.get("text", ""))
]
if thinking != "":
if thinking != "" or thinking_signature != "":
blocks.insert(
0,
ThinkingBlock(
Expand Down Expand Up @@ -635,7 +634,7 @@ def gen() -> ChatResponseGen:
blocks: List[Union[TextBlock, ThinkingBlock, ToolCallBlock]] = [
TextBlock(text=content.get("text", ""))
]
if thinking != "":
if thinking != "" or thinking_signature != "":
blocks.insert(
0,
ThinkingBlock(
Expand Down Expand Up @@ -680,7 +679,7 @@ def gen() -> ChatResponseGen:
blocks: List[Union[TextBlock, ThinkingBlock, ToolCallBlock]] = [
TextBlock(text=content.get("text", ""))
]
if thinking != "":
if thinking != "" or thinking_signature != "":
blocks.insert(
0,
ThinkingBlock(
Expand Down Expand Up @@ -824,10 +823,9 @@ async def gen() -> ChatResponseAsyncGen:
content = join_two_dicts(content, content_delta)

thinking_delta_value = None
if "reasoningContent" in content_delta:
if reasoning_content := content_delta.get("reasoningContent"):
# For ConverseStream (streaming) requests, reasoning text, signature,
# redacted content are stored within `reasoningContent`.
reasoning_content = content_delta.get("reasoningContent", {})
reasoning_text = reasoning_content.get("text", "")
thinking += reasoning_text
thinking_delta_value = reasoning_text
Expand Down Expand Up @@ -865,7 +863,7 @@ async def gen() -> ChatResponseAsyncGen:
blocks: List[Union[TextBlock, ThinkingBlock, ToolCallBlock]] = [
TextBlock(text=content.get("text", ""))
]
if thinking != "":
if thinking != "" or thinking_signature != "":
blocks.insert(
0,
ThinkingBlock(
Expand Down Expand Up @@ -921,7 +919,7 @@ async def gen() -> ChatResponseAsyncGen:
blocks: List[Union[TextBlock, ThinkingBlock, ToolCallBlock]] = [
TextBlock(text=content.get("text", ""))
]
if thinking != "":
if thinking != "" or thinking_signature != "":
blocks.insert(
0,
ThinkingBlock(
Expand Down Expand Up @@ -966,7 +964,7 @@ async def gen() -> ChatResponseAsyncGen:
blocks: List[Union[TextBlock, ThinkingBlock, ToolCallBlock]] = [
TextBlock(text=content.get("text", ""))
]
if thinking != "":
if thinking != "" or thinking_signature != "":
blocks.insert(
0,
ThinkingBlock(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,16 +338,14 @@ def _content_block_to_bedrock_format(
)
return {"text": block.content}

if block.content:
signature = block.additional_information.get("signature")
if block.content or signature:
thinking_data = {
"reasoningContent": {"reasoningText": {"text": block.content}}
"reasoningContent": {"reasoningText": {"text": block.content or ""}}
}
if (
"signature" in block.additional_information
and block.additional_information["signature"]
):
if signature:
thinking_data["reasoningContent"]["reasoningText"]["signature"] = (
block.additional_information["signature"]
signature
)

return thinking_data
Expand Down Expand Up @@ -946,3 +944,4 @@ def join_two_dicts(dict1: Dict[str, Any], dict2: Dict[str, Any]) -> Dict[str, An
class ThinkingDict(TypedDict):
type: Literal["enabled", "adaptive"]
budget_tokens: NotRequired[int]
display: NotRequired[Literal["summarized", "omitted"]]
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dev = [

[project]
name = "llama-index-llms-bedrock-converse"
version = "0.14.10"
version = "0.15.0"
description = "llama-index llms bedrock converse integration"
authors = [{name = "Your Name", email = "you@example.com"}]
requires-python = ">=3.10,<4.0"
Expand Down
Loading
Loading