llama-index-llms-bedrock-converse 0.12.2__py3-none-any.whl → 0.12.4__py3-none-any.whl
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.
- llama_index/llms/bedrock_converse/base.py +40 -16
- {llama_index_llms_bedrock_converse-0.12.2.dist-info → llama_index_llms_bedrock_converse-0.12.4.dist-info}/METADATA +1 -1
- llama_index_llms_bedrock_converse-0.12.4.dist-info/RECORD +7 -0
- llama_index_llms_bedrock_converse-0.12.2.dist-info/RECORD +0 -7
- {llama_index_llms_bedrock_converse-0.12.2.dist-info → llama_index_llms_bedrock_converse-0.12.4.dist-info}/WHEEL +0 -0
- {llama_index_llms_bedrock_converse-0.12.2.dist-info → llama_index_llms_bedrock_converse-0.12.4.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import warnings
|
|
2
2
|
from typing import (
|
|
3
|
+
TYPE_CHECKING,
|
|
3
4
|
Any,
|
|
4
5
|
Callable,
|
|
5
6
|
Dict,
|
|
@@ -9,16 +10,21 @@ from typing import (
|
|
|
9
10
|
Sequence,
|
|
10
11
|
Tuple,
|
|
11
12
|
Union,
|
|
12
|
-
TYPE_CHECKING,
|
|
13
13
|
)
|
|
14
14
|
|
|
15
|
+
from llama_index.core.base.llms.generic_utils import (
|
|
16
|
+
achat_to_completion_decorator,
|
|
17
|
+
astream_chat_to_completion_decorator,
|
|
18
|
+
chat_to_completion_decorator,
|
|
19
|
+
stream_chat_to_completion_decorator,
|
|
20
|
+
)
|
|
15
21
|
from llama_index.core.base.llms.types import (
|
|
16
22
|
ChatMessage,
|
|
17
23
|
ChatResponse,
|
|
18
|
-
ChatResponseGen,
|
|
19
24
|
ChatResponseAsyncGen,
|
|
20
|
-
|
|
25
|
+
ChatResponseGen,
|
|
21
26
|
CompletionResponse,
|
|
27
|
+
CompletionResponseAsyncGen,
|
|
22
28
|
CompletionResponseGen,
|
|
23
29
|
LLMMetadata,
|
|
24
30
|
MessageRole,
|
|
@@ -33,26 +39,20 @@ from llama_index.core.llms.callbacks import (
|
|
|
33
39
|
llm_chat_callback,
|
|
34
40
|
llm_completion_callback,
|
|
35
41
|
)
|
|
36
|
-
from llama_index.core.base.llms.generic_utils import (
|
|
37
|
-
achat_to_completion_decorator,
|
|
38
|
-
astream_chat_to_completion_decorator,
|
|
39
|
-
chat_to_completion_decorator,
|
|
40
|
-
stream_chat_to_completion_decorator,
|
|
41
|
-
)
|
|
42
42
|
from llama_index.core.llms.function_calling import FunctionCallingLLM, ToolSelection
|
|
43
43
|
from llama_index.core.llms.utils import parse_partial_json
|
|
44
44
|
from llama_index.core.types import BaseOutputParser, PydanticProgramMode
|
|
45
45
|
from llama_index.llms.bedrock_converse.utils import (
|
|
46
|
+
ThinkingDict,
|
|
46
47
|
bedrock_modelname_to_context_size,
|
|
47
48
|
converse_with_retry,
|
|
48
49
|
converse_with_retry_async,
|
|
49
50
|
force_single_tool_call,
|
|
50
51
|
is_bedrock_function_calling_model,
|
|
52
|
+
is_reasoning,
|
|
51
53
|
join_two_dicts,
|
|
52
54
|
messages_to_converse_messages,
|
|
53
55
|
tools_to_converse_tools,
|
|
54
|
-
is_reasoning,
|
|
55
|
-
ThinkingDict,
|
|
56
56
|
)
|
|
57
57
|
|
|
58
58
|
if TYPE_CHECKING:
|
|
@@ -364,7 +364,9 @@ class BedrockConverse(FunctionCallingLLM):
|
|
|
364
364
|
}
|
|
365
365
|
|
|
366
366
|
def _get_content_and_tool_calls(
|
|
367
|
-
self,
|
|
367
|
+
self,
|
|
368
|
+
response: Optional[Dict[str, Any]] = None,
|
|
369
|
+
content: Optional[Dict[str, Any]] = None,
|
|
368
370
|
) -> Tuple[
|
|
369
371
|
List[Union[TextBlock, ThinkingBlock, ToolCallBlock]], List[str], List[str]
|
|
370
372
|
]:
|
|
@@ -505,10 +507,13 @@ class BedrockConverse(FunctionCallingLLM):
|
|
|
505
507
|
content_delta = content_block_delta["delta"]
|
|
506
508
|
content = join_two_dicts(content, content_delta)
|
|
507
509
|
|
|
510
|
+
thinking_delta_value = None
|
|
508
511
|
if "reasoningContent" in content_delta:
|
|
509
|
-
|
|
512
|
+
reasoning_text = content_delta.get("reasoningContent", {}).get(
|
|
510
513
|
"text", ""
|
|
511
514
|
)
|
|
515
|
+
thinking += reasoning_text
|
|
516
|
+
thinking_delta_value = reasoning_text
|
|
512
517
|
thinking_signature += content_delta.get(
|
|
513
518
|
"reasoningContent", {}
|
|
514
519
|
).get("signature", "")
|
|
@@ -566,6 +571,14 @@ class BedrockConverse(FunctionCallingLLM):
|
|
|
566
571
|
)
|
|
567
572
|
)
|
|
568
573
|
|
|
574
|
+
response_additional_kwargs = self._get_response_token_counts(
|
|
575
|
+
dict(chunk)
|
|
576
|
+
)
|
|
577
|
+
if thinking_delta_value is not None:
|
|
578
|
+
response_additional_kwargs["thinking_delta"] = (
|
|
579
|
+
thinking_delta_value
|
|
580
|
+
)
|
|
581
|
+
|
|
569
582
|
yield ChatResponse(
|
|
570
583
|
message=ChatMessage(
|
|
571
584
|
role=role,
|
|
@@ -579,7 +592,7 @@ class BedrockConverse(FunctionCallingLLM):
|
|
|
579
592
|
),
|
|
580
593
|
delta=content_delta.get("text", ""),
|
|
581
594
|
raw=chunk,
|
|
582
|
-
additional_kwargs=
|
|
595
|
+
additional_kwargs=response_additional_kwargs,
|
|
583
596
|
)
|
|
584
597
|
elif content_block_start := chunk.get("contentBlockStart"):
|
|
585
598
|
# New tool call starting
|
|
@@ -777,10 +790,13 @@ class BedrockConverse(FunctionCallingLLM):
|
|
|
777
790
|
content_delta = content_block_delta["delta"]
|
|
778
791
|
content = join_two_dicts(content, content_delta)
|
|
779
792
|
|
|
793
|
+
thinking_delta_value = None
|
|
780
794
|
if "reasoningContent" in content_delta:
|
|
781
|
-
|
|
795
|
+
reasoning_text = content_delta.get("reasoningContent", {}).get(
|
|
782
796
|
"text", ""
|
|
783
797
|
)
|
|
798
|
+
thinking += reasoning_text
|
|
799
|
+
thinking_delta_value = reasoning_text
|
|
784
800
|
thinking_signature += content_delta.get(
|
|
785
801
|
"reasoningContent", {}
|
|
786
802
|
).get("signature", "")
|
|
@@ -838,6 +854,14 @@ class BedrockConverse(FunctionCallingLLM):
|
|
|
838
854
|
)
|
|
839
855
|
)
|
|
840
856
|
|
|
857
|
+
response_additional_kwargs = self._get_response_token_counts(
|
|
858
|
+
dict(chunk)
|
|
859
|
+
)
|
|
860
|
+
if thinking_delta_value is not None:
|
|
861
|
+
response_additional_kwargs["thinking_delta"] = (
|
|
862
|
+
thinking_delta_value
|
|
863
|
+
)
|
|
864
|
+
|
|
841
865
|
yield ChatResponse(
|
|
842
866
|
message=ChatMessage(
|
|
843
867
|
role=role,
|
|
@@ -851,7 +875,7 @@ class BedrockConverse(FunctionCallingLLM):
|
|
|
851
875
|
),
|
|
852
876
|
delta=content_delta.get("text", ""),
|
|
853
877
|
raw=chunk,
|
|
854
|
-
additional_kwargs=
|
|
878
|
+
additional_kwargs=response_additional_kwargs,
|
|
855
879
|
)
|
|
856
880
|
elif content_block_start := chunk.get("contentBlockStart"):
|
|
857
881
|
# New tool call starting
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
llama_index/llms/bedrock_converse/__init__.py,sha256=xE3ZHLXqFr7TTTgQlYH9bLLPRZAV3dJyiz_iUFXBfak,98
|
|
2
|
+
llama_index/llms/bedrock_converse/base.py,sha256=uQ2pD0SwSqbjLdDB9A5O0REky5y6LL3E3UWNIHvKVu8,46074
|
|
3
|
+
llama_index/llms/bedrock_converse/utils.py,sha256=dP24P7SU9l6NiRC4jbBRjnsPoSwEBXDBMzqwSAgSMX0,30001
|
|
4
|
+
llama_index_llms_bedrock_converse-0.12.4.dist-info/METADATA,sha256=WdzTa6FZPw6XiDWs1K97YuvU5kz2352AwZLD9kyteKY,7834
|
|
5
|
+
llama_index_llms_bedrock_converse-0.12.4.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
6
|
+
llama_index_llms_bedrock_converse-0.12.4.dist-info/licenses/LICENSE,sha256=JPQLUZD9rKvCTdu192Nk0V5PAwklIg6jANii3UmTyMs,1065
|
|
7
|
+
llama_index_llms_bedrock_converse-0.12.4.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
llama_index/llms/bedrock_converse/__init__.py,sha256=xE3ZHLXqFr7TTTgQlYH9bLLPRZAV3dJyiz_iUFXBfak,98
|
|
2
|
-
llama_index/llms/bedrock_converse/base.py,sha256=rs6Vz6Yg6lM8zaZQ26enXsn0jwVgTDm5x4S1LY4CEiI,45059
|
|
3
|
-
llama_index/llms/bedrock_converse/utils.py,sha256=dP24P7SU9l6NiRC4jbBRjnsPoSwEBXDBMzqwSAgSMX0,30001
|
|
4
|
-
llama_index_llms_bedrock_converse-0.12.2.dist-info/METADATA,sha256=7qLGNTYt8TRDG_4488bJoCVZ4hpMPIvvSHGxsjtQBSQ,7834
|
|
5
|
-
llama_index_llms_bedrock_converse-0.12.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
6
|
-
llama_index_llms_bedrock_converse-0.12.2.dist-info/licenses/LICENSE,sha256=JPQLUZD9rKvCTdu192Nk0V5PAwklIg6jANii3UmTyMs,1065
|
|
7
|
-
llama_index_llms_bedrock_converse-0.12.2.dist-info/RECORD,,
|
|
File without changes
|