|
58 | 58 | _GEN_AI_RESPONSE_FINISH_REASONS: str = "gen_ai.response.finish_reasons" |
59 | 59 | _GEN_AI_USAGE_INPUT_TOKENS: str = "gen_ai.usage.input_tokens" |
60 | 60 | _GEN_AI_USAGE_OUTPUT_TOKENS: str = "gen_ai.usage.output_tokens" |
| 61 | +_GEN_AI_REQUEST_STOP_SEQUENCES: str = "gen_ai.request.stop_sequences" |
61 | 62 | _GEN_AI_SYSTEM: str = "gen_ai.system" |
62 | 63 | _GEN_AI_RUNTIME_ID: str = "gen_ai.runtime.id" |
63 | 64 | _GEN_AI_BROWSER_ID: str = "gen_ai.browser.id" |
@@ -663,6 +664,64 @@ def test_bedrock_runtime_invoke_model_mistral(self): |
663 | 664 | span_name="chat mistral.mistral-7b-instruct-v0:2", |
664 | 665 | ) |
665 | 666 |
|
| 667 | + def test_bedrock_runtime_converse(self): |
| 668 | + self.do_test_requests( |
| 669 | + "bedrock/converse/converse", |
| 670 | + "GET", |
| 671 | + 200, |
| 672 | + 0, |
| 673 | + 0, |
| 674 | + rpc_service="Bedrock Runtime", |
| 675 | + remote_service="AWS::BedrockRuntime", |
| 676 | + remote_operation="Converse", |
| 677 | + remote_resource_type="AWS::Bedrock::Model", |
| 678 | + remote_resource_identifier="anthropic.claude-v2:1", |
| 679 | + cloudformation_primary_identifier="anthropic.claude-v2:1", |
| 680 | + request_specific_attributes={ |
| 681 | + _GEN_AI_REQUEST_MODEL: "anthropic.claude-v2:1", |
| 682 | + _GEN_AI_SYSTEM: "aws.bedrock", |
| 683 | + _GEN_AI_REQUEST_MAX_TOKENS: 512, |
| 684 | + _GEN_AI_REQUEST_TEMPERATURE: 0.7, |
| 685 | + _GEN_AI_REQUEST_TOP_P: 0.9, |
| 686 | + _GEN_AI_REQUEST_STOP_SEQUENCES: ["Human:"], |
| 687 | + }, |
| 688 | + response_specific_attributes={ |
| 689 | + _GEN_AI_RESPONSE_FINISH_REASONS: ["end_turn"], |
| 690 | + _GEN_AI_USAGE_INPUT_TOKENS: 12, |
| 691 | + _GEN_AI_USAGE_OUTPUT_TOKENS: 8, |
| 692 | + }, |
| 693 | + span_name="chat anthropic.claude-v2:1", |
| 694 | + ) |
| 695 | + |
| 696 | + def test_bedrock_runtime_converse_stream(self): |
| 697 | + self.do_test_requests( |
| 698 | + "bedrock/conversestream/converse-stream", |
| 699 | + "GET", |
| 700 | + 200, |
| 701 | + 0, |
| 702 | + 0, |
| 703 | + rpc_service="Bedrock Runtime", |
| 704 | + remote_service="AWS::BedrockRuntime", |
| 705 | + remote_operation="ConverseStream", |
| 706 | + remote_resource_type="AWS::Bedrock::Model", |
| 707 | + remote_resource_identifier="anthropic.claude-v2:1", |
| 708 | + cloudformation_primary_identifier="anthropic.claude-v2:1", |
| 709 | + request_specific_attributes={ |
| 710 | + _GEN_AI_REQUEST_MODEL: "anthropic.claude-v2:1", |
| 711 | + _GEN_AI_SYSTEM: "aws.bedrock", |
| 712 | + _GEN_AI_REQUEST_MAX_TOKENS: 256, |
| 713 | + _GEN_AI_REQUEST_TEMPERATURE: 0.8, |
| 714 | + _GEN_AI_REQUEST_TOP_P: 0.95, |
| 715 | + _GEN_AI_REQUEST_STOP_SEQUENCES: ["Assistant:"], |
| 716 | + }, |
| 717 | + response_specific_attributes={ |
| 718 | + _GEN_AI_RESPONSE_FINISH_REASONS: ["end_turn"], |
| 719 | + _GEN_AI_USAGE_INPUT_TOKENS: 15, |
| 720 | + _GEN_AI_USAGE_OUTPUT_TOKENS: 10, |
| 721 | + }, |
| 722 | + span_name="chat anthropic.claude-v2:1", |
| 723 | + ) |
| 724 | + |
666 | 725 | def test_bedrock_get_guardrail(self): |
667 | 726 | self.do_test_requests( |
668 | 727 | "bedrock/getguardrail/get-guardrail", |
|
0 commit comments