opentelemetry-instrumentation-botocore 0.52b0__tar.gz → 0.53b0__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.
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/PKG-INFO +41 -3
- opentelemetry_instrumentation_botocore-0.53b0/README.rst +62 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/pyproject.toml +2 -2
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/src/opentelemetry/instrumentation/botocore/__init__.py +6 -36
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/src/opentelemetry/instrumentation/botocore/extensions/bedrock_utils.py +23 -1
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/src/opentelemetry/instrumentation/botocore/version.py +1 -1
- opentelemetry_instrumentation_botocore-0.53b0/tests/cassettes/test_invoke_model_no_content_tool_call[amazon.nova].yaml +291 -0
- opentelemetry_instrumentation_botocore-0.52b0/tests/cassettes/test_invoke_model_with_content_tool_call.yaml → opentelemetry_instrumentation_botocore-0.53b0/tests/cassettes/test_invoke_model_no_content_tool_call[anthropic.claude].yaml +23 -23
- opentelemetry_instrumentation_botocore-0.53b0/tests/cassettes/test_invoke_model_with_content_tool_call[amazon.nova].yaml +291 -0
- opentelemetry_instrumentation_botocore-0.52b0/tests/cassettes/test_invoke_model_no_content_tool_call.yaml → opentelemetry_instrumentation_botocore-0.53b0/tests/cassettes/test_invoke_model_with_content_tool_call[anthropic.claude].yaml +30 -30
- opentelemetry_instrumentation_botocore-0.53b0/tests/cassettes/test_invoke_model_with_response_stream_no_content_tool_call[amazon.nova].yaml +648 -0
- opentelemetry_instrumentation_botocore-0.53b0/tests/cassettes/test_invoke_model_with_response_stream_no_content_tool_call[anthropic.claude].yaml +460 -0
- opentelemetry_instrumentation_botocore-0.53b0/tests/cassettes/test_invoke_model_with_response_stream_with_content_tool_call[amazon.nova].yaml +643 -0
- opentelemetry_instrumentation_botocore-0.53b0/tests/cassettes/test_invoke_model_with_response_stream_with_content_tool_call[anthropic.claude].yaml +484 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/test_botocore_bedrock.py +309 -138
- opentelemetry_instrumentation_botocore-0.52b0/README.rst +0 -24
- opentelemetry_instrumentation_botocore-0.52b0/tests/cassettes/test_invoke_model_with_response_stream_no_content_tool_call.yaml +0 -468
- opentelemetry_instrumentation_botocore-0.52b0/tests/cassettes/test_invoke_model_with_response_stream_with_content_tool_call.yaml +0 -473
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/.gitignore +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/LICENSE +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/src/opentelemetry/instrumentation/botocore/environment_variables.py +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/src/opentelemetry/instrumentation/botocore/extensions/__init__.py +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/src/opentelemetry/instrumentation/botocore/extensions/_messaging.py +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/src/opentelemetry/instrumentation/botocore/extensions/bedrock.py +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/src/opentelemetry/instrumentation/botocore/extensions/dynamodb.py +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/src/opentelemetry/instrumentation/botocore/extensions/lmbd.py +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/src/opentelemetry/instrumentation/botocore/extensions/sns.py +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/src/opentelemetry/instrumentation/botocore/extensions/sqs.py +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/src/opentelemetry/instrumentation/botocore/extensions/types.py +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/src/opentelemetry/instrumentation/botocore/package.py +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/README.md +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/__init__.py +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/bedrock_utils.py +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_converse_no_content.yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_converse_no_content_different_events.yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_converse_stream_handles_event_stream_error.yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_converse_stream_no_content.yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_converse_stream_no_content_different_events.yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_converse_stream_no_content_tool_call.yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_converse_stream_with_content.yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_converse_stream_with_content_different_events.yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_converse_stream_with_content_tool_call.yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_converse_stream_with_invalid_model.yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_converse_tool_call_no_content.yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_converse_tool_call_with_content.yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_converse_with_content.yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_converse_with_content_different_events.yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_converse_with_invalid_model.yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_invoke_model_no_content[amazon.nova].yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_invoke_model_no_content[amazon.titan].yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_invoke_model_no_content[anthropic.claude].yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_invoke_model_no_content_different_events[amazon.nova].yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_invoke_model_no_content_different_events[anthropic.claude].yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_invoke_model_with_content[amazon.nova].yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_invoke_model_with_content[amazon.titan].yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_invoke_model_with_content[anthropic.claude].yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_invoke_model_with_content_different_events[amazon.nova].yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_invoke_model_with_content_different_events[anthropic.claude].yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_invoke_model_with_content_user_content_as_string.yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_invoke_model_with_invalid_model.yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_invoke_model_with_response_stream_handles_stream_error.yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_invoke_model_with_response_stream_invalid_model.yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_invoke_model_with_response_stream_no_content[amazon.nova].yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_invoke_model_with_response_stream_no_content[amazon.titan].yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_invoke_model_with_response_stream_no_content[anthropic.claude].yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_invoke_model_with_response_stream_no_content_different_events[amazon.nova].yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_invoke_model_with_response_stream_no_content_different_events[anthropic.claude].yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_invoke_model_with_response_stream_with_content[amazon.nova].yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_invoke_model_with_response_stream_with_content[amazon.titan].yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_invoke_model_with_response_stream_with_content[anthropic.claude].yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_invoke_model_with_response_stream_with_content_different_events[amazon.nova].yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/cassettes/test_invoke_model_with_response_stream_with_content_different_events[anthropic.claude].yaml +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/conftest.py +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/test_botocore_dynamodb.py +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/test_botocore_instrumentation.py +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/test_botocore_lambda.py +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/test_botocore_messaging.py +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/test_botocore_sns.py +0 -0
- {opentelemetry_instrumentation_botocore-0.52b0 → opentelemetry_instrumentation_botocore-0.53b0}/tests/test_botocore_sqs.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: opentelemetry-instrumentation-botocore
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.53b0
|
4
4
|
Summary: OpenTelemetry Botocore instrumentation
|
5
5
|
Project-URL: Homepage, https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation/opentelemetry-instrumentation-botocore
|
6
6
|
Project-URL: Repository, https://github.com/open-telemetry/opentelemetry-python-contrib
|
@@ -20,9 +20,9 @@ Classifier: Programming Language :: Python :: 3.12
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.13
|
21
21
|
Requires-Python: >=3.8
|
22
22
|
Requires-Dist: opentelemetry-api~=1.30
|
23
|
-
Requires-Dist: opentelemetry-instrumentation==0.
|
23
|
+
Requires-Dist: opentelemetry-instrumentation==0.53b0
|
24
24
|
Requires-Dist: opentelemetry-propagator-aws-xray~=1.0
|
25
|
-
Requires-Dist: opentelemetry-semantic-conventions==0.
|
25
|
+
Requires-Dist: opentelemetry-semantic-conventions==0.53b0
|
26
26
|
Provides-Extra: instruments
|
27
27
|
Requires-Dist: botocore~=1.0; extra == 'instruments'
|
28
28
|
Description-Content-Type: text/x-rst
|
@@ -37,6 +37,44 @@ OpenTelemetry Botocore Tracing
|
|
37
37
|
|
38
38
|
This library allows tracing requests made by the Botocore library.
|
39
39
|
|
40
|
+
Extensions
|
41
|
+
----------
|
42
|
+
|
43
|
+
The instrumentation supports creating extensions for AWS services for enriching what is collected. We have extensions
|
44
|
+
for the following AWS services:
|
45
|
+
|
46
|
+
- Bedrock Runtime
|
47
|
+
- DynamoDB
|
48
|
+
- Lambda
|
49
|
+
- SNS
|
50
|
+
- SQS
|
51
|
+
|
52
|
+
Bedrock Runtime
|
53
|
+
***************
|
54
|
+
|
55
|
+
This extension implements the GenAI semantic conventions for the following API calls:
|
56
|
+
|
57
|
+
- Converse
|
58
|
+
- ConverseStream
|
59
|
+
- InvokeModel
|
60
|
+
- InvokeModelWithResponseStream
|
61
|
+
|
62
|
+
For the Converse and ConverseStream APIs tracing, events and metrics are implemented.
|
63
|
+
|
64
|
+
For the InvokeModel and InvokeModelWithResponseStream APIs tracing, events and metrics implemented only for a subset of
|
65
|
+
the available models, namely:
|
66
|
+
|
67
|
+
- Amazon Titan models
|
68
|
+
- Amazon Nova models
|
69
|
+
- Anthropic Claude
|
70
|
+
|
71
|
+
Tool calls with InvokeModel and InvokeModelWithResponseStream APIs are supported with:
|
72
|
+
|
73
|
+
- Amazon Nova models
|
74
|
+
- Anthropic Claude 3+
|
75
|
+
|
76
|
+
If you don't have an application using Bedrock APIs yet, try our `zero-code examples <examples/bedrock-runtime/zero-code>`_.
|
77
|
+
|
40
78
|
Installation
|
41
79
|
------------
|
42
80
|
|
@@ -0,0 +1,62 @@
|
|
1
|
+
OpenTelemetry Botocore Tracing
|
2
|
+
==============================
|
3
|
+
|
4
|
+
|pypi|
|
5
|
+
|
6
|
+
.. |pypi| image:: https://badge.fury.io/py/opentelemetry-instrumentation-botocore.svg
|
7
|
+
:target: https://pypi.org/project/opentelemetry-instrumentation-botocore/
|
8
|
+
|
9
|
+
This library allows tracing requests made by the Botocore library.
|
10
|
+
|
11
|
+
Extensions
|
12
|
+
----------
|
13
|
+
|
14
|
+
The instrumentation supports creating extensions for AWS services for enriching what is collected. We have extensions
|
15
|
+
for the following AWS services:
|
16
|
+
|
17
|
+
- Bedrock Runtime
|
18
|
+
- DynamoDB
|
19
|
+
- Lambda
|
20
|
+
- SNS
|
21
|
+
- SQS
|
22
|
+
|
23
|
+
Bedrock Runtime
|
24
|
+
***************
|
25
|
+
|
26
|
+
This extension implements the GenAI semantic conventions for the following API calls:
|
27
|
+
|
28
|
+
- Converse
|
29
|
+
- ConverseStream
|
30
|
+
- InvokeModel
|
31
|
+
- InvokeModelWithResponseStream
|
32
|
+
|
33
|
+
For the Converse and ConverseStream APIs tracing, events and metrics are implemented.
|
34
|
+
|
35
|
+
For the InvokeModel and InvokeModelWithResponseStream APIs tracing, events and metrics implemented only for a subset of
|
36
|
+
the available models, namely:
|
37
|
+
|
38
|
+
- Amazon Titan models
|
39
|
+
- Amazon Nova models
|
40
|
+
- Anthropic Claude
|
41
|
+
|
42
|
+
Tool calls with InvokeModel and InvokeModelWithResponseStream APIs are supported with:
|
43
|
+
|
44
|
+
- Amazon Nova models
|
45
|
+
- Anthropic Claude 3+
|
46
|
+
|
47
|
+
If you don't have an application using Bedrock APIs yet, try our `zero-code examples <examples/bedrock-runtime/zero-code>`_.
|
48
|
+
|
49
|
+
Installation
|
50
|
+
------------
|
51
|
+
|
52
|
+
::
|
53
|
+
|
54
|
+
pip install opentelemetry-instrumentation-botocore
|
55
|
+
|
56
|
+
|
57
|
+
References
|
58
|
+
----------
|
59
|
+
|
60
|
+
* `OpenTelemetry Botocore Tracing <https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/botocore/botocore.html>`_
|
61
|
+
* `OpenTelemetry Project <https://opentelemetry.io/>`_
|
62
|
+
* `OpenTelemetry Python Examples <https://github.com/open-telemetry/opentelemetry-python/tree/main/docs/examples>`_
|
@@ -27,8 +27,8 @@ classifiers = [
|
|
27
27
|
]
|
28
28
|
dependencies = [
|
29
29
|
"opentelemetry-api ~= 1.30",
|
30
|
-
"opentelemetry-instrumentation == 0.
|
31
|
-
"opentelemetry-semantic-conventions == 0.
|
30
|
+
"opentelemetry-instrumentation == 0.53b0",
|
31
|
+
"opentelemetry-semantic-conventions == 0.53b0",
|
32
32
|
"opentelemetry-propagator-aws-xray ~= 1.0",
|
33
33
|
]
|
34
34
|
|
@@ -28,7 +28,7 @@ Usage
|
|
28
28
|
.. code:: python
|
29
29
|
|
30
30
|
from opentelemetry.instrumentation.botocore import BotocoreInstrumentor
|
31
|
-
import botocore
|
31
|
+
import botocore.session
|
32
32
|
|
33
33
|
|
34
34
|
# Instrument Botocore
|
@@ -39,7 +39,7 @@ Usage
|
|
39
39
|
session.set_credentials(
|
40
40
|
access_key="access-key", secret_key="secret-key"
|
41
41
|
)
|
42
|
-
ec2 =
|
42
|
+
ec2 = session.create_client("ec2", region_name="us-west-2")
|
43
43
|
ec2.describe_instances()
|
44
44
|
|
45
45
|
API
|
@@ -58,13 +58,15 @@ for example:
|
|
58
58
|
.. code: python
|
59
59
|
|
60
60
|
from opentelemetry.instrumentation.botocore import BotocoreInstrumentor
|
61
|
-
import botocore
|
61
|
+
import botocore.session
|
62
62
|
|
63
63
|
def request_hook(span, service_name, operation_name, api_params):
|
64
64
|
# request hook logic
|
65
|
+
pass
|
65
66
|
|
66
67
|
def response_hook(span, service_name, operation_name, result):
|
67
68
|
# response hook logic
|
69
|
+
pass
|
68
70
|
|
69
71
|
# Instrument Botocore with hooks
|
70
72
|
BotocoreInstrumentor().instrument(request_hook=request_hook, response_hook=response_hook)
|
@@ -74,40 +76,8 @@ for example:
|
|
74
76
|
session.set_credentials(
|
75
77
|
access_key="access-key", secret_key="secret-key"
|
76
78
|
)
|
77
|
-
ec2 =
|
79
|
+
ec2 = session.create_client("ec2", region_name="us-west-2")
|
78
80
|
ec2.describe_instances()
|
79
|
-
|
80
|
-
Extensions
|
81
|
-
----------
|
82
|
-
|
83
|
-
The instrumentation supports creating extensions for AWS services for enriching what is collected. We have extensions
|
84
|
-
for the following AWS services:
|
85
|
-
|
86
|
-
- Bedrock Runtime
|
87
|
-
- DynamoDB
|
88
|
-
- Lambda
|
89
|
-
- SNS
|
90
|
-
- SQS
|
91
|
-
|
92
|
-
Bedrock Runtime
|
93
|
-
***************
|
94
|
-
|
95
|
-
This extension implements the GenAI semantic conventions for the following API calls:
|
96
|
-
|
97
|
-
- Converse
|
98
|
-
- ConverseStream
|
99
|
-
- InvokeModel
|
100
|
-
- InvokeModelWithResponseStream
|
101
|
-
|
102
|
-
For the Converse and ConverseStream APIs tracing, events and metrics are implemented.
|
103
|
-
|
104
|
-
For the InvokeModel and InvokeModelWithResponseStream APIs tracing, events and metrics implemented only for a subset of
|
105
|
-
the available models, namely:
|
106
|
-
- Amazon Titan models
|
107
|
-
- Amazon Nova models
|
108
|
-
- Anthropic Claude
|
109
|
-
|
110
|
-
There is no support for tool calls with Amazon Models for the InvokeModel and InvokeModelWithResponseStream APIs.
|
111
81
|
"""
|
112
82
|
|
113
83
|
import logging
|
@@ -216,7 +216,6 @@ class InvokeModelWithResponseStreamWrapper(ObjectProxy):
|
|
216
216
|
|
217
217
|
def _process_amazon_nova_chunk(self, chunk):
|
218
218
|
# pylint: disable=too-many-branches
|
219
|
-
# TODO: handle tool calls!
|
220
219
|
if "messageStart" in chunk:
|
221
220
|
# {'messageStart': {'role': 'assistant'}}
|
222
221
|
if chunk["messageStart"].get("role") == "assistant":
|
@@ -224,17 +223,40 @@ class InvokeModelWithResponseStreamWrapper(ObjectProxy):
|
|
224
223
|
self._message = {"role": "assistant", "content": []}
|
225
224
|
return
|
226
225
|
|
226
|
+
if "contentBlockStart" in chunk:
|
227
|
+
# {'contentBlockStart': {'start': {'toolUse': {'toolUseId': 'id', 'name': 'name'}}, 'contentBlockIndex': 31}}
|
228
|
+
if self._record_message:
|
229
|
+
self._message["content"].append(self._content_block)
|
230
|
+
|
231
|
+
start = chunk["contentBlockStart"].get("start", {})
|
232
|
+
if "toolUse" in start:
|
233
|
+
self._content_block = start
|
234
|
+
else:
|
235
|
+
self._content_block = {}
|
236
|
+
return
|
237
|
+
|
227
238
|
if "contentBlockDelta" in chunk:
|
228
239
|
# {'contentBlockDelta': {'delta': {'text': "Hello"}, 'contentBlockIndex': 0}}
|
240
|
+
# {'contentBlockDelta': {'delta': {'toolUse': {'input': '{"location":"San Francisco"}'}}, 'contentBlockIndex': 31}}
|
229
241
|
if self._record_message:
|
230
242
|
delta = chunk["contentBlockDelta"].get("delta", {})
|
231
243
|
if "text" in delta:
|
232
244
|
self._content_block.setdefault("text", "")
|
233
245
|
self._content_block["text"] += delta["text"]
|
246
|
+
elif "toolUse" in delta:
|
247
|
+
self._content_block.setdefault("toolUse", {})
|
248
|
+
self._content_block["toolUse"]["input"] = json.loads(
|
249
|
+
delta["toolUse"]["input"]
|
250
|
+
)
|
234
251
|
return
|
235
252
|
|
236
253
|
if "contentBlockStop" in chunk:
|
237
254
|
# {'contentBlockStop': {'contentBlockIndex': 0}}
|
255
|
+
if self._record_message:
|
256
|
+
# create a new content block only for tools
|
257
|
+
if "toolUse" in self._content_block:
|
258
|
+
self._message["content"].append(self._content_block)
|
259
|
+
self._content_block = {}
|
238
260
|
return
|
239
261
|
|
240
262
|
if "messageStop" in chunk:
|
@@ -0,0 +1,291 @@
|
|
1
|
+
interactions:
|
2
|
+
- request:
|
3
|
+
body: |-
|
4
|
+
{
|
5
|
+
"messages": [
|
6
|
+
{
|
7
|
+
"role": "user",
|
8
|
+
"content": [
|
9
|
+
{
|
10
|
+
"text": "What is the weather in Seattle and San Francisco today? Please expect one tool call for Seattle and one for San Francisco"
|
11
|
+
}
|
12
|
+
]
|
13
|
+
}
|
14
|
+
],
|
15
|
+
"inferenceConfig": {
|
16
|
+
"max_new_tokens": 1000
|
17
|
+
},
|
18
|
+
"schemaVersion": "messages-v1",
|
19
|
+
"toolConfig": {
|
20
|
+
"tools": [
|
21
|
+
{
|
22
|
+
"toolSpec": {
|
23
|
+
"name": "get_current_weather",
|
24
|
+
"description": "Get the current weather in a given location.",
|
25
|
+
"inputSchema": {
|
26
|
+
"json": {
|
27
|
+
"type": "object",
|
28
|
+
"properties": {
|
29
|
+
"location": {
|
30
|
+
"type": "string",
|
31
|
+
"description": "The name of the city"
|
32
|
+
}
|
33
|
+
},
|
34
|
+
"required": [
|
35
|
+
"location"
|
36
|
+
]
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
]
|
42
|
+
}
|
43
|
+
}
|
44
|
+
headers:
|
45
|
+
Content-Length:
|
46
|
+
- '552'
|
47
|
+
User-Agent:
|
48
|
+
- Boto3/1.35.56 md/Botocore#1.35.56 ua/2.0 os/linux#6.1.0-1034-oem md/arch#x86_64
|
49
|
+
lang/python#3.10.12 md/pyimpl#CPython cfg/retry-mode#legacy Botocore/1.35.56
|
50
|
+
X-Amz-Date:
|
51
|
+
- 20250325T130901Z
|
52
|
+
X-Amz-Security-Token:
|
53
|
+
- test_aws_security_token
|
54
|
+
X-Amzn-Trace-Id:
|
55
|
+
- Root=1-2541300b-2dbeda14c09ccd3d3b041879;Parent=1fc006fd156b7383;Sampled=1
|
56
|
+
amz-sdk-invocation-id:
|
57
|
+
- 09f5a7ed-4163-46ec-a974-000c5662062a
|
58
|
+
amz-sdk-request:
|
59
|
+
- attempt=1
|
60
|
+
authorization:
|
61
|
+
- Bearer test_aws_authorization
|
62
|
+
method: POST
|
63
|
+
uri: https://bedrock-runtime.us-east-1.amazonaws.com/model/amazon.nova-micro-v1%3A0/invoke
|
64
|
+
response:
|
65
|
+
body:
|
66
|
+
string: |-
|
67
|
+
{
|
68
|
+
"output": {
|
69
|
+
"message": {
|
70
|
+
"content": [
|
71
|
+
{
|
72
|
+
"text": "<thinking> To provide the current weather information for both Seattle and San Francisco, I will need to use the `get_current_weather` tool separately for each city. I will start by calling the tool for Seattle and then proceed to call it for San Francisco.</thinking>\n"
|
73
|
+
},
|
74
|
+
{
|
75
|
+
"toolUse": {
|
76
|
+
"name": "get_current_weather",
|
77
|
+
"toolUseId": "4d8acf92-6a04-42b6-aaf7-f68937a339ef",
|
78
|
+
"input": {
|
79
|
+
"location": "Seattle"
|
80
|
+
}
|
81
|
+
}
|
82
|
+
},
|
83
|
+
{
|
84
|
+
"toolUse": {
|
85
|
+
"name": "get_current_weather",
|
86
|
+
"toolUseId": "db27bd9d-9f7d-4783-aa8b-59871e00e0bc",
|
87
|
+
"input": {
|
88
|
+
"location": "San Francisco"
|
89
|
+
}
|
90
|
+
}
|
91
|
+
}
|
92
|
+
],
|
93
|
+
"role": "assistant"
|
94
|
+
}
|
95
|
+
},
|
96
|
+
"stopReason": "tool_use",
|
97
|
+
"usage": {
|
98
|
+
"inputTokens": 427,
|
99
|
+
"outputTokens": 172,
|
100
|
+
"totalTokens": 599,
|
101
|
+
"cacheReadInputTokenCount": 0,
|
102
|
+
"cacheWriteInputTokenCount": 0
|
103
|
+
}
|
104
|
+
}
|
105
|
+
headers:
|
106
|
+
Connection:
|
107
|
+
- keep-alive
|
108
|
+
Content-Type:
|
109
|
+
- application/json
|
110
|
+
Date:
|
111
|
+
- Tue, 25 Mar 2025 13:09:02 GMT
|
112
|
+
Set-Cookie: test_set_cookie
|
113
|
+
X-Amzn-Bedrock-Cache-Read-Input-Token-Count:
|
114
|
+
- '0'
|
115
|
+
X-Amzn-Bedrock-Cache-Write-Input-Token-Count:
|
116
|
+
- '0'
|
117
|
+
X-Amzn-Bedrock-Input-Token-Count:
|
118
|
+
- '427'
|
119
|
+
X-Amzn-Bedrock-Invocation-Latency:
|
120
|
+
- '430'
|
121
|
+
X-Amzn-Bedrock-Output-Token-Count:
|
122
|
+
- '172'
|
123
|
+
x-amzn-RequestId:
|
124
|
+
- adebeba4-5940-4c34-87a1-46cd45646bbe
|
125
|
+
status:
|
126
|
+
code: 200
|
127
|
+
message: OK
|
128
|
+
- request:
|
129
|
+
body: |-
|
130
|
+
{
|
131
|
+
"messages": [
|
132
|
+
{
|
133
|
+
"role": "user",
|
134
|
+
"content": [
|
135
|
+
{
|
136
|
+
"text": "What is the weather in Seattle and San Francisco today? Please expect one tool call for Seattle and one for San Francisco"
|
137
|
+
}
|
138
|
+
]
|
139
|
+
},
|
140
|
+
{
|
141
|
+
"content": [
|
142
|
+
{
|
143
|
+
"text": "<thinking> To provide the current weather information for both Seattle and San Francisco, I will need to use the `get_current_weather` tool separately for each city. I will start by calling the tool for Seattle and then proceed to call it for San Francisco.</thinking>\n"
|
144
|
+
},
|
145
|
+
{
|
146
|
+
"toolUse": {
|
147
|
+
"name": "get_current_weather",
|
148
|
+
"toolUseId": "4d8acf92-6a04-42b6-aaf7-f68937a339ef",
|
149
|
+
"input": {
|
150
|
+
"location": "Seattle"
|
151
|
+
}
|
152
|
+
}
|
153
|
+
},
|
154
|
+
{
|
155
|
+
"toolUse": {
|
156
|
+
"name": "get_current_weather",
|
157
|
+
"toolUseId": "db27bd9d-9f7d-4783-aa8b-59871e00e0bc",
|
158
|
+
"input": {
|
159
|
+
"location": "San Francisco"
|
160
|
+
}
|
161
|
+
}
|
162
|
+
}
|
163
|
+
],
|
164
|
+
"role": "assistant"
|
165
|
+
},
|
166
|
+
{
|
167
|
+
"role": "user",
|
168
|
+
"content": [
|
169
|
+
{
|
170
|
+
"toolResult": {
|
171
|
+
"toolUseId": "4d8acf92-6a04-42b6-aaf7-f68937a339ef",
|
172
|
+
"content": [
|
173
|
+
{
|
174
|
+
"json": {
|
175
|
+
"weather": "50 degrees and raining"
|
176
|
+
}
|
177
|
+
}
|
178
|
+
]
|
179
|
+
}
|
180
|
+
},
|
181
|
+
{
|
182
|
+
"toolResult": {
|
183
|
+
"toolUseId": "db27bd9d-9f7d-4783-aa8b-59871e00e0bc",
|
184
|
+
"content": [
|
185
|
+
{
|
186
|
+
"json": {
|
187
|
+
"weather": "70 degrees and sunny"
|
188
|
+
}
|
189
|
+
}
|
190
|
+
]
|
191
|
+
}
|
192
|
+
}
|
193
|
+
]
|
194
|
+
}
|
195
|
+
],
|
196
|
+
"inferenceConfig": {
|
197
|
+
"max_new_tokens": 1000
|
198
|
+
},
|
199
|
+
"schemaVersion": "messages-v1",
|
200
|
+
"toolConfig": {
|
201
|
+
"tools": [
|
202
|
+
{
|
203
|
+
"toolSpec": {
|
204
|
+
"name": "get_current_weather",
|
205
|
+
"description": "Get the current weather in a given location.",
|
206
|
+
"inputSchema": {
|
207
|
+
"json": {
|
208
|
+
"type": "object",
|
209
|
+
"properties": {
|
210
|
+
"location": {
|
211
|
+
"type": "string",
|
212
|
+
"description": "The name of the city"
|
213
|
+
}
|
214
|
+
},
|
215
|
+
"required": [
|
216
|
+
"location"
|
217
|
+
]
|
218
|
+
}
|
219
|
+
}
|
220
|
+
}
|
221
|
+
}
|
222
|
+
]
|
223
|
+
}
|
224
|
+
}
|
225
|
+
headers:
|
226
|
+
Content-Length:
|
227
|
+
- '1439'
|
228
|
+
User-Agent:
|
229
|
+
- Boto3/1.35.56 md/Botocore#1.35.56 ua/2.0 os/linux#6.1.0-1034-oem md/arch#x86_64
|
230
|
+
lang/python#3.10.12 md/pyimpl#CPython cfg/retry-mode#legacy Botocore/1.35.56
|
231
|
+
X-Amz-Date:
|
232
|
+
- 20250325T130902Z
|
233
|
+
X-Amz-Security-Token:
|
234
|
+
- test_aws_security_token
|
235
|
+
X-Amzn-Trace-Id:
|
236
|
+
- Root=1-2592d804-d8515e92a6320e1d293c3643;Parent=5406f9af558aaabe;Sampled=1
|
237
|
+
amz-sdk-invocation-id:
|
238
|
+
- 4ad9ba7e-df5a-4a01-a3a1-40fce5d29ef2
|
239
|
+
amz-sdk-request:
|
240
|
+
- attempt=1
|
241
|
+
authorization:
|
242
|
+
- Bearer test_aws_authorization
|
243
|
+
method: POST
|
244
|
+
uri: https://bedrock-runtime.us-east-1.amazonaws.com/model/amazon.nova-micro-v1%3A0/invoke
|
245
|
+
response:
|
246
|
+
body:
|
247
|
+
string: |-
|
248
|
+
{
|
249
|
+
"output": {
|
250
|
+
"message": {
|
251
|
+
"content": [
|
252
|
+
{
|
253
|
+
"text": "<thinking> I have received the weather information for both cities. Now I will compile this information and present it to the User.</thinking>\n\nThe current weather in Seattle is 50 degrees and it is raining. In San Francisco, the weather is 70 degrees and sunny."
|
254
|
+
}
|
255
|
+
],
|
256
|
+
"role": "assistant"
|
257
|
+
}
|
258
|
+
},
|
259
|
+
"stopReason": "end_turn",
|
260
|
+
"usage": {
|
261
|
+
"inputTokens": 576,
|
262
|
+
"outputTokens": 57,
|
263
|
+
"totalTokens": 633,
|
264
|
+
"cacheReadInputTokenCount": 0,
|
265
|
+
"cacheWriteInputTokenCount": 0
|
266
|
+
}
|
267
|
+
}
|
268
|
+
headers:
|
269
|
+
Connection:
|
270
|
+
- keep-alive
|
271
|
+
Content-Type:
|
272
|
+
- application/json
|
273
|
+
Date:
|
274
|
+
- Tue, 25 Mar 2025 13:09:03 GMT
|
275
|
+
Set-Cookie: test_set_cookie
|
276
|
+
X-Amzn-Bedrock-Cache-Read-Input-Token-Count:
|
277
|
+
- '0'
|
278
|
+
X-Amzn-Bedrock-Cache-Write-Input-Token-Count:
|
279
|
+
- '0'
|
280
|
+
X-Amzn-Bedrock-Input-Token-Count:
|
281
|
+
- '576'
|
282
|
+
X-Amzn-Bedrock-Invocation-Latency:
|
283
|
+
- '417'
|
284
|
+
X-Amzn-Bedrock-Output-Token-Count:
|
285
|
+
- '57'
|
286
|
+
x-amzn-RequestId:
|
287
|
+
- cedb9b10-f794-4ec4-ac67-f3e237511e62
|
288
|
+
status:
|
289
|
+
code: 200
|
290
|
+
message: OK
|
291
|
+
version: 1
|