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[InvokeEndpointOutputTypeDef]
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
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
create_payload
staticmethod
create_payload(input_text, max_tokens=256, inference_parameters={}, **kwargs)
Create a payload for the SageMaker API request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_text
|
str | list[ContentItem]
|
A single text string, or an ordered list mixing strings
and :class: |
required |
max_tokens
|
int
|
Maximum tokens to generate. Defaults to 256. |
256
|
inference_parameters
|
dict
|
Additional inference parameters. |
{}
|
**kwargs
|
Additional keyword arguments to include in the payload. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The formatted payload for the SageMaker API request. |
Source code in llmeter/endpoints/sagemaker.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
invoke
invoke(payload)
Invoke the SageMaker endpoint with the given payload.
Source code in llmeter/endpoints/sagemaker.py
195 196 197 198 199 200 201 202 203 204 205 | |
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[InvokeEndpointWithResponseStreamOutputTypeDef]
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
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
create_payload
staticmethod
create_payload(input_text, max_tokens=256, inference_parameters={}, **kwargs)
Create a payload for the SageMaker streaming API request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_text
|
str | list[ContentItem]
|
A single text string, or an ordered list mixing strings
and :class: |
required |
max_tokens
|
int
|
Maximum tokens to generate. Defaults to 256. |
256
|
inference_parameters
|
dict
|
Additional inference parameters. |
{}
|
**kwargs
|
Additional keyword arguments to include in the payload. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The formatted payload for the SageMaker streaming API request. |
Source code in llmeter/endpoints/sagemaker.py
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | |
invoke
invoke(payload)
Invoke a SageMaker streaming endpoint with the given payload.
Source code in llmeter/endpoints/sagemaker.py
244 245 246 247 248 249 250 251 252 253 254 | |