|
12 | 12 | import javax.annotation.Nullable; |
13 | 13 | import software.amazon.awssdk.core.SdkRequest; |
14 | 14 | import software.amazon.awssdk.core.SdkResponse; |
| 15 | +import software.amazon.awssdk.core.interceptor.ExecutionAttributes; |
15 | 16 |
|
16 | 17 | final class BedrockRuntimeAccess { |
17 | 18 | private BedrockRuntimeAccess() {} |
@@ -44,72 +45,99 @@ static boolean isBedrockRuntimeResponse(SdkResponse response) { |
44 | 45 | return enabled && BedrockRuntimeImpl.isBedrockRuntimeResponse(response); |
45 | 46 | } |
46 | 47 |
|
| 48 | + @NoMuzzle |
| 49 | + static void maybeParseInvokeModelRequest( |
| 50 | + ExecutionAttributes executionAttributes, SdkRequest request) { |
| 51 | + if (enabled) { |
| 52 | + BedrockRuntimeImpl.maybeParseInvokeModelRequest(executionAttributes, request); |
| 53 | + } |
| 54 | + } |
| 55 | + |
| 56 | + @NoMuzzle |
| 57 | + static void maybeParseInvokeModelResponse( |
| 58 | + ExecutionAttributes executionAttributes, SdkResponse response) { |
| 59 | + if (enabled) { |
| 60 | + BedrockRuntimeImpl.maybeParseInvokeModelResponse(executionAttributes, response); |
| 61 | + } |
| 62 | + } |
| 63 | + |
| 64 | + @Nullable |
| 65 | + @NoMuzzle |
| 66 | + static String getModelId(ExecutionAttributes executionAttributes) { |
| 67 | + return enabled ? BedrockRuntimeImpl.getModelId(executionAttributes) : null; |
| 68 | + } |
| 69 | + |
47 | 70 | @Nullable |
48 | 71 | @NoMuzzle |
49 | | - static String getModelId(SdkRequest request) { |
50 | | - return enabled ? BedrockRuntimeImpl.getModelId(request) : null; |
| 72 | + static String getOperationName(ExecutionAttributes executionAttributes) { |
| 73 | + return enabled ? BedrockRuntimeImpl.getOperationName(executionAttributes) : null; |
51 | 74 | } |
52 | 75 |
|
53 | 76 | @Nullable |
54 | 77 | @NoMuzzle |
55 | | - static Long getMaxTokens(SdkRequest request) { |
56 | | - return enabled ? BedrockRuntimeImpl.getMaxTokens(request) : null; |
| 78 | + static Long getMaxTokens(ExecutionAttributes executionAttributes) { |
| 79 | + return enabled ? BedrockRuntimeImpl.getMaxTokens(executionAttributes) : null; |
57 | 80 | } |
58 | 81 |
|
59 | 82 | @Nullable |
60 | 83 | @NoMuzzle |
61 | | - static Double getTemperature(SdkRequest request) { |
62 | | - return enabled ? BedrockRuntimeImpl.getTemperature(request) : null; |
| 84 | + static Double getTemperature(ExecutionAttributes executionAttributes) { |
| 85 | + return enabled ? BedrockRuntimeImpl.getTemperature(executionAttributes) : null; |
63 | 86 | } |
64 | 87 |
|
65 | 88 | @Nullable |
66 | 89 | @NoMuzzle |
67 | | - static Double getTopP(SdkRequest request) { |
68 | | - return enabled ? BedrockRuntimeImpl.getTopP(request) : null; |
| 90 | + static Double getTopP(ExecutionAttributes executionAttributes) { |
| 91 | + return enabled ? BedrockRuntimeImpl.getTopP(executionAttributes) : null; |
69 | 92 | } |
70 | 93 |
|
71 | 94 | @Nullable |
72 | 95 | @NoMuzzle |
73 | | - static List<String> getStopSequences(SdkRequest request) { |
74 | | - return enabled ? BedrockRuntimeImpl.getStopSequences(request) : null; |
| 96 | + static List<String> getStopSequences(ExecutionAttributes executionAttributes) { |
| 97 | + return enabled ? BedrockRuntimeImpl.getStopSequences(executionAttributes) : null; |
75 | 98 | } |
76 | 99 |
|
77 | 100 | @Nullable |
78 | 101 | @NoMuzzle |
79 | | - static List<String> getStopReasons(Response response) { |
80 | | - return enabled ? BedrockRuntimeImpl.getStopReasons(response) : null; |
| 102 | + static List<String> getStopReasons(ExecutionAttributes executionAttributes, Response response) { |
| 103 | + return enabled ? BedrockRuntimeImpl.getStopReasons(executionAttributes, response) : null; |
81 | 104 | } |
82 | 105 |
|
83 | 106 | @Nullable |
84 | 107 | @NoMuzzle |
85 | | - static Long getUsageInputTokens(Response response) { |
86 | | - return enabled ? BedrockRuntimeImpl.getUsageInputTokens(response) : null; |
| 108 | + static Long getUsageInputTokens(ExecutionAttributes executionAttributes, Response response) { |
| 109 | + return enabled ? BedrockRuntimeImpl.getUsageInputTokens(executionAttributes, response) : null; |
87 | 110 | } |
88 | 111 |
|
89 | 112 | @Nullable |
90 | 113 | @NoMuzzle |
91 | | - static Long getUsageOutputTokens(Response response) { |
92 | | - return enabled ? BedrockRuntimeImpl.getUsageOutputTokens(response) : null; |
| 114 | + static Long getUsageOutputTokens(ExecutionAttributes executionAttributes, Response response) { |
| 115 | + return enabled ? BedrockRuntimeImpl.getUsageOutputTokens(executionAttributes, response) : null; |
93 | 116 | } |
94 | 117 |
|
95 | 118 | @NoMuzzle |
96 | 119 | static void recordRequestEvents( |
97 | | - Context otelContext, Logger eventLogger, SdkRequest request, boolean captureMessageContent) { |
| 120 | + Context otelContext, |
| 121 | + Logger eventLogger, |
| 122 | + ExecutionAttributes executionAttributes, |
| 123 | + SdkRequest request, |
| 124 | + boolean captureMessageContent) { |
98 | 125 | if (enabled) { |
99 | 126 | BedrockRuntimeImpl.recordRequestEvents( |
100 | | - otelContext, eventLogger, request, captureMessageContent); |
| 127 | + otelContext, eventLogger, executionAttributes, request, captureMessageContent); |
101 | 128 | } |
102 | 129 | } |
103 | 130 |
|
104 | 131 | @NoMuzzle |
105 | 132 | static void recordResponseEvents( |
106 | 133 | Context otelContext, |
107 | 134 | Logger eventLogger, |
| 135 | + ExecutionAttributes executionAttributes, |
108 | 136 | SdkResponse response, |
109 | 137 | boolean captureMessageContent) { |
110 | 138 | if (enabled) { |
111 | 139 | BedrockRuntimeImpl.recordResponseEvents( |
112 | | - otelContext, eventLogger, response, captureMessageContent); |
| 140 | + otelContext, eventLogger, executionAttributes, response, captureMessageContent); |
113 | 141 | } |
114 | 142 | } |
115 | 143 | } |
0 commit comments