Sagemaker
sagemaker
SageMakerEndpoint
SageMakerEndpoint(endpoint_name, model_id, generated_text_jmespath='generated_text', input_text_jmespath='inputs', token_count_jmespath='details.generated_tokens', region=None, boto3_session=None, **kwargs)
Bases: SageMakerBase
A class for handling invocations to a SageMaker endpoint.
This class extends SageMakerBase to provide functionality for invoking a SageMaker endpoint and parsing its response.
Source code in llmeter/endpoints/sagemaker.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
invoke
invoke(payload)
Invoke the SageMaker endpoint with the given payload.
This method sends a request to the SageMaker endpoint, processes the response, and returns an InvocationResponse object with the results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
Dict
|
The input payload for the model. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
InvocationResponse |
InvocationResponse
|
An object containing the model's response and associated metrics. |
Raises:
| Type | Description |
|---|---|
ClientError
|
If there's an error during the invocation of the SageMaker endpoint. |
Exception
|
If there's any other error during the invocation or parsing of the response. |
Source code in llmeter/endpoints/sagemaker.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
SageMakerStreamEndpoint
SageMakerStreamEndpoint(endpoint_name, model_id, generated_text_jmespath='generated_text', input_text_jmespath='inputs', token_count_jmespath='details.generated_tokens', region=None, boto3_session=None, **kwargs)
Bases: SageMakerBase
A class for handling streaming invocations to a SageMaker endpoint.
This class extends SageMakerBase to provide functionality specific to streaming responses from a SageMaker endpoint.
Source code in llmeter/endpoints/sagemaker.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
invoke
invoke(payload)
Invoke a SageMaker endpoint with the given payload.
This method sends a request to the SageMaker endpoint and handles the streaming response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
Dict
|
The input payload for the model. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
InvocationResponse |
InvocationResponse
|
An object containing the model's response and metrics. |
Raises:
| Type | Description |
|---|---|
Exception
|
If there's an error during the invocation or parsing of the response. |
Source code in llmeter/endpoints/sagemaker.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |