|
| 1 | +// smithy-typescript generated code |
| 2 | +import { getEventStreamPlugin } from "@aws-sdk/middleware-eventstream"; |
| 3 | +import { getEndpointPlugin } from "@smithy/middleware-endpoint"; |
| 4 | +import { getSerdePlugin } from "@smithy/middleware-serde"; |
| 5 | +import { Command as $Command } from "@smithy/smithy-client"; |
| 6 | +import { MetadataBearer as __MetadataBearer } from "@smithy/types"; |
| 7 | + |
| 8 | +import { BedrockRuntimeClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../BedrockRuntimeClient"; |
| 9 | +import { commonParams } from "../endpoint/EndpointParameters"; |
| 10 | +import { |
| 11 | + InvokeModelWithBidirectionalStreamRequest, |
| 12 | + InvokeModelWithBidirectionalStreamRequestFilterSensitiveLog, |
| 13 | + InvokeModelWithBidirectionalStreamResponse, |
| 14 | + InvokeModelWithBidirectionalStreamResponseFilterSensitiveLog, |
| 15 | +} from "../models/models_0"; |
| 16 | +import { |
| 17 | + de_InvokeModelWithBidirectionalStreamCommand, |
| 18 | + se_InvokeModelWithBidirectionalStreamCommand, |
| 19 | +} from "../protocols/Aws_restJson1"; |
| 20 | + |
| 21 | +/** |
| 22 | + * @public |
| 23 | + */ |
| 24 | +export type { __MetadataBearer }; |
| 25 | +export { $Command }; |
| 26 | +/** |
| 27 | + * @public |
| 28 | + * |
| 29 | + * The input for {@link InvokeModelWithBidirectionalStreamCommand}. |
| 30 | + */ |
| 31 | +export interface InvokeModelWithBidirectionalStreamCommandInput extends InvokeModelWithBidirectionalStreamRequest {} |
| 32 | +/** |
| 33 | + * @public |
| 34 | + * |
| 35 | + * The output of {@link InvokeModelWithBidirectionalStreamCommand}. |
| 36 | + */ |
| 37 | +export interface InvokeModelWithBidirectionalStreamCommandOutput |
| 38 | + extends InvokeModelWithBidirectionalStreamResponse, |
| 39 | + __MetadataBearer {} |
| 40 | + |
| 41 | +/** |
| 42 | + * <p>Invoke the specified Amazon Bedrock model to run inference using the bidirectional stream. The response is returned in a stream that remains open for 8 minutes. A single session can contain multiple prompts and responses from the model. The prompts to the model are provided as audio files and the model's responses are spoken back to the user and transcribed.</p> |
| 43 | + * <p>It is possible for users to interrupt the model's response with a new prompt, which will halt the response speech. The model will retain contextual awareness of the conversation while pivoting to respond to the new prompt.</p> |
| 44 | + * @example |
| 45 | + * Use a bare-bones client and the command you need to make an API call. |
| 46 | + * ```javascript |
| 47 | + * import { BedrockRuntimeClient, InvokeModelWithBidirectionalStreamCommand } from "@aws-sdk/client-bedrock-runtime"; // ES Modules import |
| 48 | + * // const { BedrockRuntimeClient, InvokeModelWithBidirectionalStreamCommand } = require("@aws-sdk/client-bedrock-runtime"); // CommonJS import |
| 49 | + * const client = new BedrockRuntimeClient(config); |
| 50 | + * const input = { // InvokeModelWithBidirectionalStreamRequest |
| 51 | + * modelId: "STRING_VALUE", // required |
| 52 | + * body: { // InvokeModelWithBidirectionalStreamInput Union: only one key present |
| 53 | + * chunk: { // BidirectionalInputPayloadPart |
| 54 | + * bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("") |
| 55 | + * }, |
| 56 | + * }, |
| 57 | + * }; |
| 58 | + * const command = new InvokeModelWithBidirectionalStreamCommand(input); |
| 59 | + * const response = await client.send(command); |
| 60 | + * // { // InvokeModelWithBidirectionalStreamResponse |
| 61 | + * // body: { // InvokeModelWithBidirectionalStreamOutput Union: only one key present |
| 62 | + * // chunk: { // BidirectionalOutputPayloadPart |
| 63 | + * // bytes: new Uint8Array(), |
| 64 | + * // }, |
| 65 | + * // internalServerException: { // InternalServerException |
| 66 | + * // message: "STRING_VALUE", |
| 67 | + * // }, |
| 68 | + * // modelStreamErrorException: { // ModelStreamErrorException |
| 69 | + * // message: "STRING_VALUE", |
| 70 | + * // originalStatusCode: Number("int"), |
| 71 | + * // originalMessage: "STRING_VALUE", |
| 72 | + * // }, |
| 73 | + * // validationException: { // ValidationException |
| 74 | + * // message: "STRING_VALUE", |
| 75 | + * // }, |
| 76 | + * // throttlingException: { // ThrottlingException |
| 77 | + * // message: "STRING_VALUE", |
| 78 | + * // }, |
| 79 | + * // modelTimeoutException: { // ModelTimeoutException |
| 80 | + * // message: "STRING_VALUE", |
| 81 | + * // }, |
| 82 | + * // serviceUnavailableException: { // ServiceUnavailableException |
| 83 | + * // message: "STRING_VALUE", |
| 84 | + * // }, |
| 85 | + * // }, |
| 86 | + * // }; |
| 87 | + * |
| 88 | + * ``` |
| 89 | + * |
| 90 | + * @param InvokeModelWithBidirectionalStreamCommandInput - {@link InvokeModelWithBidirectionalStreamCommandInput} |
| 91 | + * @returns {@link InvokeModelWithBidirectionalStreamCommandOutput} |
| 92 | + * @see {@link InvokeModelWithBidirectionalStreamCommandInput} for command's `input` shape. |
| 93 | + * @see {@link InvokeModelWithBidirectionalStreamCommandOutput} for command's `response` shape. |
| 94 | + * @see {@link BedrockRuntimeClientResolvedConfig | config} for BedrockRuntimeClient's `config` shape. |
| 95 | + * |
| 96 | + * @throws {@link AccessDeniedException} (client fault) |
| 97 | + * <p>The request is denied because you do not have sufficient permissions to perform the requested action. For troubleshooting this error, |
| 98 | + * see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html#ts-access-denied">AccessDeniedException</a> in the Amazon Bedrock User Guide</p> |
| 99 | + * |
| 100 | + * @throws {@link InternalServerException} (server fault) |
| 101 | + * <p>An internal server error occurred. For troubleshooting this error, |
| 102 | + * see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html#ts-internal-failure">InternalFailure</a> in the Amazon Bedrock User Guide</p> |
| 103 | + * |
| 104 | + * @throws {@link ModelErrorException} (client fault) |
| 105 | + * <p>The request failed due to an error while processing the model.</p> |
| 106 | + * |
| 107 | + * @throws {@link ModelNotReadyException} (client fault) |
| 108 | + * <p>The model specified in the request is not ready to serve inference requests. The AWS SDK |
| 109 | + * will automatically retry the operation up to 5 times. For information about configuring |
| 110 | + * automatic retries, see <a href="https://docs.aws.amazon.com/sdkref/latest/guide/feature-retry-behavior.html">Retry behavior</a> in the <i>AWS SDKs and Tools</i> |
| 111 | + * reference guide.</p> |
| 112 | + * |
| 113 | + * @throws {@link ModelStreamErrorException} (client fault) |
| 114 | + * <p>An error occurred while streaming the response. Retry your request.</p> |
| 115 | + * |
| 116 | + * @throws {@link ModelTimeoutException} (client fault) |
| 117 | + * <p>The request took too long to process. Processing time exceeded the model timeout length.</p> |
| 118 | + * |
| 119 | + * @throws {@link ResourceNotFoundException} (client fault) |
| 120 | + * <p>The specified resource ARN was not found. For troubleshooting this error, |
| 121 | + * see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html#ts-resource-not-found">ResourceNotFound</a> in the Amazon Bedrock User Guide</p> |
| 122 | + * |
| 123 | + * @throws {@link ServiceQuotaExceededException} (client fault) |
| 124 | + * <p>Your request exceeds the service quota for your account. You can view your quotas at <a href="https://docs.aws.amazon.com/servicequotas/latest/userguide/gs-request-quota.html">Viewing service quotas</a>. You can resubmit your request later.</p> |
| 125 | + * |
| 126 | + * @throws {@link ServiceUnavailableException} (server fault) |
| 127 | + * <p>The service isn't currently available. For troubleshooting this error, |
| 128 | + * see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html#ts-service-unavailable">ServiceUnavailable</a> in the Amazon Bedrock User Guide</p> |
| 129 | + * |
| 130 | + * @throws {@link ThrottlingException} (client fault) |
| 131 | + * <p>Your request was denied due to exceeding the account quotas for <i>Amazon Bedrock</i>. For |
| 132 | + * troubleshooting this error, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html#ts-throttling-exception">ThrottlingException</a> in the Amazon Bedrock User Guide</p> |
| 133 | + * |
| 134 | + * @throws {@link ValidationException} (client fault) |
| 135 | + * <p>The input fails to satisfy the constraints specified by <i>Amazon Bedrock</i>. For troubleshooting this error, |
| 136 | + * see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html#ts-validation-error">ValidationError</a> in the Amazon Bedrock User Guide</p> |
| 137 | + * |
| 138 | + * @throws {@link BedrockRuntimeServiceException} |
| 139 | + * <p>Base exception class for all service exceptions from BedrockRuntime service.</p> |
| 140 | + * |
| 141 | + * |
| 142 | + * @public |
| 143 | + */ |
| 144 | +export class InvokeModelWithBidirectionalStreamCommand extends $Command |
| 145 | + .classBuilder< |
| 146 | + InvokeModelWithBidirectionalStreamCommandInput, |
| 147 | + InvokeModelWithBidirectionalStreamCommandOutput, |
| 148 | + BedrockRuntimeClientResolvedConfig, |
| 149 | + ServiceInputTypes, |
| 150 | + ServiceOutputTypes |
| 151 | + >() |
| 152 | + .ep(commonParams) |
| 153 | + .m(function (this: any, Command: any, cs: any, config: BedrockRuntimeClientResolvedConfig, o: any) { |
| 154 | + return [ |
| 155 | + getSerdePlugin(config, this.serialize, this.deserialize), |
| 156 | + getEndpointPlugin(config, Command.getEndpointParameterInstructions()), |
| 157 | + getEventStreamPlugin(config), |
| 158 | + ]; |
| 159 | + }) |
| 160 | + .s("AmazonBedrockFrontendService", "InvokeModelWithBidirectionalStream", { |
| 161 | + /** |
| 162 | + * @internal |
| 163 | + */ |
| 164 | + eventStream: { |
| 165 | + input: true, |
| 166 | + output: true, |
| 167 | + }, |
| 168 | + }) |
| 169 | + .n("BedrockRuntimeClient", "InvokeModelWithBidirectionalStreamCommand") |
| 170 | + .f( |
| 171 | + InvokeModelWithBidirectionalStreamRequestFilterSensitiveLog, |
| 172 | + InvokeModelWithBidirectionalStreamResponseFilterSensitiveLog |
| 173 | + ) |
| 174 | + .ser(se_InvokeModelWithBidirectionalStreamCommand) |
| 175 | + .de(de_InvokeModelWithBidirectionalStreamCommand) |
| 176 | + .build() { |
| 177 | + /** @internal type navigation helper, not in runtime. */ |
| 178 | + protected declare static __types: { |
| 179 | + api: { |
| 180 | + input: InvokeModelWithBidirectionalStreamRequest; |
| 181 | + output: InvokeModelWithBidirectionalStreamResponse; |
| 182 | + }; |
| 183 | + sdk: { |
| 184 | + input: InvokeModelWithBidirectionalStreamCommandInput; |
| 185 | + output: InvokeModelWithBidirectionalStreamCommandOutput; |
| 186 | + }; |
| 187 | + }; |
| 188 | +} |
0 commit comments