From 428953bfa29cdada94fc1895d1ecd336d4698f6e Mon Sep 17 00:00:00 2001 From: awstools Date: Tue, 28 Nov 2023 19:07:17 +0000 Subject: [PATCH] feat(client-bedrock-agent-runtime): This release introduces Agents for Amazon Bedrock Runtime --- .../client-bedrock-agent-runtime/.gitignore | 9 + clients/client-bedrock-agent-runtime/LICENSE | 201 ++ .../client-bedrock-agent-runtime/README.md | 229 ++ .../api-extractor.json | 4 + .../client-bedrock-agent-runtime/package.json | 105 + .../src/BedrockAgentRuntime.ts | 66 + .../src/BedrockAgentRuntimeClient.ts | 308 +++ .../src/commands/InvokeAgentCommand.ts | 398 +++ .../commands/RetrieveAndGenerateCommand.ts | 217 ++ .../src/commands/RetrieveCommand.ts | 196 ++ .../src/commands/index.ts | 4 + .../src/endpoint/EndpointParameters.ts | 34 + .../src/endpoint/endpointResolver.ts | 16 + .../src/endpoint/ruleset.ts | 32 + .../src/extensionConfiguration.ts | 12 + .../client-bedrock-agent-runtime/src/index.ts | 19 + .../BedrockAgentRuntimeServiceException.ts | 22 + .../src/models/index.ts | 2 + .../src/models/models_0.ts | 2056 ++++++++++++++ .../src/pagination/Interfaces.ts | 11 + .../src/pagination/RetrievePaginator.ts | 45 + .../src/pagination/index.ts | 3 + .../src/protocols/Aws_restJson1.ts | 1039 +++++++ .../src/runtimeConfig.browser.ts | 46 + .../src/runtimeConfig.native.ts | 18 + .../src/runtimeConfig.shared.ts | 27 + .../src/runtimeConfig.ts | 63 + .../src/runtimeExtensions.ts | 45 + .../tsconfig.cjs.json | 6 + .../tsconfig.es.json | 8 + .../tsconfig.json | 13 + .../tsconfig.types.json | 10 + .../client-bedrock-agent-runtime/typedoc.json | 6 + .../aws-models/bedrock-agent-runtime.json | 2454 +++++++++++++++++ 34 files changed, 7724 insertions(+) create mode 100644 clients/client-bedrock-agent-runtime/.gitignore create mode 100644 clients/client-bedrock-agent-runtime/LICENSE create mode 100644 clients/client-bedrock-agent-runtime/README.md create mode 100644 clients/client-bedrock-agent-runtime/api-extractor.json create mode 100644 clients/client-bedrock-agent-runtime/package.json create mode 100644 clients/client-bedrock-agent-runtime/src/BedrockAgentRuntime.ts create mode 100644 clients/client-bedrock-agent-runtime/src/BedrockAgentRuntimeClient.ts create mode 100644 clients/client-bedrock-agent-runtime/src/commands/InvokeAgentCommand.ts create mode 100644 clients/client-bedrock-agent-runtime/src/commands/RetrieveAndGenerateCommand.ts create mode 100644 clients/client-bedrock-agent-runtime/src/commands/RetrieveCommand.ts create mode 100644 clients/client-bedrock-agent-runtime/src/commands/index.ts create mode 100644 clients/client-bedrock-agent-runtime/src/endpoint/EndpointParameters.ts create mode 100644 clients/client-bedrock-agent-runtime/src/endpoint/endpointResolver.ts create mode 100644 clients/client-bedrock-agent-runtime/src/endpoint/ruleset.ts create mode 100644 clients/client-bedrock-agent-runtime/src/extensionConfiguration.ts create mode 100644 clients/client-bedrock-agent-runtime/src/index.ts create mode 100644 clients/client-bedrock-agent-runtime/src/models/BedrockAgentRuntimeServiceException.ts create mode 100644 clients/client-bedrock-agent-runtime/src/models/index.ts create mode 100644 clients/client-bedrock-agent-runtime/src/models/models_0.ts create mode 100644 clients/client-bedrock-agent-runtime/src/pagination/Interfaces.ts create mode 100644 clients/client-bedrock-agent-runtime/src/pagination/RetrievePaginator.ts create mode 100644 clients/client-bedrock-agent-runtime/src/pagination/index.ts create mode 100644 clients/client-bedrock-agent-runtime/src/protocols/Aws_restJson1.ts create mode 100644 clients/client-bedrock-agent-runtime/src/runtimeConfig.browser.ts create mode 100644 clients/client-bedrock-agent-runtime/src/runtimeConfig.native.ts create mode 100644 clients/client-bedrock-agent-runtime/src/runtimeConfig.shared.ts create mode 100644 clients/client-bedrock-agent-runtime/src/runtimeConfig.ts create mode 100644 clients/client-bedrock-agent-runtime/src/runtimeExtensions.ts create mode 100644 clients/client-bedrock-agent-runtime/tsconfig.cjs.json create mode 100644 clients/client-bedrock-agent-runtime/tsconfig.es.json create mode 100644 clients/client-bedrock-agent-runtime/tsconfig.json create mode 100644 clients/client-bedrock-agent-runtime/tsconfig.types.json create mode 100644 clients/client-bedrock-agent-runtime/typedoc.json create mode 100644 codegen/sdk-codegen/aws-models/bedrock-agent-runtime.json diff --git a/clients/client-bedrock-agent-runtime/.gitignore b/clients/client-bedrock-agent-runtime/.gitignore new file mode 100644 index 000000000000..54f14c9aef25 --- /dev/null +++ b/clients/client-bedrock-agent-runtime/.gitignore @@ -0,0 +1,9 @@ +/node_modules/ +/build/ +/coverage/ +/docs/ +/dist-* +*.tsbuildinfo +*.tgz +*.log +package-lock.json diff --git a/clients/client-bedrock-agent-runtime/LICENSE b/clients/client-bedrock-agent-runtime/LICENSE new file mode 100644 index 000000000000..5001cd317c44 --- /dev/null +++ b/clients/client-bedrock-agent-runtime/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2018-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/clients/client-bedrock-agent-runtime/README.md b/clients/client-bedrock-agent-runtime/README.md new file mode 100644 index 000000000000..2e6a9341114e --- /dev/null +++ b/clients/client-bedrock-agent-runtime/README.md @@ -0,0 +1,229 @@ + + +# @aws-sdk/client-bedrock-agent-runtime + +## Description + +AWS SDK for JavaScript BedrockAgentRuntime Client for Node.js, Browser and React Native. + +Amazon Bedrock Agent + +## Installing + +To install the this package, simply type add or install @aws-sdk/client-bedrock-agent-runtime +using your favorite package manager: + +- `npm install @aws-sdk/client-bedrock-agent-runtime` +- `yarn add @aws-sdk/client-bedrock-agent-runtime` +- `pnpm add @aws-sdk/client-bedrock-agent-runtime` + +## Getting Started + +### Import + +The AWS SDK is modulized by clients and commands. +To send a request, you only need to import the `BedrockAgentRuntimeClient` and +the commands you need, for example `RetrieveCommand`: + +```js +// ES5 example +const { BedrockAgentRuntimeClient, RetrieveCommand } = require("@aws-sdk/client-bedrock-agent-runtime"); +``` + +```ts +// ES6+ example +import { BedrockAgentRuntimeClient, RetrieveCommand } from "@aws-sdk/client-bedrock-agent-runtime"; +``` + +### Usage + +To send a request, you: + +- Initiate client with configuration (e.g. credentials, region). +- Initiate command with input parameters. +- Call `send` operation on client with command object as input. +- If you are using a custom http handler, you may call `destroy()` to close open connections. + +```js +// a client can be shared by different commands. +const client = new BedrockAgentRuntimeClient({ region: "REGION" }); + +const params = { + /** input parameters */ +}; +const command = new RetrieveCommand(params); +``` + +#### Async/await + +We recommend using [await](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await) +operator to wait for the promise returned by send operation as follows: + +```js +// async/await. +try { + const data = await client.send(command); + // process data. +} catch (error) { + // error handling. +} finally { + // finally. +} +``` + +Async-await is clean, concise, intuitive, easy to debug and has better error handling +as compared to using Promise chains or callbacks. + +#### Promises + +You can also use [Promise chaining](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises#chaining) +to execute send operation. + +```js +client.send(command).then( + (data) => { + // process data. + }, + (error) => { + // error handling. + } +); +``` + +Promises can also be called using `.catch()` and `.finally()` as follows: + +```js +client + .send(command) + .then((data) => { + // process data. + }) + .catch((error) => { + // error handling. + }) + .finally(() => { + // finally. + }); +``` + +#### Callbacks + +We do not recommend using callbacks because of [callback hell](http://callbackhell.com/), +but they are supported by the send operation. + +```js +// callbacks. +client.send(command, (err, data) => { + // process err and data. +}); +``` + +#### v2 compatible style + +The client can also send requests using v2 compatible style. +However, it results in a bigger bundle size and may be dropped in next major version. More details in the blog post +on [modular packages in AWS SDK for JavaScript](https://aws.amazon.com/blogs/developer/modular-packages-in-aws-sdk-for-javascript/) + +```ts +import * as AWS from "@aws-sdk/client-bedrock-agent-runtime"; +const client = new AWS.BedrockAgentRuntime({ region: "REGION" }); + +// async/await. +try { + const data = await client.retrieve(params); + // process data. +} catch (error) { + // error handling. +} + +// Promises. +client + .retrieve(params) + .then((data) => { + // process data. + }) + .catch((error) => { + // error handling. + }); + +// callbacks. +client.retrieve(params, (err, data) => { + // process err and data. +}); +``` + +### Troubleshooting + +When the service returns an exception, the error will include the exception information, +as well as response metadata (e.g. request id). + +```js +try { + const data = await client.send(command); + // process data. +} catch (error) { + const { requestId, cfId, extendedRequestId } = error.$metadata; + console.log({ requestId, cfId, extendedRequestId }); + /** + * The keys within exceptions are also parsed. + * You can access them by specifying exception names: + * if (error.name === 'SomeServiceException') { + * const value = error.specialKeyInException; + * } + */ +} +``` + +## Getting Help + +Please use these community resources for getting help. +We use the GitHub issues for tracking bugs and feature requests, but have limited bandwidth to address them. + +- Visit [Developer Guide](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/welcome.html) + or [API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/index.html). +- Check out the blog posts tagged with [`aws-sdk-js`](https://aws.amazon.com/blogs/developer/tag/aws-sdk-js/) + on AWS Developer Blog. +- Ask a question on [StackOverflow](https://stackoverflow.com/questions/tagged/aws-sdk-js) and tag it with `aws-sdk-js`. +- Join the AWS JavaScript community on [gitter](https://gitter.im/aws/aws-sdk-js-v3). +- If it turns out that you may have found a bug, please [open an issue](https://github.com/aws/aws-sdk-js-v3/issues/new/choose). + +To test your universal JavaScript code in Node.js, browser and react-native environments, +visit our [code samples repo](https://github.com/aws-samples/aws-sdk-js-tests). + +## Contributing + +This client code is generated automatically. Any modifications will be overwritten the next time the `@aws-sdk/client-bedrock-agent-runtime` package is updated. +To contribute to client you can check our [generate clients scripts](https://github.com/aws/aws-sdk-js-v3/tree/main/scripts/generate-clients). + +## License + +This SDK is distributed under the +[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0), +see LICENSE for more information. + +## Client Commands (Operations List) + +
+ +InvokeAgent + + +[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/bedrock-agent-runtime/command/InvokeAgentCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-agent-runtime/Interface/InvokeAgentCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-agent-runtime/Interface/InvokeAgentCommandOutput/) + +
+
+ +Retrieve + + +[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/bedrock-agent-runtime/command/RetrieveCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-agent-runtime/Interface/RetrieveCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-agent-runtime/Interface/RetrieveCommandOutput/) + +
+
+ +RetrieveAndGenerate + + +[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/bedrock-agent-runtime/command/RetrieveAndGenerateCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-agent-runtime/Interface/RetrieveAndGenerateCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-agent-runtime/Interface/RetrieveAndGenerateCommandOutput/) + +
diff --git a/clients/client-bedrock-agent-runtime/api-extractor.json b/clients/client-bedrock-agent-runtime/api-extractor.json new file mode 100644 index 000000000000..d5bf5ffeee85 --- /dev/null +++ b/clients/client-bedrock-agent-runtime/api-extractor.json @@ -0,0 +1,4 @@ +{ + "extends": "../../api-extractor.json", + "mainEntryPointFilePath": "/dist-types/index.d.ts" +} diff --git a/clients/client-bedrock-agent-runtime/package.json b/clients/client-bedrock-agent-runtime/package.json new file mode 100644 index 000000000000..b33f14877822 --- /dev/null +++ b/clients/client-bedrock-agent-runtime/package.json @@ -0,0 +1,105 @@ +{ + "name": "@aws-sdk/client-bedrock-agent-runtime", + "description": "AWS SDK for JavaScript Bedrock Agent Runtime Client for Node.js, Browser and React Native", + "version": "3.0.0", + "scripts": { + "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'", + "build:cjs": "tsc -p tsconfig.cjs.json", + "build:docs": "typedoc", + "build:es": "tsc -p tsconfig.es.json", + "build:include:deps": "lerna run --scope $npm_package_name --include-dependencies build", + "build:types": "tsc -p tsconfig.types.json", + "build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4", + "clean": "rimraf ./dist-* && rimraf *.tsbuildinfo", + "extract:docs": "api-extractor run --local", + "generate:client": "node ../../scripts/generate-clients/single-service --solo bedrock-agent-runtime" + }, + "main": "./dist-cjs/index.js", + "types": "./dist-types/index.d.ts", + "module": "./dist-es/index.js", + "sideEffects": false, + "dependencies": { + "@aws-crypto/sha256-browser": "3.0.0", + "@aws-crypto/sha256-js": "3.0.0", + "@aws-sdk/client-sts": "*", + "@aws-sdk/core": "*", + "@aws-sdk/credential-provider-node": "*", + "@aws-sdk/middleware-host-header": "*", + "@aws-sdk/middleware-logger": "*", + "@aws-sdk/middleware-recursion-detection": "*", + "@aws-sdk/middleware-signing": "*", + "@aws-sdk/middleware-user-agent": "*", + "@aws-sdk/region-config-resolver": "*", + "@aws-sdk/types": "*", + "@aws-sdk/util-endpoints": "*", + "@aws-sdk/util-user-agent-browser": "*", + "@aws-sdk/util-user-agent-node": "*", + "@smithy/config-resolver": "^2.0.18", + "@smithy/eventstream-serde-browser": "^2.0.13", + "@smithy/eventstream-serde-config-resolver": "^2.0.13", + "@smithy/eventstream-serde-node": "^2.0.13", + "@smithy/fetch-http-handler": "^2.2.6", + "@smithy/hash-node": "^2.0.15", + "@smithy/invalid-dependency": "^2.0.13", + "@smithy/middleware-content-length": "^2.0.15", + "@smithy/middleware-endpoint": "^2.2.0", + "@smithy/middleware-retry": "^2.0.20", + "@smithy/middleware-serde": "^2.0.13", + "@smithy/middleware-stack": "^2.0.7", + "@smithy/node-config-provider": "^2.1.5", + "@smithy/node-http-handler": "^2.1.9", + "@smithy/protocol-http": "^3.0.9", + "@smithy/smithy-client": "^2.1.15", + "@smithy/types": "^2.5.0", + "@smithy/url-parser": "^2.0.13", + "@smithy/util-base64": "^2.0.1", + "@smithy/util-body-length-browser": "^2.0.0", + "@smithy/util-body-length-node": "^2.1.0", + "@smithy/util-defaults-mode-browser": "^2.0.19", + "@smithy/util-defaults-mode-node": "^2.0.25", + "@smithy/util-endpoints": "^1.0.4", + "@smithy/util-retry": "^2.0.6", + "@smithy/util-utf8": "^2.0.2", + "tslib": "^2.5.0" + }, + "devDependencies": { + "@smithy/service-client-documentation-generator": "^2.0.0", + "@tsconfig/node14": "1.0.3", + "@types/node": "^14.14.31", + "concurrently": "7.0.0", + "downlevel-dts": "0.10.1", + "rimraf": "3.0.2", + "typedoc": "0.23.23", + "typescript": "~4.9.5" + }, + "engines": { + "node": ">=14.0.0" + }, + "typesVersions": { + "<4.0": { + "dist-types/*": [ + "dist-types/ts3.4/*" + ] + } + }, + "files": [ + "dist-*/**" + ], + "author": { + "name": "AWS SDK for JavaScript Team", + "url": "https://aws.amazon.com/javascript/" + }, + "license": "Apache-2.0", + "browser": { + "./dist-es/runtimeConfig": "./dist-es/runtimeConfig.browser" + }, + "react-native": { + "./dist-es/runtimeConfig": "./dist-es/runtimeConfig.native" + }, + "homepage": "https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-bedrock-agent-runtime", + "repository": { + "type": "git", + "url": "https://github.com/aws/aws-sdk-js-v3.git", + "directory": "clients/client-bedrock-agent-runtime" + } +} diff --git a/clients/client-bedrock-agent-runtime/src/BedrockAgentRuntime.ts b/clients/client-bedrock-agent-runtime/src/BedrockAgentRuntime.ts new file mode 100644 index 000000000000..d9d65d1c6858 --- /dev/null +++ b/clients/client-bedrock-agent-runtime/src/BedrockAgentRuntime.ts @@ -0,0 +1,66 @@ +// smithy-typescript generated code +import { createAggregatedClient } from "@smithy/smithy-client"; +import { HttpHandlerOptions as __HttpHandlerOptions } from "@smithy/types"; + +import { BedrockAgentRuntimeClient, BedrockAgentRuntimeClientConfig } from "./BedrockAgentRuntimeClient"; +import { InvokeAgentCommand, InvokeAgentCommandInput, InvokeAgentCommandOutput } from "./commands/InvokeAgentCommand"; +import { + RetrieveAndGenerateCommand, + RetrieveAndGenerateCommandInput, + RetrieveAndGenerateCommandOutput, +} from "./commands/RetrieveAndGenerateCommand"; +import { RetrieveCommand, RetrieveCommandInput, RetrieveCommandOutput } from "./commands/RetrieveCommand"; + +const commands = { + InvokeAgentCommand, + RetrieveCommand, + RetrieveAndGenerateCommand, +}; + +export interface BedrockAgentRuntime { + /** + * @see {@link InvokeAgentCommand} + */ + invokeAgent(args: InvokeAgentCommandInput, options?: __HttpHandlerOptions): Promise; + invokeAgent(args: InvokeAgentCommandInput, cb: (err: any, data?: InvokeAgentCommandOutput) => void): void; + invokeAgent( + args: InvokeAgentCommandInput, + options: __HttpHandlerOptions, + cb: (err: any, data?: InvokeAgentCommandOutput) => void + ): void; + + /** + * @see {@link RetrieveCommand} + */ + retrieve(args: RetrieveCommandInput, options?: __HttpHandlerOptions): Promise; + retrieve(args: RetrieveCommandInput, cb: (err: any, data?: RetrieveCommandOutput) => void): void; + retrieve( + args: RetrieveCommandInput, + options: __HttpHandlerOptions, + cb: (err: any, data?: RetrieveCommandOutput) => void + ): void; + + /** + * @see {@link RetrieveAndGenerateCommand} + */ + retrieveAndGenerate( + args: RetrieveAndGenerateCommandInput, + options?: __HttpHandlerOptions + ): Promise; + retrieveAndGenerate( + args: RetrieveAndGenerateCommandInput, + cb: (err: any, data?: RetrieveAndGenerateCommandOutput) => void + ): void; + retrieveAndGenerate( + args: RetrieveAndGenerateCommandInput, + options: __HttpHandlerOptions, + cb: (err: any, data?: RetrieveAndGenerateCommandOutput) => void + ): void; +} + +/** + * @public + * Amazon Bedrock Agent + */ +export class BedrockAgentRuntime extends BedrockAgentRuntimeClient implements BedrockAgentRuntime {} +createAggregatedClient(commands, BedrockAgentRuntime); diff --git a/clients/client-bedrock-agent-runtime/src/BedrockAgentRuntimeClient.ts b/clients/client-bedrock-agent-runtime/src/BedrockAgentRuntimeClient.ts new file mode 100644 index 000000000000..c9bdc66a010d --- /dev/null +++ b/clients/client-bedrock-agent-runtime/src/BedrockAgentRuntimeClient.ts @@ -0,0 +1,308 @@ +// smithy-typescript generated code +import { + getHostHeaderPlugin, + HostHeaderInputConfig, + HostHeaderResolvedConfig, + resolveHostHeaderConfig, +} from "@aws-sdk/middleware-host-header"; +import { getLoggerPlugin } from "@aws-sdk/middleware-logger"; +import { getRecursionDetectionPlugin } from "@aws-sdk/middleware-recursion-detection"; +import { + AwsAuthInputConfig, + AwsAuthResolvedConfig, + getAwsAuthPlugin, + resolveAwsAuthConfig, +} from "@aws-sdk/middleware-signing"; +import { + getUserAgentPlugin, + resolveUserAgentConfig, + UserAgentInputConfig, + UserAgentResolvedConfig, +} from "@aws-sdk/middleware-user-agent"; +import { Credentials as __Credentials } from "@aws-sdk/types"; +import { RegionInputConfig, RegionResolvedConfig, resolveRegionConfig } from "@smithy/config-resolver"; +import { + EventStreamSerdeInputConfig, + EventStreamSerdeResolvedConfig, + resolveEventStreamSerdeConfig, +} from "@smithy/eventstream-serde-config-resolver"; +import { getContentLengthPlugin } from "@smithy/middleware-content-length"; +import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint"; +import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry"; +import { HttpHandler as __HttpHandler } from "@smithy/protocol-http"; +import { + Client as __Client, + DefaultsMode as __DefaultsMode, + SmithyConfiguration as __SmithyConfiguration, + SmithyResolvedConfiguration as __SmithyResolvedConfiguration, +} from "@smithy/smithy-client"; +import { + BodyLengthCalculator as __BodyLengthCalculator, + CheckOptionalClientConfig as __CheckOptionalClientConfig, + Checksum as __Checksum, + ChecksumConstructor as __ChecksumConstructor, + Decoder as __Decoder, + Encoder as __Encoder, + EndpointV2 as __EndpointV2, + EventStreamSerdeProvider as __EventStreamSerdeProvider, + Hash as __Hash, + HashConstructor as __HashConstructor, + HttpHandlerOptions as __HttpHandlerOptions, + Logger as __Logger, + Provider as __Provider, + Provider, + StreamCollector as __StreamCollector, + UrlParser as __UrlParser, + UserAgent as __UserAgent, +} from "@smithy/types"; + +import { InvokeAgentCommandInput, InvokeAgentCommandOutput } from "./commands/InvokeAgentCommand"; +import { + RetrieveAndGenerateCommandInput, + RetrieveAndGenerateCommandOutput, +} from "./commands/RetrieveAndGenerateCommand"; +import { RetrieveCommandInput, RetrieveCommandOutput } from "./commands/RetrieveCommand"; +import { + ClientInputEndpointParameters, + ClientResolvedEndpointParameters, + EndpointParameters, + resolveClientEndpointParameters, +} from "./endpoint/EndpointParameters"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; +import { resolveRuntimeExtensions, RuntimeExtension, RuntimeExtensionsConfig } from "./runtimeExtensions"; + +export { __Client }; + +/** + * @public + */ +export type ServiceInputTypes = InvokeAgentCommandInput | RetrieveAndGenerateCommandInput | RetrieveCommandInput; + +/** + * @public + */ +export type ServiceOutputTypes = InvokeAgentCommandOutput | RetrieveAndGenerateCommandOutput | RetrieveCommandOutput; + +/** + * @public + */ +export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__HttpHandlerOptions>> { + /** + * The HTTP handler to use. Fetch in browser and Https in Nodejs. + */ + requestHandler?: __HttpHandler; + + /** + * A constructor for a class implementing the {@link @smithy/types#ChecksumConstructor} interface + * that computes the SHA-256 HMAC or checksum of a string or binary buffer. + * @internal + */ + sha256?: __ChecksumConstructor | __HashConstructor; + + /** + * The function that will be used to convert strings into HTTP endpoints. + * @internal + */ + urlParser?: __UrlParser; + + /** + * A function that can calculate the length of a request body. + * @internal + */ + bodyLengthChecker?: __BodyLengthCalculator; + + /** + * A function that converts a stream into an array of bytes. + * @internal + */ + streamCollector?: __StreamCollector; + + /** + * The function that will be used to convert a base64-encoded string to a byte array. + * @internal + */ + base64Decoder?: __Decoder; + + /** + * The function that will be used to convert binary data to a base64-encoded string. + * @internal + */ + base64Encoder?: __Encoder; + + /** + * The function that will be used to convert a UTF8-encoded string to a byte array. + * @internal + */ + utf8Decoder?: __Decoder; + + /** + * The function that will be used to convert binary data to a UTF-8 encoded string. + * @internal + */ + utf8Encoder?: __Encoder; + + /** + * The runtime environment. + * @internal + */ + runtime?: string; + + /** + * Disable dynamically changing the endpoint of the client based on the hostPrefix + * trait of an operation. + */ + disableHostPrefix?: boolean; + + /** + * Unique service identifier. + * @internal + */ + serviceId?: string; + + /** + * Enables IPv6/IPv4 dualstack endpoint. + */ + useDualstackEndpoint?: boolean | __Provider; + + /** + * Enables FIPS compatible endpoints. + */ + useFipsEndpoint?: boolean | __Provider; + + /** + * The AWS region to which this client will send requests + */ + region?: string | __Provider; + + /** + * Default credentials provider; Not available in browser runtime. + * @internal + */ + credentialDefaultProvider?: (input: any) => __Provider<__Credentials>; + + /** + * The provider populating default tracking information to be sent with `user-agent`, `x-amz-user-agent` header + * @internal + */ + defaultUserAgentProvider?: Provider<__UserAgent>; + + /** + * Value for how many times a request will be made at most in case of retry. + */ + maxAttempts?: number | __Provider; + + /** + * Specifies which retry algorithm to use. + * @see https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-smithy-util-retry/Enum/RETRY_MODES/ + * + */ + retryMode?: string | __Provider; + + /** + * Optional logger for logging debug/info/warn/error. + */ + logger?: __Logger; + + /** + * Optional extensions + */ + extensions?: RuntimeExtension[]; + + /** + * The function that provides necessary utilities for generating and parsing event stream + */ + eventStreamSerdeProvider?: __EventStreamSerdeProvider; + + /** + * The {@link @smithy/smithy-client#DefaultsMode} that will be used to determine how certain default configuration options are resolved in the SDK. + */ + defaultsMode?: __DefaultsMode | __Provider<__DefaultsMode>; +} + +/** + * @public + */ +export type BedrockAgentRuntimeClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>> & + ClientDefaults & + RegionInputConfig & + EndpointInputConfig & + RetryInputConfig & + HostHeaderInputConfig & + AwsAuthInputConfig & + UserAgentInputConfig & + EventStreamSerdeInputConfig & + ClientInputEndpointParameters; +/** + * @public + * + * The configuration interface of BedrockAgentRuntimeClient class constructor that set the region, credentials and other options. + */ +export interface BedrockAgentRuntimeClientConfig extends BedrockAgentRuntimeClientConfigType {} + +/** + * @public + */ +export type BedrockAgentRuntimeClientResolvedConfigType = __SmithyResolvedConfiguration<__HttpHandlerOptions> & + Required & + RuntimeExtensionsConfig & + RegionResolvedConfig & + EndpointResolvedConfig & + RetryResolvedConfig & + HostHeaderResolvedConfig & + AwsAuthResolvedConfig & + UserAgentResolvedConfig & + EventStreamSerdeResolvedConfig & + ClientResolvedEndpointParameters; +/** + * @public + * + * The resolved configuration interface of BedrockAgentRuntimeClient class. This is resolved and normalized from the {@link BedrockAgentRuntimeClientConfig | constructor configuration interface}. + */ +export interface BedrockAgentRuntimeClientResolvedConfig extends BedrockAgentRuntimeClientResolvedConfigType {} + +/** + * @public + * Amazon Bedrock Agent + */ +export class BedrockAgentRuntimeClient extends __Client< + __HttpHandlerOptions, + ServiceInputTypes, + ServiceOutputTypes, + BedrockAgentRuntimeClientResolvedConfig +> { + /** + * The resolved configuration of BedrockAgentRuntimeClient class. This is resolved and normalized from the {@link BedrockAgentRuntimeClientConfig | constructor configuration interface}. + */ + readonly config: BedrockAgentRuntimeClientResolvedConfig; + + constructor(...[configuration]: __CheckOptionalClientConfig) { + const _config_0 = __getRuntimeConfig(configuration || {}); + const _config_1 = resolveClientEndpointParameters(_config_0); + const _config_2 = resolveRegionConfig(_config_1); + const _config_3 = resolveEndpointConfig(_config_2); + const _config_4 = resolveRetryConfig(_config_3); + const _config_5 = resolveHostHeaderConfig(_config_4); + const _config_6 = resolveAwsAuthConfig(_config_5); + const _config_7 = resolveUserAgentConfig(_config_6); + const _config_8 = resolveEventStreamSerdeConfig(_config_7); + const _config_9 = resolveRuntimeExtensions(_config_8, configuration?.extensions || []); + super(_config_9); + this.config = _config_9; + this.middlewareStack.use(getRetryPlugin(this.config)); + this.middlewareStack.use(getContentLengthPlugin(this.config)); + this.middlewareStack.use(getHostHeaderPlugin(this.config)); + this.middlewareStack.use(getLoggerPlugin(this.config)); + this.middlewareStack.use(getRecursionDetectionPlugin(this.config)); + this.middlewareStack.use(getAwsAuthPlugin(this.config)); + this.middlewareStack.use(getUserAgentPlugin(this.config)); + } + + /** + * Destroy underlying resources, like sockets. It's usually not necessary to do this. + * However in Node.js, it's best to explicitly shut down the client's agent when it is no longer needed. + * Otherwise, sockets might stay open for quite a long time before the server terminates them. + */ + destroy(): void { + super.destroy(); + } +} diff --git a/clients/client-bedrock-agent-runtime/src/commands/InvokeAgentCommand.ts b/clients/client-bedrock-agent-runtime/src/commands/InvokeAgentCommand.ts new file mode 100644 index 000000000000..f53054497f95 --- /dev/null +++ b/clients/client-bedrock-agent-runtime/src/commands/InvokeAgentCommand.ts @@ -0,0 +1,398 @@ +// smithy-typescript generated code +import { EndpointParameterInstructions, getEndpointPlugin } from "@smithy/middleware-endpoint"; +import { getSerdePlugin } from "@smithy/middleware-serde"; +import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@smithy/protocol-http"; +import { Command as $Command } from "@smithy/smithy-client"; +import { + EventStreamSerdeContext as __EventStreamSerdeContext, + FinalizeHandlerArguments, + Handler, + HandlerExecutionContext, + HttpHandlerOptions as __HttpHandlerOptions, + MetadataBearer as __MetadataBearer, + MiddlewareStack, + SerdeContext as __SerdeContext, + SMITHY_CONTEXT_KEY, +} from "@smithy/types"; + +import { + BedrockAgentRuntimeClientResolvedConfig, + ServiceInputTypes, + ServiceOutputTypes, +} from "../BedrockAgentRuntimeClient"; +import { + InvokeAgentRequest, + InvokeAgentRequestFilterSensitiveLog, + InvokeAgentResponse, + InvokeAgentResponseFilterSensitiveLog, +} from "../models/models_0"; +import { de_InvokeAgentCommand, se_InvokeAgentCommand } from "../protocols/Aws_restJson1"; + +/** + * @public + */ +export { __MetadataBearer, $Command }; +/** + * @public + * + * The input for {@link InvokeAgentCommand}. + */ +export interface InvokeAgentCommandInput extends InvokeAgentRequest {} +/** + * @public + * + * The output of {@link InvokeAgentCommand}. + */ +export interface InvokeAgentCommandOutput extends InvokeAgentResponse, __MetadataBearer {} + +/** + * @public + * Invokes the specified Bedrock model to run inference using the input provided in the request body. + * @example + * Use a bare-bones client and the command you need to make an API call. + * ```javascript + * import { BedrockAgentRuntimeClient, InvokeAgentCommand } from "@aws-sdk/client-bedrock-agent-runtime"; // ES Modules import + * // const { BedrockAgentRuntimeClient, InvokeAgentCommand } = require("@aws-sdk/client-bedrock-agent-runtime"); // CommonJS import + * const client = new BedrockAgentRuntimeClient(config); + * const input = { // InvokeAgentRequest + * sessionState: { // SessionState + * sessionAttributes: { // SessionAttributesMap + * "": "STRING_VALUE", + * }, + * promptSessionAttributes: { // PromptSessionAttributesMap + * "": "STRING_VALUE", + * }, + * }, + * agentId: "STRING_VALUE", // required + * agentAliasId: "STRING_VALUE", // required + * sessionId: "STRING_VALUE", // required + * endSession: true || false, + * enableTrace: true || false, + * inputText: "STRING_VALUE", // required + * }; + * const command = new InvokeAgentCommand(input); + * const response = await client.send(command); + * // { // InvokeAgentResponse + * // completion: { // ResponseStream Union: only one key present + * // chunk: { // PayloadPart + * // bytes: "BLOB_VALUE", + * // attribution: { // Attribution + * // citations: [ // Citations + * // { // Citation + * // generatedResponsePart: { // GeneratedResponsePart + * // textResponsePart: { // TextResponsePart + * // text: "STRING_VALUE", + * // span: { // Span + * // start: Number("int"), + * // end: Number("int"), + * // }, + * // }, + * // }, + * // retrievedReferences: [ // RetrievedReferences + * // { // RetrievedReference + * // content: { // RetrievalResultContent + * // text: "STRING_VALUE", // required + * // }, + * // location: { // RetrievalResultLocation + * // type: "S3", // required + * // s3Location: { // RetrievalResultS3Location + * // uri: "STRING_VALUE", + * // }, + * // }, + * // }, + * // ], + * // }, + * // ], + * // }, + * // }, + * // trace: { // TracePart + * // agentId: "STRING_VALUE", + * // agentAliasId: "STRING_VALUE", + * // sessionId: "STRING_VALUE", + * // trace: { // Trace Union: only one key present + * // preProcessingTrace: { // PreProcessingTrace Union: only one key present + * // modelInvocationInput: { // ModelInvocationInput + * // traceId: "STRING_VALUE", + * // text: "STRING_VALUE", + * // type: "PRE_PROCESSING" || "ORCHESTRATION" || "KNOWLEDGE_BASE_RESPONSE_GENERATION" || "POST_PROCESSING", + * // inferenceConfiguration: { // InferenceConfiguration + * // temperature: Number("float"), + * // topP: Number("float"), + * // topK: Number("int"), + * // maximumLength: Number("int"), + * // stopSequences: [ // StopSequences + * // "STRING_VALUE", + * // ], + * // }, + * // overrideLambda: "STRING_VALUE", + * // promptCreationMode: "DEFAULT" || "OVERRIDDEN", + * // parserMode: "DEFAULT" || "OVERRIDDEN", + * // }, + * // modelInvocationOutput: { // PreProcessingModelInvocationOutput + * // traceId: "STRING_VALUE", + * // parsedResponse: { // PreProcessingParsedResponse + * // rationale: "STRING_VALUE", + * // isValid: true || false, + * // }, + * // }, + * // }, + * // orchestrationTrace: { // OrchestrationTrace Union: only one key present + * // rationale: { // Rationale + * // traceId: "STRING_VALUE", + * // text: "STRING_VALUE", + * // }, + * // invocationInput: { // InvocationInput + * // traceId: "STRING_VALUE", + * // invocationType: "ACTION_GROUP" || "KNOWLEDGE_BASE" || "FINISH", + * // actionGroupInvocationInput: { // ActionGroupInvocationInput + * // actionGroupName: "STRING_VALUE", + * // verb: "STRING_VALUE", + * // apiPath: "STRING_VALUE", + * // parameters: [ // Parameters + * // { // Parameter + * // name: "STRING_VALUE", + * // type: "STRING_VALUE", + * // value: "STRING_VALUE", + * // }, + * // ], + * // requestBody: { // RequestBody + * // content: { // ContentMap + * // "": [ + * // { + * // name: "STRING_VALUE", + * // type: "STRING_VALUE", + * // value: "STRING_VALUE", + * // }, + * // ], + * // }, + * // }, + * // }, + * // knowledgeBaseLookupInput: { // KnowledgeBaseLookupInput + * // text: "STRING_VALUE", + * // knowledgeBaseId: "STRING_VALUE", + * // }, + * // }, + * // observation: { // Observation + * // traceId: "STRING_VALUE", + * // type: "ACTION_GROUP" || "KNOWLEDGE_BASE" || "FINISH" || "ASK_USER" || "REPROMPT", + * // actionGroupInvocationOutput: { // ActionGroupInvocationOutput + * // text: "STRING_VALUE", + * // }, + * // knowledgeBaseLookupOutput: { // KnowledgeBaseLookupOutput + * // retrievedReferences: [ + * // { + * // content: { + * // text: "STRING_VALUE", // required + * // }, + * // location: { + * // type: "S3", // required + * // s3Location: { + * // uri: "STRING_VALUE", + * // }, + * // }, + * // }, + * // ], + * // }, + * // finalResponse: { // FinalResponse + * // text: "STRING_VALUE", + * // }, + * // repromptResponse: { // RepromptResponse + * // text: "STRING_VALUE", + * // source: "ACTION_GROUP" || "KNOWLEDGE_BASE" || "PARSER", + * // }, + * // }, + * // modelInvocationInput: { + * // traceId: "STRING_VALUE", + * // text: "STRING_VALUE", + * // type: "PRE_PROCESSING" || "ORCHESTRATION" || "KNOWLEDGE_BASE_RESPONSE_GENERATION" || "POST_PROCESSING", + * // inferenceConfiguration: { + * // temperature: Number("float"), + * // topP: Number("float"), + * // topK: Number("int"), + * // maximumLength: Number("int"), + * // stopSequences: [ + * // "STRING_VALUE", + * // ], + * // }, + * // overrideLambda: "STRING_VALUE", + * // promptCreationMode: "DEFAULT" || "OVERRIDDEN", + * // parserMode: "DEFAULT" || "OVERRIDDEN", + * // }, + * // }, + * // postProcessingTrace: { // PostProcessingTrace Union: only one key present + * // modelInvocationInput: { + * // traceId: "STRING_VALUE", + * // text: "STRING_VALUE", + * // type: "PRE_PROCESSING" || "ORCHESTRATION" || "KNOWLEDGE_BASE_RESPONSE_GENERATION" || "POST_PROCESSING", + * // inferenceConfiguration: { + * // temperature: Number("float"), + * // topP: Number("float"), + * // topK: Number("int"), + * // maximumLength: Number("int"), + * // stopSequences: [ + * // "STRING_VALUE", + * // ], + * // }, + * // overrideLambda: "STRING_VALUE", + * // promptCreationMode: "DEFAULT" || "OVERRIDDEN", + * // parserMode: "DEFAULT" || "OVERRIDDEN", + * // }, + * // modelInvocationOutput: { // PostProcessingModelInvocationOutput + * // traceId: "STRING_VALUE", + * // parsedResponse: { // PostProcessingParsedResponse + * // text: "STRING_VALUE", + * // }, + * // }, + * // }, + * // failureTrace: { // FailureTrace + * // traceId: "STRING_VALUE", + * // failureReason: "STRING_VALUE", + * // }, + * // }, + * // }, + * // internalServerException: { // InternalServerException + * // message: "STRING_VALUE", + * // }, + * // validationException: { // ValidationException + * // message: "STRING_VALUE", + * // }, + * // resourceNotFoundException: { // ResourceNotFoundException + * // message: "STRING_VALUE", + * // }, + * // serviceQuotaExceededException: { // ServiceQuotaExceededException + * // message: "STRING_VALUE", + * // }, + * // throttlingException: { // ThrottlingException + * // message: "STRING_VALUE", + * // }, + * // accessDeniedException: { // AccessDeniedException + * // message: "STRING_VALUE", + * // }, + * // conflictException: { // ConflictException + * // message: "STRING_VALUE", + * // }, + * // dependencyFailedException: { // DependencyFailedException + * // message: "STRING_VALUE", + * // resourceName: "STRING_VALUE", + * // }, + * // badGatewayException: { // BadGatewayException + * // message: "STRING_VALUE", + * // resourceName: "STRING_VALUE", + * // }, + * // }, + * // contentType: "STRING_VALUE", // required + * // sessionId: "STRING_VALUE", // required + * // }; + * + * ``` + * + * @param InvokeAgentCommandInput - {@link InvokeAgentCommandInput} + * @returns {@link InvokeAgentCommandOutput} + * @see {@link InvokeAgentCommandInput} for command's `input` shape. + * @see {@link InvokeAgentCommandOutput} for command's `response` shape. + * @see {@link BedrockAgentRuntimeClientResolvedConfig | config} for BedrockAgentRuntimeClient's `config` shape. + * + * @throws {@link AccessDeniedException} (client fault) + * This exception is thrown when a request is denied per access permissions + * + * @throws {@link BadGatewayException} (server fault) + * This exception is thrown when a request fails due to dependency like Lambda, Bedrock, STS resource + * + * @throws {@link ConflictException} (client fault) + * This exception is thrown when there is a conflict performing an operation + * + * @throws {@link DependencyFailedException} (client fault) + * This exception is thrown when a request fails due to dependency like Lambda, Bedrock, STS resource due to a customer fault (i.e. bad configuration) + * + * @throws {@link InternalServerException} (server fault) + * This exception is thrown if there was an unexpected error during processing of request + * + * @throws {@link ResourceNotFoundException} (client fault) + * This exception is thrown when a resource referenced by the operation does not exist + * + * @throws {@link ServiceQuotaExceededException} (client fault) + * This exception is thrown when a request is made beyond the service quota + * + * @throws {@link ThrottlingException} (client fault) + * This exception is thrown when the number of requests exceeds the limit + * + * @throws {@link ValidationException} (client fault) + * This exception is thrown when the request's input validation fails + * + * @throws {@link BedrockAgentRuntimeServiceException} + *

Base exception class for all service exceptions from BedrockAgentRuntime service.

+ * + */ +export class InvokeAgentCommand extends $Command< + InvokeAgentCommandInput, + InvokeAgentCommandOutput, + BedrockAgentRuntimeClientResolvedConfig +> { + public static getEndpointParameterInstructions(): EndpointParameterInstructions { + return { + UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, + Endpoint: { type: "builtInParams", name: "endpoint" }, + Region: { type: "builtInParams", name: "region" }, + UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, + }; + } + + /** + * @public + */ + constructor(readonly input: InvokeAgentCommandInput) { + super(); + } + + /** + * @internal + */ + resolveMiddleware( + clientStack: MiddlewareStack, + configuration: BedrockAgentRuntimeClientResolvedConfig, + options?: __HttpHandlerOptions + ): Handler { + this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize)); + this.middlewareStack.use(getEndpointPlugin(configuration, InvokeAgentCommand.getEndpointParameterInstructions())); + + const stack = clientStack.concat(this.middlewareStack); + + const { logger } = configuration; + const clientName = "BedrockAgentRuntimeClient"; + const commandName = "InvokeAgentCommand"; + const handlerExecutionContext: HandlerExecutionContext = { + logger, + clientName, + commandName, + inputFilterSensitiveLog: InvokeAgentRequestFilterSensitiveLog, + outputFilterSensitiveLog: InvokeAgentResponseFilterSensitiveLog, + [SMITHY_CONTEXT_KEY]: { + service: "AmazonBedrockAgentRunTimeService", + operation: "InvokeAgent", + }, + }; + const { requestHandler } = configuration; + return stack.resolve( + (request: FinalizeHandlerArguments) => + requestHandler.handle(request.request as __HttpRequest, options || {}), + handlerExecutionContext + ); + } + + /** + * @internal + */ + private serialize(input: InvokeAgentCommandInput, context: __SerdeContext): Promise<__HttpRequest> { + return se_InvokeAgentCommand(input, context); + } + + /** + * @internal + */ + private deserialize( + output: __HttpResponse, + context: __SerdeContext & __EventStreamSerdeContext + ): Promise { + return de_InvokeAgentCommand(output, context); + } +} diff --git a/clients/client-bedrock-agent-runtime/src/commands/RetrieveAndGenerateCommand.ts b/clients/client-bedrock-agent-runtime/src/commands/RetrieveAndGenerateCommand.ts new file mode 100644 index 000000000000..bba32e5a5ef9 --- /dev/null +++ b/clients/client-bedrock-agent-runtime/src/commands/RetrieveAndGenerateCommand.ts @@ -0,0 +1,217 @@ +// smithy-typescript generated code +import { EndpointParameterInstructions, getEndpointPlugin } from "@smithy/middleware-endpoint"; +import { getSerdePlugin } from "@smithy/middleware-serde"; +import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@smithy/protocol-http"; +import { Command as $Command } from "@smithy/smithy-client"; +import { + FinalizeHandlerArguments, + Handler, + HandlerExecutionContext, + HttpHandlerOptions as __HttpHandlerOptions, + MetadataBearer as __MetadataBearer, + MiddlewareStack, + SerdeContext as __SerdeContext, + SMITHY_CONTEXT_KEY, +} from "@smithy/types"; + +import { + BedrockAgentRuntimeClientResolvedConfig, + ServiceInputTypes, + ServiceOutputTypes, +} from "../BedrockAgentRuntimeClient"; +import { + RetrieveAndGenerateRequest, + RetrieveAndGenerateRequestFilterSensitiveLog, + RetrieveAndGenerateResponse, + RetrieveAndGenerateResponseFilterSensitiveLog, +} from "../models/models_0"; +import { de_RetrieveAndGenerateCommand, se_RetrieveAndGenerateCommand } from "../protocols/Aws_restJson1"; + +/** + * @public + */ +export { __MetadataBearer, $Command }; +/** + * @public + * + * The input for {@link RetrieveAndGenerateCommand}. + */ +export interface RetrieveAndGenerateCommandInput extends RetrieveAndGenerateRequest {} +/** + * @public + * + * The output of {@link RetrieveAndGenerateCommand}. + */ +export interface RetrieveAndGenerateCommandOutput extends RetrieveAndGenerateResponse, __MetadataBearer {} + +/** + * @public + * RetrieveAndGenerate API + * @example + * Use a bare-bones client and the command you need to make an API call. + * ```javascript + * import { BedrockAgentRuntimeClient, RetrieveAndGenerateCommand } from "@aws-sdk/client-bedrock-agent-runtime"; // ES Modules import + * // const { BedrockAgentRuntimeClient, RetrieveAndGenerateCommand } = require("@aws-sdk/client-bedrock-agent-runtime"); // CommonJS import + * const client = new BedrockAgentRuntimeClient(config); + * const input = { // RetrieveAndGenerateRequest + * sessionId: "STRING_VALUE", + * input: { // RetrieveAndGenerateInput + * text: "STRING_VALUE", // required + * }, + * retrieveAndGenerateConfiguration: { // RetrieveAndGenerateConfiguration + * type: "KNOWLEDGE_BASE", // required + * knowledgeBaseConfiguration: { // KnowledgeBaseRetrieveAndGenerateConfiguration + * knowledgeBaseId: "STRING_VALUE", // required + * modelArn: "STRING_VALUE", // required + * }, + * }, + * sessionConfiguration: { // RetrieveAndGenerateSessionConfiguration + * kmsKeyArn: "STRING_VALUE", // required + * }, + * }; + * const command = new RetrieveAndGenerateCommand(input); + * const response = await client.send(command); + * // { // RetrieveAndGenerateResponse + * // sessionId: "STRING_VALUE", // required + * // output: { // RetrieveAndGenerateOutput + * // text: "STRING_VALUE", // required + * // }, + * // citations: [ // Citations + * // { // Citation + * // generatedResponsePart: { // GeneratedResponsePart + * // textResponsePart: { // TextResponsePart + * // text: "STRING_VALUE", + * // span: { // Span + * // start: Number("int"), + * // end: Number("int"), + * // }, + * // }, + * // }, + * // retrievedReferences: [ // RetrievedReferences + * // { // RetrievedReference + * // content: { // RetrievalResultContent + * // text: "STRING_VALUE", // required + * // }, + * // location: { // RetrievalResultLocation + * // type: "S3", // required + * // s3Location: { // RetrievalResultS3Location + * // uri: "STRING_VALUE", + * // }, + * // }, + * // }, + * // ], + * // }, + * // ], + * // }; + * + * ``` + * + * @param RetrieveAndGenerateCommandInput - {@link RetrieveAndGenerateCommandInput} + * @returns {@link RetrieveAndGenerateCommandOutput} + * @see {@link RetrieveAndGenerateCommandInput} for command's `input` shape. + * @see {@link RetrieveAndGenerateCommandOutput} for command's `response` shape. + * @see {@link BedrockAgentRuntimeClientResolvedConfig | config} for BedrockAgentRuntimeClient's `config` shape. + * + * @throws {@link AccessDeniedException} (client fault) + * This exception is thrown when a request is denied per access permissions + * + * @throws {@link BadGatewayException} (server fault) + * This exception is thrown when a request fails due to dependency like Lambda, Bedrock, STS resource + * + * @throws {@link ConflictException} (client fault) + * This exception is thrown when there is a conflict performing an operation + * + * @throws {@link DependencyFailedException} (client fault) + * This exception is thrown when a request fails due to dependency like Lambda, Bedrock, STS resource due to a customer fault (i.e. bad configuration) + * + * @throws {@link InternalServerException} (server fault) + * This exception is thrown if there was an unexpected error during processing of request + * + * @throws {@link ResourceNotFoundException} (client fault) + * This exception is thrown when a resource referenced by the operation does not exist + * + * @throws {@link ServiceQuotaExceededException} (client fault) + * This exception is thrown when a request is made beyond the service quota + * + * @throws {@link ThrottlingException} (client fault) + * This exception is thrown when the number of requests exceeds the limit + * + * @throws {@link ValidationException} (client fault) + * This exception is thrown when the request's input validation fails + * + * @throws {@link BedrockAgentRuntimeServiceException} + *

Base exception class for all service exceptions from BedrockAgentRuntime service.

+ * + */ +export class RetrieveAndGenerateCommand extends $Command< + RetrieveAndGenerateCommandInput, + RetrieveAndGenerateCommandOutput, + BedrockAgentRuntimeClientResolvedConfig +> { + public static getEndpointParameterInstructions(): EndpointParameterInstructions { + return { + UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, + Endpoint: { type: "builtInParams", name: "endpoint" }, + Region: { type: "builtInParams", name: "region" }, + UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, + }; + } + + /** + * @public + */ + constructor(readonly input: RetrieveAndGenerateCommandInput) { + super(); + } + + /** + * @internal + */ + resolveMiddleware( + clientStack: MiddlewareStack, + configuration: BedrockAgentRuntimeClientResolvedConfig, + options?: __HttpHandlerOptions + ): Handler { + this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize)); + this.middlewareStack.use( + getEndpointPlugin(configuration, RetrieveAndGenerateCommand.getEndpointParameterInstructions()) + ); + + const stack = clientStack.concat(this.middlewareStack); + + const { logger } = configuration; + const clientName = "BedrockAgentRuntimeClient"; + const commandName = "RetrieveAndGenerateCommand"; + const handlerExecutionContext: HandlerExecutionContext = { + logger, + clientName, + commandName, + inputFilterSensitiveLog: RetrieveAndGenerateRequestFilterSensitiveLog, + outputFilterSensitiveLog: RetrieveAndGenerateResponseFilterSensitiveLog, + [SMITHY_CONTEXT_KEY]: { + service: "AmazonBedrockAgentRunTimeService", + operation: "RetrieveAndGenerate", + }, + }; + const { requestHandler } = configuration; + return stack.resolve( + (request: FinalizeHandlerArguments) => + requestHandler.handle(request.request as __HttpRequest, options || {}), + handlerExecutionContext + ); + } + + /** + * @internal + */ + private serialize(input: RetrieveAndGenerateCommandInput, context: __SerdeContext): Promise<__HttpRequest> { + return se_RetrieveAndGenerateCommand(input, context); + } + + /** + * @internal + */ + private deserialize(output: __HttpResponse, context: __SerdeContext): Promise { + return de_RetrieveAndGenerateCommand(output, context); + } +} diff --git a/clients/client-bedrock-agent-runtime/src/commands/RetrieveCommand.ts b/clients/client-bedrock-agent-runtime/src/commands/RetrieveCommand.ts new file mode 100644 index 000000000000..ae06c2388d8e --- /dev/null +++ b/clients/client-bedrock-agent-runtime/src/commands/RetrieveCommand.ts @@ -0,0 +1,196 @@ +// smithy-typescript generated code +import { EndpointParameterInstructions, getEndpointPlugin } from "@smithy/middleware-endpoint"; +import { getSerdePlugin } from "@smithy/middleware-serde"; +import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@smithy/protocol-http"; +import { Command as $Command } from "@smithy/smithy-client"; +import { + FinalizeHandlerArguments, + Handler, + HandlerExecutionContext, + HttpHandlerOptions as __HttpHandlerOptions, + MetadataBearer as __MetadataBearer, + MiddlewareStack, + SerdeContext as __SerdeContext, + SMITHY_CONTEXT_KEY, +} from "@smithy/types"; + +import { + BedrockAgentRuntimeClientResolvedConfig, + ServiceInputTypes, + ServiceOutputTypes, +} from "../BedrockAgentRuntimeClient"; +import { + RetrieveRequest, + RetrieveRequestFilterSensitiveLog, + RetrieveResponse, + RetrieveResponseFilterSensitiveLog, +} from "../models/models_0"; +import { de_RetrieveCommand, se_RetrieveCommand } from "../protocols/Aws_restJson1"; + +/** + * @public + */ +export { __MetadataBearer, $Command }; +/** + * @public + * + * The input for {@link RetrieveCommand}. + */ +export interface RetrieveCommandInput extends RetrieveRequest {} +/** + * @public + * + * The output of {@link RetrieveCommand}. + */ +export interface RetrieveCommandOutput extends RetrieveResponse, __MetadataBearer {} + +/** + * @public + * Retrieve from knowledge base. + * @example + * Use a bare-bones client and the command you need to make an API call. + * ```javascript + * import { BedrockAgentRuntimeClient, RetrieveCommand } from "@aws-sdk/client-bedrock-agent-runtime"; // ES Modules import + * // const { BedrockAgentRuntimeClient, RetrieveCommand } = require("@aws-sdk/client-bedrock-agent-runtime"); // CommonJS import + * const client = new BedrockAgentRuntimeClient(config); + * const input = { // RetrieveRequest + * knowledgeBaseId: "STRING_VALUE", // required + * retrievalQuery: { // KnowledgeBaseQuery + * text: "STRING_VALUE", // required + * }, + * retrievalConfiguration: { // KnowledgeBaseRetrievalConfiguration + * vectorSearchConfiguration: { // KnowledgeBaseVectorSearchConfiguration + * numberOfResults: Number("int"), // required + * }, + * }, + * nextToken: "STRING_VALUE", + * }; + * const command = new RetrieveCommand(input); + * const response = await client.send(command); + * // { // RetrieveResponse + * // retrievalResults: [ // KnowledgeBaseRetrievalResults // required + * // { // KnowledgeBaseRetrievalResult + * // content: { // RetrievalResultContent + * // text: "STRING_VALUE", // required + * // }, + * // location: { // RetrievalResultLocation + * // type: "S3", // required + * // s3Location: { // RetrievalResultS3Location + * // uri: "STRING_VALUE", + * // }, + * // }, + * // score: Number("double"), + * // }, + * // ], + * // nextToken: "STRING_VALUE", + * // }; + * + * ``` + * + * @param RetrieveCommandInput - {@link RetrieveCommandInput} + * @returns {@link RetrieveCommandOutput} + * @see {@link RetrieveCommandInput} for command's `input` shape. + * @see {@link RetrieveCommandOutput} for command's `response` shape. + * @see {@link BedrockAgentRuntimeClientResolvedConfig | config} for BedrockAgentRuntimeClient's `config` shape. + * + * @throws {@link AccessDeniedException} (client fault) + * This exception is thrown when a request is denied per access permissions + * + * @throws {@link BadGatewayException} (server fault) + * This exception is thrown when a request fails due to dependency like Lambda, Bedrock, STS resource + * + * @throws {@link ConflictException} (client fault) + * This exception is thrown when there is a conflict performing an operation + * + * @throws {@link DependencyFailedException} (client fault) + * This exception is thrown when a request fails due to dependency like Lambda, Bedrock, STS resource due to a customer fault (i.e. bad configuration) + * + * @throws {@link InternalServerException} (server fault) + * This exception is thrown if there was an unexpected error during processing of request + * + * @throws {@link ResourceNotFoundException} (client fault) + * This exception is thrown when a resource referenced by the operation does not exist + * + * @throws {@link ServiceQuotaExceededException} (client fault) + * This exception is thrown when a request is made beyond the service quota + * + * @throws {@link ThrottlingException} (client fault) + * This exception is thrown when the number of requests exceeds the limit + * + * @throws {@link ValidationException} (client fault) + * This exception is thrown when the request's input validation fails + * + * @throws {@link BedrockAgentRuntimeServiceException} + *

Base exception class for all service exceptions from BedrockAgentRuntime service.

+ * + */ +export class RetrieveCommand extends $Command< + RetrieveCommandInput, + RetrieveCommandOutput, + BedrockAgentRuntimeClientResolvedConfig +> { + public static getEndpointParameterInstructions(): EndpointParameterInstructions { + return { + UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, + Endpoint: { type: "builtInParams", name: "endpoint" }, + Region: { type: "builtInParams", name: "region" }, + UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, + }; + } + + /** + * @public + */ + constructor(readonly input: RetrieveCommandInput) { + super(); + } + + /** + * @internal + */ + resolveMiddleware( + clientStack: MiddlewareStack, + configuration: BedrockAgentRuntimeClientResolvedConfig, + options?: __HttpHandlerOptions + ): Handler { + this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize)); + this.middlewareStack.use(getEndpointPlugin(configuration, RetrieveCommand.getEndpointParameterInstructions())); + + const stack = clientStack.concat(this.middlewareStack); + + const { logger } = configuration; + const clientName = "BedrockAgentRuntimeClient"; + const commandName = "RetrieveCommand"; + const handlerExecutionContext: HandlerExecutionContext = { + logger, + clientName, + commandName, + inputFilterSensitiveLog: RetrieveRequestFilterSensitiveLog, + outputFilterSensitiveLog: RetrieveResponseFilterSensitiveLog, + [SMITHY_CONTEXT_KEY]: { + service: "AmazonBedrockAgentRunTimeService", + operation: "Retrieve", + }, + }; + const { requestHandler } = configuration; + return stack.resolve( + (request: FinalizeHandlerArguments) => + requestHandler.handle(request.request as __HttpRequest, options || {}), + handlerExecutionContext + ); + } + + /** + * @internal + */ + private serialize(input: RetrieveCommandInput, context: __SerdeContext): Promise<__HttpRequest> { + return se_RetrieveCommand(input, context); + } + + /** + * @internal + */ + private deserialize(output: __HttpResponse, context: __SerdeContext): Promise { + return de_RetrieveCommand(output, context); + } +} diff --git a/clients/client-bedrock-agent-runtime/src/commands/index.ts b/clients/client-bedrock-agent-runtime/src/commands/index.ts new file mode 100644 index 000000000000..63aba081cf07 --- /dev/null +++ b/clients/client-bedrock-agent-runtime/src/commands/index.ts @@ -0,0 +1,4 @@ +// smithy-typescript generated code +export * from "./InvokeAgentCommand"; +export * from "./RetrieveAndGenerateCommand"; +export * from "./RetrieveCommand"; diff --git a/clients/client-bedrock-agent-runtime/src/endpoint/EndpointParameters.ts b/clients/client-bedrock-agent-runtime/src/endpoint/EndpointParameters.ts new file mode 100644 index 000000000000..5f8d2e564e42 --- /dev/null +++ b/clients/client-bedrock-agent-runtime/src/endpoint/EndpointParameters.ts @@ -0,0 +1,34 @@ +// smithy-typescript generated code +import { Endpoint, EndpointParameters as __EndpointParameters, EndpointV2, Provider } from "@smithy/types"; + +/** + * @public + */ +export interface ClientInputEndpointParameters { + region?: string | Provider; + useDualstackEndpoint?: boolean | Provider; + useFipsEndpoint?: boolean | Provider; + endpoint?: string | Provider | Endpoint | Provider | EndpointV2 | Provider; +} + +export type ClientResolvedEndpointParameters = ClientInputEndpointParameters & { + defaultSigningName: string; +}; + +export const resolveClientEndpointParameters = ( + options: T & ClientInputEndpointParameters +): T & ClientResolvedEndpointParameters => { + return { + ...options, + useDualstackEndpoint: options.useDualstackEndpoint ?? false, + useFipsEndpoint: options.useFipsEndpoint ?? false, + defaultSigningName: "bedrock", + }; +}; + +export interface EndpointParameters extends __EndpointParameters { + Region?: string; + UseDualStack?: boolean; + UseFIPS?: boolean; + Endpoint?: string; +} diff --git a/clients/client-bedrock-agent-runtime/src/endpoint/endpointResolver.ts b/clients/client-bedrock-agent-runtime/src/endpoint/endpointResolver.ts new file mode 100644 index 000000000000..5a2f95973187 --- /dev/null +++ b/clients/client-bedrock-agent-runtime/src/endpoint/endpointResolver.ts @@ -0,0 +1,16 @@ +// smithy-typescript generated code +import { EndpointV2, Logger } from "@smithy/types"; +import { EndpointParams, resolveEndpoint } from "@smithy/util-endpoints"; + +import { EndpointParameters } from "./EndpointParameters"; +import { ruleSet } from "./ruleset"; + +export const defaultEndpointResolver = ( + endpointParams: EndpointParameters, + context: { logger?: Logger } = {} +): EndpointV2 => { + return resolveEndpoint(ruleSet, { + endpointParams: endpointParams as EndpointParams, + logger: context.logger, + }); +}; diff --git a/clients/client-bedrock-agent-runtime/src/endpoint/ruleset.ts b/clients/client-bedrock-agent-runtime/src/endpoint/ruleset.ts new file mode 100644 index 000000000000..3cb2646d05da --- /dev/null +++ b/clients/client-bedrock-agent-runtime/src/endpoint/ruleset.ts @@ -0,0 +1,32 @@ +// @ts-nocheck +// generated code, do not edit +import { RuleSetObject } from "@smithy/types"; + +/* This file is compressed. Log this object + or see "smithy.rules#endpointRuleSet" + in codegen/sdk-codegen/aws-models/bedrock-agent-runtime.json */ + +const s="required", +t="fn", +u="argv", +v="ref"; +const a=true, +b="isSet", +c="booleanEquals", +d="error", +e="endpoint", +f="tree", +g="PartitionResult", +h={[s]:false,"type":"String"}, +i={[s]:true,"default":false,"type":"Boolean"}, +j={[v]:"Endpoint"}, +k={[t]:c,[u]:[{[v]:"UseFIPS"},true]}, +l={[t]:c,[u]:[{[v]:"UseDualStack"},true]}, +m={}, +n={[t]:"getAttr",[u]:[{[v]:g},"supportsFIPS"]}, +o={[t]:c,[u]:[true,{[t]:"getAttr",[u]:[{[v]:g},"supportsDualStack"]}]}, +p=[k], +q=[l], +r=[{[v]:"Region"}]; +const _data={version:"1.0",parameters:{Region:h,UseDualStack:i,UseFIPS:i,Endpoint:h},rules:[{conditions:[{[t]:b,[u]:[j]}],rules:[{conditions:p,error:"Invalid Configuration: FIPS and custom endpoint are not supported",type:d},{rules:[{conditions:q,error:"Invalid Configuration: Dualstack and custom endpoint are not supported",type:d},{endpoint:{url:j,properties:m,headers:m},type:e}],type:f}],type:f},{rules:[{conditions:[{[t]:b,[u]:r}],rules:[{conditions:[{[t]:"aws.partition",[u]:r,assign:g}],rules:[{conditions:[k,l],rules:[{conditions:[{[t]:c,[u]:[a,n]},o],rules:[{rules:[{endpoint:{url:"https://bedrock-agent-runtime-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:m,headers:m},type:e}],type:f}],type:f},{error:"FIPS and DualStack are enabled, but this partition does not support one or both",type:d}],type:f},{conditions:p,rules:[{conditions:[{[t]:c,[u]:[n,a]}],rules:[{rules:[{endpoint:{url:"https://bedrock-agent-runtime-fips.{Region}.{PartitionResult#dnsSuffix}",properties:m,headers:m},type:e}],type:f}],type:f},{error:"FIPS is enabled but this partition does not support FIPS",type:d}],type:f},{conditions:q,rules:[{conditions:[o],rules:[{rules:[{endpoint:{url:"https://bedrock-agent-runtime.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:m,headers:m},type:e}],type:f}],type:f},{error:"DualStack is enabled but this partition does not support DualStack",type:d}],type:f},{rules:[{endpoint:{url:"https://bedrock-agent-runtime.{Region}.{PartitionResult#dnsSuffix}",properties:m,headers:m},type:e}],type:f}],type:f}],type:f},{error:"Invalid Configuration: Missing Region",type:d}],type:f}]}; +export const ruleSet: RuleSetObject = _data; diff --git a/clients/client-bedrock-agent-runtime/src/extensionConfiguration.ts b/clients/client-bedrock-agent-runtime/src/extensionConfiguration.ts new file mode 100644 index 000000000000..08e8324703a4 --- /dev/null +++ b/clients/client-bedrock-agent-runtime/src/extensionConfiguration.ts @@ -0,0 +1,12 @@ +// smithy-typescript generated code +import { AwsRegionExtensionConfiguration } from "@aws-sdk/types"; +import { HttpHandlerExtensionConfiguration } from "@smithy/protocol-http"; +import { DefaultExtensionConfiguration } from "@smithy/types"; + +/** + * @internal + */ +export interface BedrockAgentRuntimeExtensionConfiguration + extends HttpHandlerExtensionConfiguration, + DefaultExtensionConfiguration, + AwsRegionExtensionConfiguration {} diff --git a/clients/client-bedrock-agent-runtime/src/index.ts b/clients/client-bedrock-agent-runtime/src/index.ts new file mode 100644 index 000000000000..a8dc9da688a8 --- /dev/null +++ b/clients/client-bedrock-agent-runtime/src/index.ts @@ -0,0 +1,19 @@ +// smithy-typescript generated code +/* eslint-disable */ +/** + * Amazon Bedrock Agent + * + * @packageDocumentation + */ +export * from "./BedrockAgentRuntimeClient"; +export * from "./BedrockAgentRuntime"; +export { ClientInputEndpointParameters } from "./endpoint/EndpointParameters"; +export { RuntimeExtension } from "./runtimeExtensions"; +export { BedrockAgentRuntimeExtensionConfiguration } from "./extensionConfiguration"; +export * from "./commands"; +export * from "./pagination"; +export * from "./models"; + +import "@aws-sdk/util-endpoints"; + +export { BedrockAgentRuntimeServiceException } from "./models/BedrockAgentRuntimeServiceException"; diff --git a/clients/client-bedrock-agent-runtime/src/models/BedrockAgentRuntimeServiceException.ts b/clients/client-bedrock-agent-runtime/src/models/BedrockAgentRuntimeServiceException.ts new file mode 100644 index 000000000000..064f152d36dd --- /dev/null +++ b/clients/client-bedrock-agent-runtime/src/models/BedrockAgentRuntimeServiceException.ts @@ -0,0 +1,22 @@ +// smithy-typescript generated code +import { + ServiceException as __ServiceException, + ServiceExceptionOptions as __ServiceExceptionOptions, +} from "@smithy/smithy-client"; + +export { __ServiceException, __ServiceExceptionOptions }; + +/** + * @public + * + * Base exception class for all service exceptions from BedrockAgentRuntime service. + */ +export class BedrockAgentRuntimeServiceException extends __ServiceException { + /** + * @internal + */ + constructor(options: __ServiceExceptionOptions) { + super(options); + Object.setPrototypeOf(this, BedrockAgentRuntimeServiceException.prototype); + } +} diff --git a/clients/client-bedrock-agent-runtime/src/models/index.ts b/clients/client-bedrock-agent-runtime/src/models/index.ts new file mode 100644 index 000000000000..9eaceb12865f --- /dev/null +++ b/clients/client-bedrock-agent-runtime/src/models/index.ts @@ -0,0 +1,2 @@ +// smithy-typescript generated code +export * from "./models_0"; diff --git a/clients/client-bedrock-agent-runtime/src/models/models_0.ts b/clients/client-bedrock-agent-runtime/src/models/models_0.ts new file mode 100644 index 000000000000..8231e82c68ae --- /dev/null +++ b/clients/client-bedrock-agent-runtime/src/models/models_0.ts @@ -0,0 +1,2056 @@ +// smithy-typescript generated code +import { ExceptionOptionType as __ExceptionOptionType, SENSITIVE_STRING } from "@smithy/smithy-client"; + +import { BedrockAgentRuntimeServiceException as __BaseException } from "./BedrockAgentRuntimeServiceException"; + +/** + * @public + * This exception is thrown when a request is denied per access permissions + */ +export class AccessDeniedException extends __BaseException { + readonly name: "AccessDeniedException" = "AccessDeniedException"; + readonly $fault: "client" = "client"; + /** + * @internal + */ + constructor(opts: __ExceptionOptionType) { + super({ + name: "AccessDeniedException", + $fault: "client", + ...opts, + }); + Object.setPrototypeOf(this, AccessDeniedException.prototype); + } +} + +/** + * @public + * parameters included in action group invocation + */ +export interface Parameter { + /** + * @public + * Name of parameter + */ + name?: string; + + /** + * @public + * Type of parameter + */ + type?: string; + + /** + * @public + * Value of parameter + */ + value?: string; +} + +/** + * @public + * Request Body Content Map + */ +export interface RequestBody { + /** + * @public + * Content type paramter map + */ + content?: Record; +} + +/** + * @public + * input to lambda used in action group + */ +export interface ActionGroupInvocationInput { + /** + * @public + * Agent Trace Action Group Name + */ + actionGroupName?: string; + + /** + * @public + * Agent Trace Action Group Action verb + */ + verb?: string; + + /** + * @public + * Agent Trace Action Group API path + */ + apiPath?: string; + + /** + * @public + * list of parameters included in action group invocation + */ + parameters?: Parameter[]; + + /** + * @public + * Request Body Content Map + */ + requestBody?: RequestBody; +} + +/** + * @public + * output from lambda used in action group + */ +export interface ActionGroupInvocationOutput { + /** + * @public + * Agent Trace Action Group Lambda Invocation Output String + */ + text?: string; +} + +/** + * @public + * This exception is thrown when a request fails due to dependency like Lambda, Bedrock, STS resource + */ +export class BadGatewayException extends __BaseException { + readonly name: "BadGatewayException" = "BadGatewayException"; + readonly $fault: "server" = "server"; + /** + * @public + * Non Blank String + */ + resourceName?: string; + + /** + * @internal + */ + constructor(opts: __ExceptionOptionType) { + super({ + name: "BadGatewayException", + $fault: "server", + ...opts, + }); + Object.setPrototypeOf(this, BadGatewayException.prototype); + this.resourceName = opts.resourceName; + } +} + +/** + * @public + * This exception is thrown when there is a conflict performing an operation + */ +export class ConflictException extends __BaseException { + readonly name: "ConflictException" = "ConflictException"; + readonly $fault: "client" = "client"; + /** + * @internal + */ + constructor(opts: __ExceptionOptionType) { + super({ + name: "ConflictException", + $fault: "client", + ...opts, + }); + Object.setPrototypeOf(this, ConflictException.prototype); + } +} + +/** + * @public + * This exception is thrown when a request fails due to dependency like Lambda, Bedrock, STS resource due to a customer fault (i.e. bad configuration) + */ +export class DependencyFailedException extends __BaseException { + readonly name: "DependencyFailedException" = "DependencyFailedException"; + readonly $fault: "client" = "client"; + /** + * @public + * Non Blank String + */ + resourceName?: string; + + /** + * @internal + */ + constructor(opts: __ExceptionOptionType) { + super({ + name: "DependencyFailedException", + $fault: "client", + ...opts, + }); + Object.setPrototypeOf(this, DependencyFailedException.prototype); + this.resourceName = opts.resourceName; + } +} + +/** + * @public + * This exception is thrown if there was an unexpected error during processing of request + */ +export class InternalServerException extends __BaseException { + readonly name: "InternalServerException" = "InternalServerException"; + readonly $fault: "server" = "server"; + /** + * @internal + */ + constructor(opts: __ExceptionOptionType) { + super({ + name: "InternalServerException", + $fault: "server", + ...opts, + }); + Object.setPrototypeOf(this, InternalServerException.prototype); + } +} + +/** + * @public + * Session state provided + */ +export interface SessionState { + /** + * @public + * Session Attributes + */ + sessionAttributes?: Record; + + /** + * @public + * Prompt Session Attributes + */ + promptSessionAttributes?: Record; +} + +/** + * @public + * InvokeAgent Request + */ +export interface InvokeAgentRequest { + /** + * @public + * Session state passed by customer. Base64 encoded json string representation of SessionState. + */ + sessionState?: SessionState; + + /** + * @public + * Identifier for Agent + */ + agentId: string | undefined; + + /** + * @public + * Identifier for Agent Alias + */ + agentAliasId: string | undefined; + + /** + * @public + * Identifier used for the current session + */ + sessionId: string | undefined; + + /** + * @public + * End current session + */ + endSession?: boolean; + + /** + * @public + * Enable agent trace events for improved debugging + */ + enableTrace?: boolean; + + /** + * @public + * Input data in the format specified in the Content-Type request header. + */ + inputText: string | undefined; +} + +/** + * @public + * Span of text + */ +export interface Span { + /** + * @public + * Start of span + */ + start?: number; + + /** + * @public + * End of span + */ + end?: number; +} + +/** + * @public + * Text response part + */ +export interface TextResponsePart { + /** + * @public + * Response part in text + */ + text?: string; + + /** + * @public + * Span of text + */ + span?: Span; +} + +/** + * @public + * Generate response part + */ +export interface GeneratedResponsePart { + /** + * @public + * Text response part + */ + textResponsePart?: TextResponsePart; +} + +/** + * @public + * Content of a retrieval result. + */ +export interface RetrievalResultContent { + /** + * @public + * Content of a retrieval result in text + */ + text: string | undefined; +} + +/** + * @public + * The S3 location of a retrieval result. + */ +export interface RetrievalResultS3Location { + /** + * @public + * URI of S3 location + */ + uri?: string; +} + +/** + * @public + * @enum + */ +export const RetrievalResultLocationType = { + S3: "S3", +} as const; + +/** + * @public + */ +export type RetrievalResultLocationType = + (typeof RetrievalResultLocationType)[keyof typeof RetrievalResultLocationType]; + +/** + * @public + * The source location of a retrieval result. + */ +export interface RetrievalResultLocation { + /** + * @public + * The location type of a retrieval result. + */ + type: RetrievalResultLocationType | undefined; + + /** + * @public + * The S3 location of a retrieval result. + */ + s3Location?: RetrievalResultS3Location; +} + +/** + * @public + * Retrieved reference + */ +export interface RetrievedReference { + /** + * @public + * Content of a retrieval result. + */ + content?: RetrievalResultContent; + + /** + * @public + * The source location of a retrieval result. + */ + location?: RetrievalResultLocation; +} + +/** + * @public + * Citation associated with the agent response + */ +export interface Citation { + /** + * @public + * Generate response part + */ + generatedResponsePart?: GeneratedResponsePart; + + /** + * @public + * list of retrieved references + */ + retrievedReferences?: RetrievedReference[]; +} + +/** + * @public + * Citations associated with final agent response + */ +export interface Attribution { + /** + * @public + * List of citations + */ + citations?: Citation[]; +} + +/** + * @public + * Base 64 endoded byte response + */ +export interface PayloadPart { + /** + * @public + * PartBody of the payload in bytes + */ + bytes?: Uint8Array; + + /** + * @public + * Citations associated with final agent response + */ + attribution?: Attribution; +} + +/** + * @public + * This exception is thrown when a resource referenced by the operation does not exist + */ +export class ResourceNotFoundException extends __BaseException { + readonly name: "ResourceNotFoundException" = "ResourceNotFoundException"; + readonly $fault: "client" = "client"; + /** + * @internal + */ + constructor(opts: __ExceptionOptionType) { + super({ + name: "ResourceNotFoundException", + $fault: "client", + ...opts, + }); + Object.setPrototypeOf(this, ResourceNotFoundException.prototype); + } +} + +/** + * @public + * This exception is thrown when a request is made beyond the service quota + */ +export class ServiceQuotaExceededException extends __BaseException { + readonly name: "ServiceQuotaExceededException" = "ServiceQuotaExceededException"; + readonly $fault: "client" = "client"; + /** + * @internal + */ + constructor(opts: __ExceptionOptionType) { + super({ + name: "ServiceQuotaExceededException", + $fault: "client", + ...opts, + }); + Object.setPrototypeOf(this, ServiceQuotaExceededException.prototype); + } +} + +/** + * @public + * This exception is thrown when the number of requests exceeds the limit + */ +export class ThrottlingException extends __BaseException { + readonly name: "ThrottlingException" = "ThrottlingException"; + readonly $fault: "client" = "client"; + /** + * @internal + */ + constructor(opts: __ExceptionOptionType) { + super({ + name: "ThrottlingException", + $fault: "client", + ...opts, + }); + Object.setPrototypeOf(this, ThrottlingException.prototype); + } +} + +/** + * @public + * Trace Part which is emitted when agent trace could not be generated + */ +export interface FailureTrace { + /** + * @public + * Identifier for trace + */ + traceId?: string; + + /** + * @public + * Agent Trace Failed Reason String + */ + failureReason?: string; +} + +/** + * @public + * @enum + */ +export const InvocationType = { + ACTION_GROUP: "ACTION_GROUP", + FINISH: "FINISH", + KNOWLEDGE_BASE: "KNOWLEDGE_BASE", +} as const; + +/** + * @public + */ +export type InvocationType = (typeof InvocationType)[keyof typeof InvocationType]; + +/** + * @public + * Input to lambda used in action group + */ +export interface KnowledgeBaseLookupInput { + /** + * @public + * Agent Trace Action Group Lambda Invocation Output String + */ + text?: string; + + /** + * @public + * Agent Trace Action Group Knowledge Base Id + */ + knowledgeBaseId?: string; +} + +/** + * @public + * Trace Part which contains input details for action group or knowledge base + */ +export interface InvocationInput { + /** + * @public + * Identifier for trace + */ + traceId?: string; + + /** + * @public + * types of invocations + */ + invocationType?: InvocationType; + + /** + * @public + * input to lambda used in action group + */ + actionGroupInvocationInput?: ActionGroupInvocationInput; + + /** + * @public + * Input to lambda used in action group + */ + knowledgeBaseLookupInput?: KnowledgeBaseLookupInput; +} + +/** + * @public + * Configurations for controlling the inference response of an InvokeAgent API call + */ +export interface InferenceConfiguration { + /** + * @public + * Controls randomness, higher values increase diversity + */ + temperature?: number; + + /** + * @public + * Cumulative probability cutoff for token selection + */ + topP?: number; + + /** + * @public + * Sample from the k most likely next tokens + */ + topK?: number; + + /** + * @public + * Maximum length of output + */ + maximumLength?: number; + + /** + * @public + * List of stop sequences + */ + stopSequences?: string[]; +} + +/** + * @public + * @enum + */ +export const CreationMode = { + DEFAULT: "DEFAULT", + OVERRIDDEN: "OVERRIDDEN", +} as const; + +/** + * @public + */ +export type CreationMode = (typeof CreationMode)[keyof typeof CreationMode]; + +/** + * @public + * @enum + */ +export const PromptType = { + KNOWLEDGE_BASE_RESPONSE_GENERATION: "KNOWLEDGE_BASE_RESPONSE_GENERATION", + ORCHESTRATION: "ORCHESTRATION", + POST_PROCESSING: "POST_PROCESSING", + PRE_PROCESSING: "PRE_PROCESSING", +} as const; + +/** + * @public + */ +export type PromptType = (typeof PromptType)[keyof typeof PromptType]; + +/** + * @public + * Trace Part which contains information used to call Invoke Model + */ +export interface ModelInvocationInput { + /** + * @public + * Identifier for trace + */ + traceId?: string; + + /** + * @public + * Prompt Message + */ + text?: string; + + /** + * @public + * types of prompts + */ + type?: PromptType; + + /** + * @public + * Configurations for controlling the inference response of an InvokeAgent API call + */ + inferenceConfiguration?: InferenceConfiguration; + + /** + * @public + * ARN of a Lambda. + */ + overrideLambda?: string; + + /** + * @public + * indicates if agent uses default prompt or overriden prompt + */ + promptCreationMode?: CreationMode; + + /** + * @public + * indicates if agent uses default prompt or overriden prompt + */ + parserMode?: CreationMode; +} + +/** + * @public + * Agent finish output + */ +export interface FinalResponse { + /** + * @public + * Agent Trace Action Group Lambda Invocation Output String + */ + text?: string; +} + +/** + * @public + * Input to lambda used in action group + */ +export interface KnowledgeBaseLookupOutput { + /** + * @public + * list of retrieved references + */ + retrievedReferences?: RetrievedReference[]; +} + +/** + * @public + * @enum + */ +export const Source = { + ACTION_GROUP: "ACTION_GROUP", + KNOWLEDGE_BASE: "KNOWLEDGE_BASE", + PARSER: "PARSER", +} as const; + +/** + * @public + */ +export type Source = (typeof Source)[keyof typeof Source]; + +/** + * @public + * Observation information if there were reprompts + */ +export interface RepromptResponse { + /** + * @public + * Reprompt response text + */ + text?: string; + + /** + * @public + * Parsing error source + */ + source?: Source; +} + +/** + * @public + * @enum + */ +export const Type = { + ACTION_GROUP: "ACTION_GROUP", + ASK_USER: "ASK_USER", + FINISH: "FINISH", + KNOWLEDGE_BASE: "KNOWLEDGE_BASE", + REPROMPT: "REPROMPT", +} as const; + +/** + * @public + */ +export type Type = (typeof Type)[keyof typeof Type]; + +/** + * @public + * Trace Part which contains output details for action group or knowledge base or final response + */ +export interface Observation { + /** + * @public + * Identifier for trace + */ + traceId?: string; + + /** + * @public + * types of observations + */ + type?: Type; + + /** + * @public + * output from lambda used in action group + */ + actionGroupInvocationOutput?: ActionGroupInvocationOutput; + + /** + * @public + * Input to lambda used in action group + */ + knowledgeBaseLookupOutput?: KnowledgeBaseLookupOutput; + + /** + * @public + * Agent finish output + */ + finalResponse?: FinalResponse; + + /** + * @public + * Observation information if there were reprompts + */ + repromptResponse?: RepromptResponse; +} + +/** + * @public + * Trace Part which contains information related to reasoning + */ +export interface Rationale { + /** + * @public + * Identifier for trace + */ + traceId?: string; + + /** + * @public + * Agent Trace Rationale String + */ + text?: string; +} + +/** + * @public + * Trace contains intermidate response during orchestration + */ +export type OrchestrationTrace = + | OrchestrationTrace.InvocationInputMember + | OrchestrationTrace.ModelInvocationInputMember + | OrchestrationTrace.ObservationMember + | OrchestrationTrace.RationaleMember + | OrchestrationTrace.$UnknownMember; + +/** + * @public + */ +export namespace OrchestrationTrace { + /** + * @public + * Trace Part which contains information related to reasoning + */ + export interface RationaleMember { + rationale: Rationale; + invocationInput?: never; + observation?: never; + modelInvocationInput?: never; + $unknown?: never; + } + + /** + * @public + * Trace Part which contains input details for action group or knowledge base + */ + export interface InvocationInputMember { + rationale?: never; + invocationInput: InvocationInput; + observation?: never; + modelInvocationInput?: never; + $unknown?: never; + } + + /** + * @public + * Trace Part which contains output details for action group or knowledge base or final response + */ + export interface ObservationMember { + rationale?: never; + invocationInput?: never; + observation: Observation; + modelInvocationInput?: never; + $unknown?: never; + } + + /** + * @public + * Trace Part which contains information used to call Invoke Model + */ + export interface ModelInvocationInputMember { + rationale?: never; + invocationInput?: never; + observation?: never; + modelInvocationInput: ModelInvocationInput; + $unknown?: never; + } + + /** + * @public + */ + export interface $UnknownMember { + rationale?: never; + invocationInput?: never; + observation?: never; + modelInvocationInput?: never; + $unknown: [string, any]; + } + + export interface Visitor { + rationale: (value: Rationale) => T; + invocationInput: (value: InvocationInput) => T; + observation: (value: Observation) => T; + modelInvocationInput: (value: ModelInvocationInput) => T; + _: (name: string, value: any) => T; + } + + export const visit = (value: OrchestrationTrace, visitor: Visitor): T => { + if (value.rationale !== undefined) return visitor.rationale(value.rationale); + if (value.invocationInput !== undefined) return visitor.invocationInput(value.invocationInput); + if (value.observation !== undefined) return visitor.observation(value.observation); + if (value.modelInvocationInput !== undefined) return visitor.modelInvocationInput(value.modelInvocationInput); + return visitor._(value.$unknown[0], value.$unknown[1]); + }; +} + +/** + * @public + * Trace Part which contains information if preprocessing was successful + */ +export interface PostProcessingParsedResponse { + /** + * @public + * Agent Trace Output String + */ + text?: string; +} + +/** + * @public + * Trace Part which contains information related to postprocessing + */ +export interface PostProcessingModelInvocationOutput { + /** + * @public + * Identifier for trace + */ + traceId?: string; + + /** + * @public + * Trace Part which contains information if preprocessing was successful + */ + parsedResponse?: PostProcessingParsedResponse; +} + +/** + * @public + * Trace Part which contains information related to post processing step + */ +export type PostProcessingTrace = + | PostProcessingTrace.ModelInvocationInputMember + | PostProcessingTrace.ModelInvocationOutputMember + | PostProcessingTrace.$UnknownMember; + +/** + * @public + */ +export namespace PostProcessingTrace { + /** + * @public + * Trace Part which contains information used to call Invoke Model + */ + export interface ModelInvocationInputMember { + modelInvocationInput: ModelInvocationInput; + modelInvocationOutput?: never; + $unknown?: never; + } + + /** + * @public + * Trace Part which contains information related to postprocessing + */ + export interface ModelInvocationOutputMember { + modelInvocationInput?: never; + modelInvocationOutput: PostProcessingModelInvocationOutput; + $unknown?: never; + } + + /** + * @public + */ + export interface $UnknownMember { + modelInvocationInput?: never; + modelInvocationOutput?: never; + $unknown: [string, any]; + } + + export interface Visitor { + modelInvocationInput: (value: ModelInvocationInput) => T; + modelInvocationOutput: (value: PostProcessingModelInvocationOutput) => T; + _: (name: string, value: any) => T; + } + + export const visit = (value: PostProcessingTrace, visitor: Visitor): T => { + if (value.modelInvocationInput !== undefined) return visitor.modelInvocationInput(value.modelInvocationInput); + if (value.modelInvocationOutput !== undefined) return visitor.modelInvocationOutput(value.modelInvocationOutput); + return visitor._(value.$unknown[0], value.$unknown[1]); + }; +} + +/** + * @public + * Trace Part which contains information if preprocessing was successful + */ +export interface PreProcessingParsedResponse { + /** + * @public + * Agent Trace Rationale String + */ + rationale?: string; + + /** + * @public + * Boolean value + */ + isValid?: boolean; +} + +/** + * @public + * Trace Part which contains information related to preprocessing + */ +export interface PreProcessingModelInvocationOutput { + /** + * @public + * Identifier for trace + */ + traceId?: string; + + /** + * @public + * Trace Part which contains information if preprocessing was successful + */ + parsedResponse?: PreProcessingParsedResponse; +} + +/** + * @public + * Trace Part which contains information related to preprocessing step + */ +export type PreProcessingTrace = + | PreProcessingTrace.ModelInvocationInputMember + | PreProcessingTrace.ModelInvocationOutputMember + | PreProcessingTrace.$UnknownMember; + +/** + * @public + */ +export namespace PreProcessingTrace { + /** + * @public + * Trace Part which contains information used to call Invoke Model + */ + export interface ModelInvocationInputMember { + modelInvocationInput: ModelInvocationInput; + modelInvocationOutput?: never; + $unknown?: never; + } + + /** + * @public + * Trace Part which contains information related to preprocessing + */ + export interface ModelInvocationOutputMember { + modelInvocationInput?: never; + modelInvocationOutput: PreProcessingModelInvocationOutput; + $unknown?: never; + } + + /** + * @public + */ + export interface $UnknownMember { + modelInvocationInput?: never; + modelInvocationOutput?: never; + $unknown: [string, any]; + } + + export interface Visitor { + modelInvocationInput: (value: ModelInvocationInput) => T; + modelInvocationOutput: (value: PreProcessingModelInvocationOutput) => T; + _: (name: string, value: any) => T; + } + + export const visit = (value: PreProcessingTrace, visitor: Visitor): T => { + if (value.modelInvocationInput !== undefined) return visitor.modelInvocationInput(value.modelInvocationInput); + if (value.modelInvocationOutput !== undefined) return visitor.modelInvocationOutput(value.modelInvocationOutput); + return visitor._(value.$unknown[0], value.$unknown[1]); + }; +} + +/** + * @public + * Trace contains intermidate response for customer + */ +export type Trace = + | Trace.FailureTraceMember + | Trace.OrchestrationTraceMember + | Trace.PostProcessingTraceMember + | Trace.PreProcessingTraceMember + | Trace.$UnknownMember; + +/** + * @public + */ +export namespace Trace { + /** + * @public + * Trace Part which contains information related to preprocessing step + */ + export interface PreProcessingTraceMember { + preProcessingTrace: PreProcessingTrace; + orchestrationTrace?: never; + postProcessingTrace?: never; + failureTrace?: never; + $unknown?: never; + } + + /** + * @public + * Trace contains intermidate response during orchestration + */ + export interface OrchestrationTraceMember { + preProcessingTrace?: never; + orchestrationTrace: OrchestrationTrace; + postProcessingTrace?: never; + failureTrace?: never; + $unknown?: never; + } + + /** + * @public + * Trace Part which contains information related to post processing step + */ + export interface PostProcessingTraceMember { + preProcessingTrace?: never; + orchestrationTrace?: never; + postProcessingTrace: PostProcessingTrace; + failureTrace?: never; + $unknown?: never; + } + + /** + * @public + * Trace Part which is emitted when agent trace could not be generated + */ + export interface FailureTraceMember { + preProcessingTrace?: never; + orchestrationTrace?: never; + postProcessingTrace?: never; + failureTrace: FailureTrace; + $unknown?: never; + } + + /** + * @public + */ + export interface $UnknownMember { + preProcessingTrace?: never; + orchestrationTrace?: never; + postProcessingTrace?: never; + failureTrace?: never; + $unknown: [string, any]; + } + + export interface Visitor { + preProcessingTrace: (value: PreProcessingTrace) => T; + orchestrationTrace: (value: OrchestrationTrace) => T; + postProcessingTrace: (value: PostProcessingTrace) => T; + failureTrace: (value: FailureTrace) => T; + _: (name: string, value: any) => T; + } + + export const visit = (value: Trace, visitor: Visitor): T => { + if (value.preProcessingTrace !== undefined) return visitor.preProcessingTrace(value.preProcessingTrace); + if (value.orchestrationTrace !== undefined) return visitor.orchestrationTrace(value.orchestrationTrace); + if (value.postProcessingTrace !== undefined) return visitor.postProcessingTrace(value.postProcessingTrace); + if (value.failureTrace !== undefined) return visitor.failureTrace(value.failureTrace); + return visitor._(value.$unknown[0], value.$unknown[1]); + }; +} + +/** + * @public + * Trace Part which contains intermidate response for customer + */ +export interface TracePart { + /** + * @public + * Identifier of the agent. + */ + agentId?: string; + + /** + * @public + * Identifier of the agent alias. + */ + agentAliasId?: string; + + /** + * @public + * Identifier of the session. + */ + sessionId?: string; + + /** + * @public + * Trace contains intermidate response for customer + */ + trace?: Trace; +} + +/** + * @public + * This exception is thrown when the request's input validation fails + */ +export class ValidationException extends __BaseException { + readonly name: "ValidationException" = "ValidationException"; + readonly $fault: "client" = "client"; + /** + * @internal + */ + constructor(opts: __ExceptionOptionType) { + super({ + name: "ValidationException", + $fault: "client", + ...opts, + }); + Object.setPrototypeOf(this, ValidationException.prototype); + } +} + +/** + * @public + * Response body of is a stream + */ +export type ResponseStream = + | ResponseStream.AccessDeniedExceptionMember + | ResponseStream.BadGatewayExceptionMember + | ResponseStream.ChunkMember + | ResponseStream.ConflictExceptionMember + | ResponseStream.DependencyFailedExceptionMember + | ResponseStream.InternalServerExceptionMember + | ResponseStream.ResourceNotFoundExceptionMember + | ResponseStream.ServiceQuotaExceededExceptionMember + | ResponseStream.ThrottlingExceptionMember + | ResponseStream.TraceMember + | ResponseStream.ValidationExceptionMember + | ResponseStream.$UnknownMember; + +/** + * @public + */ +export namespace ResponseStream { + /** + * @public + * Base 64 endoded byte response + */ + export interface ChunkMember { + chunk: PayloadPart; + trace?: never; + internalServerException?: never; + validationException?: never; + resourceNotFoundException?: never; + serviceQuotaExceededException?: never; + throttlingException?: never; + accessDeniedException?: never; + conflictException?: never; + dependencyFailedException?: never; + badGatewayException?: never; + $unknown?: never; + } + + /** + * @public + * Trace Part which contains intermidate response for customer + */ + export interface TraceMember { + chunk?: never; + trace: TracePart; + internalServerException?: never; + validationException?: never; + resourceNotFoundException?: never; + serviceQuotaExceededException?: never; + throttlingException?: never; + accessDeniedException?: never; + conflictException?: never; + dependencyFailedException?: never; + badGatewayException?: never; + $unknown?: never; + } + + /** + * @public + * This exception is thrown if there was an unexpected error during processing of request + */ + export interface InternalServerExceptionMember { + chunk?: never; + trace?: never; + internalServerException: InternalServerException; + validationException?: never; + resourceNotFoundException?: never; + serviceQuotaExceededException?: never; + throttlingException?: never; + accessDeniedException?: never; + conflictException?: never; + dependencyFailedException?: never; + badGatewayException?: never; + $unknown?: never; + } + + /** + * @public + * This exception is thrown when the request's input validation fails + */ + export interface ValidationExceptionMember { + chunk?: never; + trace?: never; + internalServerException?: never; + validationException: ValidationException; + resourceNotFoundException?: never; + serviceQuotaExceededException?: never; + throttlingException?: never; + accessDeniedException?: never; + conflictException?: never; + dependencyFailedException?: never; + badGatewayException?: never; + $unknown?: never; + } + + /** + * @public + * This exception is thrown when a resource referenced by the operation does not exist + */ + export interface ResourceNotFoundExceptionMember { + chunk?: never; + trace?: never; + internalServerException?: never; + validationException?: never; + resourceNotFoundException: ResourceNotFoundException; + serviceQuotaExceededException?: never; + throttlingException?: never; + accessDeniedException?: never; + conflictException?: never; + dependencyFailedException?: never; + badGatewayException?: never; + $unknown?: never; + } + + /** + * @public + * This exception is thrown when a request is made beyond the service quota + */ + export interface ServiceQuotaExceededExceptionMember { + chunk?: never; + trace?: never; + internalServerException?: never; + validationException?: never; + resourceNotFoundException?: never; + serviceQuotaExceededException: ServiceQuotaExceededException; + throttlingException?: never; + accessDeniedException?: never; + conflictException?: never; + dependencyFailedException?: never; + badGatewayException?: never; + $unknown?: never; + } + + /** + * @public + * This exception is thrown when the number of requests exceeds the limit + */ + export interface ThrottlingExceptionMember { + chunk?: never; + trace?: never; + internalServerException?: never; + validationException?: never; + resourceNotFoundException?: never; + serviceQuotaExceededException?: never; + throttlingException: ThrottlingException; + accessDeniedException?: never; + conflictException?: never; + dependencyFailedException?: never; + badGatewayException?: never; + $unknown?: never; + } + + /** + * @public + * This exception is thrown when a request is denied per access permissions + */ + export interface AccessDeniedExceptionMember { + chunk?: never; + trace?: never; + internalServerException?: never; + validationException?: never; + resourceNotFoundException?: never; + serviceQuotaExceededException?: never; + throttlingException?: never; + accessDeniedException: AccessDeniedException; + conflictException?: never; + dependencyFailedException?: never; + badGatewayException?: never; + $unknown?: never; + } + + /** + * @public + * This exception is thrown when there is a conflict performing an operation + */ + export interface ConflictExceptionMember { + chunk?: never; + trace?: never; + internalServerException?: never; + validationException?: never; + resourceNotFoundException?: never; + serviceQuotaExceededException?: never; + throttlingException?: never; + accessDeniedException?: never; + conflictException: ConflictException; + dependencyFailedException?: never; + badGatewayException?: never; + $unknown?: never; + } + + /** + * @public + * This exception is thrown when a request fails due to dependency like Lambda, Bedrock, STS resource due to a customer fault (i.e. bad configuration) + */ + export interface DependencyFailedExceptionMember { + chunk?: never; + trace?: never; + internalServerException?: never; + validationException?: never; + resourceNotFoundException?: never; + serviceQuotaExceededException?: never; + throttlingException?: never; + accessDeniedException?: never; + conflictException?: never; + dependencyFailedException: DependencyFailedException; + badGatewayException?: never; + $unknown?: never; + } + + /** + * @public + * This exception is thrown when a request fails due to dependency like Lambda, Bedrock, STS resource + */ + export interface BadGatewayExceptionMember { + chunk?: never; + trace?: never; + internalServerException?: never; + validationException?: never; + resourceNotFoundException?: never; + serviceQuotaExceededException?: never; + throttlingException?: never; + accessDeniedException?: never; + conflictException?: never; + dependencyFailedException?: never; + badGatewayException: BadGatewayException; + $unknown?: never; + } + + /** + * @public + */ + export interface $UnknownMember { + chunk?: never; + trace?: never; + internalServerException?: never; + validationException?: never; + resourceNotFoundException?: never; + serviceQuotaExceededException?: never; + throttlingException?: never; + accessDeniedException?: never; + conflictException?: never; + dependencyFailedException?: never; + badGatewayException?: never; + $unknown: [string, any]; + } + + export interface Visitor { + chunk: (value: PayloadPart) => T; + trace: (value: TracePart) => T; + internalServerException: (value: InternalServerException) => T; + validationException: (value: ValidationException) => T; + resourceNotFoundException: (value: ResourceNotFoundException) => T; + serviceQuotaExceededException: (value: ServiceQuotaExceededException) => T; + throttlingException: (value: ThrottlingException) => T; + accessDeniedException: (value: AccessDeniedException) => T; + conflictException: (value: ConflictException) => T; + dependencyFailedException: (value: DependencyFailedException) => T; + badGatewayException: (value: BadGatewayException) => T; + _: (name: string, value: any) => T; + } + + export const visit = (value: ResponseStream, visitor: Visitor): T => { + if (value.chunk !== undefined) return visitor.chunk(value.chunk); + if (value.trace !== undefined) return visitor.trace(value.trace); + if (value.internalServerException !== undefined) + return visitor.internalServerException(value.internalServerException); + if (value.validationException !== undefined) return visitor.validationException(value.validationException); + if (value.resourceNotFoundException !== undefined) + return visitor.resourceNotFoundException(value.resourceNotFoundException); + if (value.serviceQuotaExceededException !== undefined) + return visitor.serviceQuotaExceededException(value.serviceQuotaExceededException); + if (value.throttlingException !== undefined) return visitor.throttlingException(value.throttlingException); + if (value.accessDeniedException !== undefined) return visitor.accessDeniedException(value.accessDeniedException); + if (value.conflictException !== undefined) return visitor.conflictException(value.conflictException); + if (value.dependencyFailedException !== undefined) + return visitor.dependencyFailedException(value.dependencyFailedException); + if (value.badGatewayException !== undefined) return visitor.badGatewayException(value.badGatewayException); + return visitor._(value.$unknown[0], value.$unknown[1]); + }; +} + +/** + * @public + * InvokeAgent Response + */ +export interface InvokeAgentResponse { + /** + * @public + * Inference response from the model in the format specified in the Content-Type response header. + */ + completion: AsyncIterable | undefined; + + /** + * @public + * streaming response mimetype of the model + */ + contentType: string | undefined; + + /** + * @public + * streaming response mimetype of the model + */ + sessionId: string | undefined; +} + +/** + * @public + * Customer input of the turn + */ +export interface RetrieveAndGenerateInput { + /** + * @public + * Customer input of the turn in text + */ + text: string | undefined; +} + +/** + * @public + * Configurations for retrieval and generation for knowledge base. + */ +export interface KnowledgeBaseRetrieveAndGenerateConfiguration { + /** + * @public + * Identifier of the KnowledgeBase + */ + knowledgeBaseId: string | undefined; + + /** + * @public + * Arn of a Bedrock model. + */ + modelArn: string | undefined; +} + +/** + * @public + * @enum + */ +export const RetrieveAndGenerateType = { + KNOWLEDGE_BASE: "KNOWLEDGE_BASE", +} as const; + +/** + * @public + */ +export type RetrieveAndGenerateType = (typeof RetrieveAndGenerateType)[keyof typeof RetrieveAndGenerateType]; + +/** + * @public + * Configures the retrieval and generation for the session. + */ +export interface RetrieveAndGenerateConfiguration { + /** + * @public + * The type of RetrieveAndGenerate. + */ + type: RetrieveAndGenerateType | undefined; + + /** + * @public + * Configurations for retrieval and generation for knowledge base. + */ + knowledgeBaseConfiguration?: KnowledgeBaseRetrieveAndGenerateConfiguration; +} + +/** + * @public + * Configures common parameters of the session. + */ +export interface RetrieveAndGenerateSessionConfiguration { + /** + * @public + * The KMS key arn to encrypt the customer data of the session. + */ + kmsKeyArn: string | undefined; +} + +/** + * @public + */ +export interface RetrieveAndGenerateRequest { + /** + * @public + * Identifier of the session. + */ + sessionId?: string; + + /** + * @public + * Customer input of the turn + */ + input: RetrieveAndGenerateInput | undefined; + + /** + * @public + * Configures the retrieval and generation for the session. + */ + retrieveAndGenerateConfiguration?: RetrieveAndGenerateConfiguration; + + /** + * @public + * Configures common parameters of the session. + */ + sessionConfiguration?: RetrieveAndGenerateSessionConfiguration; +} + +/** + * @public + * Service response of the turn + */ +export interface RetrieveAndGenerateOutput { + /** + * @public + * Service response of the turn in text + */ + text: string | undefined; +} + +/** + * @public + */ +export interface RetrieveAndGenerateResponse { + /** + * @public + * Identifier of the session. + */ + sessionId: string | undefined; + + /** + * @public + * Service response of the turn + */ + output: RetrieveAndGenerateOutput | undefined; + + /** + * @public + * List of citations + */ + citations?: Citation[]; +} + +/** + * @public + * Knowledge base vector search configuration + */ +export interface KnowledgeBaseVectorSearchConfiguration { + /** + * @public + * Top-K results to retrieve from knowledge base. + */ + numberOfResults: number | undefined; +} + +/** + * @public + * Search parameters for retrieving from knowledge base. + */ +export interface KnowledgeBaseRetrievalConfiguration { + /** + * @public + * Knowledge base vector search configuration + */ + vectorSearchConfiguration: KnowledgeBaseVectorSearchConfiguration | undefined; +} + +/** + * @public + * Knowledge base input query. + */ +export interface KnowledgeBaseQuery { + /** + * @public + * Knowledge base input query in text + */ + text: string | undefined; +} + +/** + * @public + */ +export interface RetrieveRequest { + /** + * @public + * Identifier of the KnowledgeBase + */ + knowledgeBaseId: string | undefined; + + /** + * @public + * Knowledge base input query. + */ + retrievalQuery: KnowledgeBaseQuery | undefined; + + /** + * @public + * Search parameters for retrieving from knowledge base. + */ + retrievalConfiguration?: KnowledgeBaseRetrievalConfiguration; + + /** + * @public + * Opaque continuation token of previous paginated response. + */ + nextToken?: string; +} + +/** + * @public + * Result item returned from a knowledge base retrieval. + */ +export interface KnowledgeBaseRetrievalResult { + /** + * @public + * Content of a retrieval result. + */ + content: RetrievalResultContent | undefined; + + /** + * @public + * The source location of a retrieval result. + */ + location?: RetrievalResultLocation; + + /** + * @public + * The relevance score of a result. + */ + score?: number; +} + +/** + * @public + */ +export interface RetrieveResponse { + /** + * @public + * List of knowledge base retrieval results + */ + retrievalResults: KnowledgeBaseRetrievalResult[] | undefined; + + /** + * @public + * Opaque continuation token of previous paginated response. + */ + nextToken?: string; +} + +/** + * @internal + */ +export const ActionGroupInvocationInputFilterSensitiveLog = (obj: ActionGroupInvocationInput): any => ({ + ...obj, + ...(obj.actionGroupName && { actionGroupName: SENSITIVE_STRING }), + ...(obj.verb && { verb: SENSITIVE_STRING }), + ...(obj.apiPath && { apiPath: SENSITIVE_STRING }), +}); + +/** + * @internal + */ +export const ActionGroupInvocationOutputFilterSensitiveLog = (obj: ActionGroupInvocationOutput): any => ({ + ...obj, + ...(obj.text && { text: SENSITIVE_STRING }), +}); + +/** + * @internal + */ +export const InvokeAgentRequestFilterSensitiveLog = (obj: InvokeAgentRequest): any => ({ + ...obj, + ...(obj.inputText && { inputText: SENSITIVE_STRING }), +}); + +/** + * @internal + */ +export const PayloadPartFilterSensitiveLog = (obj: PayloadPart): any => ({ + ...obj, + ...(obj.bytes && { bytes: SENSITIVE_STRING }), +}); + +/** + * @internal + */ +export const FailureTraceFilterSensitiveLog = (obj: FailureTrace): any => ({ + ...obj, + ...(obj.failureReason && { failureReason: SENSITIVE_STRING }), +}); + +/** + * @internal + */ +export const KnowledgeBaseLookupInputFilterSensitiveLog = (obj: KnowledgeBaseLookupInput): any => ({ + ...obj, + ...(obj.text && { text: SENSITIVE_STRING }), + ...(obj.knowledgeBaseId && { knowledgeBaseId: SENSITIVE_STRING }), +}); + +/** + * @internal + */ +export const InvocationInputFilterSensitiveLog = (obj: InvocationInput): any => ({ + ...obj, + ...(obj.actionGroupInvocationInput && { + actionGroupInvocationInput: ActionGroupInvocationInputFilterSensitiveLog(obj.actionGroupInvocationInput), + }), + ...(obj.knowledgeBaseLookupInput && { + knowledgeBaseLookupInput: KnowledgeBaseLookupInputFilterSensitiveLog(obj.knowledgeBaseLookupInput), + }), +}); + +/** + * @internal + */ +export const ModelInvocationInputFilterSensitiveLog = (obj: ModelInvocationInput): any => ({ + ...obj, + ...(obj.text && { text: SENSITIVE_STRING }), +}); + +/** + * @internal + */ +export const FinalResponseFilterSensitiveLog = (obj: FinalResponse): any => ({ + ...obj, + ...(obj.text && { text: SENSITIVE_STRING }), +}); + +/** + * @internal + */ +export const RepromptResponseFilterSensitiveLog = (obj: RepromptResponse): any => ({ + ...obj, + ...(obj.source && { source: SENSITIVE_STRING }), +}); + +/** + * @internal + */ +export const ObservationFilterSensitiveLog = (obj: Observation): any => ({ + ...obj, + ...(obj.actionGroupInvocationOutput && { + actionGroupInvocationOutput: ActionGroupInvocationOutputFilterSensitiveLog(obj.actionGroupInvocationOutput), + }), + ...(obj.finalResponse && { finalResponse: FinalResponseFilterSensitiveLog(obj.finalResponse) }), + ...(obj.repromptResponse && { repromptResponse: SENSITIVE_STRING }), +}); + +/** + * @internal + */ +export const RationaleFilterSensitiveLog = (obj: Rationale): any => ({ + ...obj, + ...(obj.text && { text: SENSITIVE_STRING }), +}); + +/** + * @internal + */ +export const OrchestrationTraceFilterSensitiveLog = (obj: OrchestrationTrace): any => { + if (obj.rationale !== undefined) return { rationale: SENSITIVE_STRING }; + if (obj.invocationInput !== undefined) return { invocationInput: SENSITIVE_STRING }; + if (obj.observation !== undefined) return { observation: SENSITIVE_STRING }; + if (obj.modelInvocationInput !== undefined) return { modelInvocationInput: SENSITIVE_STRING }; + if (obj.$unknown !== undefined) return { [obj.$unknown[0]]: "UNKNOWN" }; +}; + +/** + * @internal + */ +export const PostProcessingParsedResponseFilterSensitiveLog = (obj: PostProcessingParsedResponse): any => ({ + ...obj, + ...(obj.text && { text: SENSITIVE_STRING }), +}); + +/** + * @internal + */ +export const PostProcessingModelInvocationOutputFilterSensitiveLog = ( + obj: PostProcessingModelInvocationOutput +): any => ({ + ...obj, + ...(obj.parsedResponse && { parsedResponse: SENSITIVE_STRING }), +}); + +/** + * @internal + */ +export const PostProcessingTraceFilterSensitiveLog = (obj: PostProcessingTrace): any => { + if (obj.modelInvocationInput !== undefined) return { modelInvocationInput: SENSITIVE_STRING }; + if (obj.modelInvocationOutput !== undefined) return { modelInvocationOutput: SENSITIVE_STRING }; + if (obj.$unknown !== undefined) return { [obj.$unknown[0]]: "UNKNOWN" }; +}; + +/** + * @internal + */ +export const PreProcessingParsedResponseFilterSensitiveLog = (obj: PreProcessingParsedResponse): any => ({ + ...obj, + ...(obj.rationale && { rationale: SENSITIVE_STRING }), +}); + +/** + * @internal + */ +export const PreProcessingModelInvocationOutputFilterSensitiveLog = (obj: PreProcessingModelInvocationOutput): any => ({ + ...obj, + ...(obj.parsedResponse && { parsedResponse: SENSITIVE_STRING }), +}); + +/** + * @internal + */ +export const PreProcessingTraceFilterSensitiveLog = (obj: PreProcessingTrace): any => { + if (obj.modelInvocationInput !== undefined) return { modelInvocationInput: SENSITIVE_STRING }; + if (obj.modelInvocationOutput !== undefined) return { modelInvocationOutput: SENSITIVE_STRING }; + if (obj.$unknown !== undefined) return { [obj.$unknown[0]]: "UNKNOWN" }; +}; + +/** + * @internal + */ +export const TraceFilterSensitiveLog = (obj: Trace): any => { + if (obj.preProcessingTrace !== undefined) return { preProcessingTrace: SENSITIVE_STRING }; + if (obj.orchestrationTrace !== undefined) return { orchestrationTrace: SENSITIVE_STRING }; + if (obj.postProcessingTrace !== undefined) return { postProcessingTrace: SENSITIVE_STRING }; + if (obj.failureTrace !== undefined) return { failureTrace: SENSITIVE_STRING }; + if (obj.$unknown !== undefined) return { [obj.$unknown[0]]: "UNKNOWN" }; +}; + +/** + * @internal + */ +export const TracePartFilterSensitiveLog = (obj: TracePart): any => ({ + ...obj, + ...(obj.trace && { trace: SENSITIVE_STRING }), +}); + +/** + * @internal + */ +export const ResponseStreamFilterSensitiveLog = (obj: ResponseStream): any => { + if (obj.chunk !== undefined) return { chunk: SENSITIVE_STRING }; + if (obj.trace !== undefined) return { trace: SENSITIVE_STRING }; + if (obj.internalServerException !== undefined) return { internalServerException: obj.internalServerException }; + if (obj.validationException !== undefined) return { validationException: obj.validationException }; + if (obj.resourceNotFoundException !== undefined) return { resourceNotFoundException: obj.resourceNotFoundException }; + if (obj.serviceQuotaExceededException !== undefined) + return { serviceQuotaExceededException: obj.serviceQuotaExceededException }; + if (obj.throttlingException !== undefined) return { throttlingException: obj.throttlingException }; + if (obj.accessDeniedException !== undefined) return { accessDeniedException: obj.accessDeniedException }; + if (obj.conflictException !== undefined) return { conflictException: obj.conflictException }; + if (obj.dependencyFailedException !== undefined) return { dependencyFailedException: obj.dependencyFailedException }; + if (obj.badGatewayException !== undefined) return { badGatewayException: obj.badGatewayException }; + if (obj.$unknown !== undefined) return { [obj.$unknown[0]]: "UNKNOWN" }; +}; + +/** + * @internal + */ +export const InvokeAgentResponseFilterSensitiveLog = (obj: InvokeAgentResponse): any => ({ + ...obj, + ...(obj.completion && { completion: "STREAMING_CONTENT" }), +}); + +/** + * @internal + */ +export const RetrieveAndGenerateInputFilterSensitiveLog = (obj: RetrieveAndGenerateInput): any => ({ + ...obj, +}); + +/** + * @internal + */ +export const RetrieveAndGenerateRequestFilterSensitiveLog = (obj: RetrieveAndGenerateRequest): any => ({ + ...obj, + ...(obj.input && { input: SENSITIVE_STRING }), +}); + +/** + * @internal + */ +export const RetrieveAndGenerateOutputFilterSensitiveLog = (obj: RetrieveAndGenerateOutput): any => ({ + ...obj, +}); + +/** + * @internal + */ +export const RetrieveAndGenerateResponseFilterSensitiveLog = (obj: RetrieveAndGenerateResponse): any => ({ + ...obj, + ...(obj.output && { output: SENSITIVE_STRING }), +}); + +/** + * @internal + */ +export const KnowledgeBaseQueryFilterSensitiveLog = (obj: KnowledgeBaseQuery): any => ({ + ...obj, +}); + +/** + * @internal + */ +export const RetrieveRequestFilterSensitiveLog = (obj: RetrieveRequest): any => ({ + ...obj, + ...(obj.retrievalQuery && { retrievalQuery: SENSITIVE_STRING }), +}); + +/** + * @internal + */ +export const RetrieveResponseFilterSensitiveLog = (obj: RetrieveResponse): any => ({ + ...obj, + ...(obj.retrievalResults && { retrievalResults: SENSITIVE_STRING }), +}); diff --git a/clients/client-bedrock-agent-runtime/src/pagination/Interfaces.ts b/clients/client-bedrock-agent-runtime/src/pagination/Interfaces.ts new file mode 100644 index 000000000000..230c24280714 --- /dev/null +++ b/clients/client-bedrock-agent-runtime/src/pagination/Interfaces.ts @@ -0,0 +1,11 @@ +// smithy-typescript generated code +import { PaginationConfiguration } from "@smithy/types"; + +import { BedrockAgentRuntimeClient } from "../BedrockAgentRuntimeClient"; + +/** + * @public + */ +export interface BedrockAgentRuntimePaginationConfiguration extends PaginationConfiguration { + client: BedrockAgentRuntimeClient; +} diff --git a/clients/client-bedrock-agent-runtime/src/pagination/RetrievePaginator.ts b/clients/client-bedrock-agent-runtime/src/pagination/RetrievePaginator.ts new file mode 100644 index 000000000000..a79865b40100 --- /dev/null +++ b/clients/client-bedrock-agent-runtime/src/pagination/RetrievePaginator.ts @@ -0,0 +1,45 @@ +// smithy-typescript generated code +import { Paginator } from "@smithy/types"; + +import { BedrockAgentRuntimeClient } from "../BedrockAgentRuntimeClient"; +import { RetrieveCommand, RetrieveCommandInput, RetrieveCommandOutput } from "../commands/RetrieveCommand"; +import { BedrockAgentRuntimePaginationConfiguration } from "./Interfaces"; + +/** + * @internal + */ +const makePagedClientRequest = async ( + client: BedrockAgentRuntimeClient, + input: RetrieveCommandInput, + ...args: any +): Promise => { + // @ts-ignore + return await client.send(new RetrieveCommand(input), ...args); +}; +/** + * @public + */ +export async function* paginateRetrieve( + config: BedrockAgentRuntimePaginationConfiguration, + input: RetrieveCommandInput, + ...additionalArguments: any +): Paginator { + // ToDo: replace with actual type instead of typeof input.nextToken + let token: typeof input.nextToken | undefined = config.startingToken || undefined; + let hasNext = true; + let page: RetrieveCommandOutput; + while (hasNext) { + input.nextToken = token; + if (config.client instanceof BedrockAgentRuntimeClient) { + page = await makePagedClientRequest(config.client, input, ...additionalArguments); + } else { + throw new Error("Invalid client, expected BedrockAgentRuntime | BedrockAgentRuntimeClient"); + } + yield page; + const prevToken = token; + token = page.nextToken; + hasNext = !!(token && (!config.stopOnSameToken || token !== prevToken)); + } + // @ts-ignore + return undefined; +} diff --git a/clients/client-bedrock-agent-runtime/src/pagination/index.ts b/clients/client-bedrock-agent-runtime/src/pagination/index.ts new file mode 100644 index 000000000000..13f7ad2087e8 --- /dev/null +++ b/clients/client-bedrock-agent-runtime/src/pagination/index.ts @@ -0,0 +1,3 @@ +// smithy-typescript generated code +export * from "./Interfaces"; +export * from "./RetrievePaginator"; diff --git a/clients/client-bedrock-agent-runtime/src/protocols/Aws_restJson1.ts b/clients/client-bedrock-agent-runtime/src/protocols/Aws_restJson1.ts new file mode 100644 index 000000000000..5397d102ad6d --- /dev/null +++ b/clients/client-bedrock-agent-runtime/src/protocols/Aws_restJson1.ts @@ -0,0 +1,1039 @@ +// smithy-typescript generated code +import { awsExpectUnion as __expectUnion } from "@aws-sdk/core"; +import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@smithy/protocol-http"; +import { + _json, + collectBody, + decorateServiceException as __decorateServiceException, + expectInt32 as __expectInt32, + expectNonNull as __expectNonNull, + expectObject as __expectObject, + expectString as __expectString, + limitedParseDouble as __limitedParseDouble, + limitedParseFloat32 as __limitedParseFloat32, + map, + resolvedPath as __resolvedPath, + take, + withBaseException, +} from "@smithy/smithy-client"; +import { + Endpoint as __Endpoint, + EventStreamSerdeContext as __EventStreamSerdeContext, + ResponseMetadata as __ResponseMetadata, + SerdeContext as __SerdeContext, +} from "@smithy/types"; + +import { InvokeAgentCommandInput, InvokeAgentCommandOutput } from "../commands/InvokeAgentCommand"; +import { + RetrieveAndGenerateCommandInput, + RetrieveAndGenerateCommandOutput, +} from "../commands/RetrieveAndGenerateCommand"; +import { RetrieveCommandInput, RetrieveCommandOutput } from "../commands/RetrieveCommand"; +import { BedrockAgentRuntimeServiceException as __BaseException } from "../models/BedrockAgentRuntimeServiceException"; +import { + AccessDeniedException, + BadGatewayException, + ConflictException, + DependencyFailedException, + InferenceConfiguration, + InternalServerException, + KnowledgeBaseQuery, + KnowledgeBaseRetrievalConfiguration, + KnowledgeBaseRetrievalResult, + KnowledgeBaseRetrieveAndGenerateConfiguration, + KnowledgeBaseVectorSearchConfiguration, + ModelInvocationInput, + OrchestrationTrace, + PayloadPart, + PostProcessingTrace, + PreProcessingTrace, + ResourceNotFoundException, + ResponseStream, + RetrieveAndGenerateConfiguration, + RetrieveAndGenerateInput, + RetrieveAndGenerateSessionConfiguration, + ServiceQuotaExceededException, + SessionState, + ThrottlingException, + Trace, + TracePart, + ValidationException, +} from "../models/models_0"; + +/** + * serializeAws_restJson1InvokeAgentCommand + */ +export const se_InvokeAgentCommand = async ( + input: InvokeAgentCommandInput, + context: __SerdeContext +): Promise<__HttpRequest> => { + const { hostname, protocol = "https", port, path: basePath } = await context.endpoint(); + const headers: any = { + "content-type": "application/json", + }; + let resolvedPath = + `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + + "/agents/{agentId}/agentAliases/{agentAliasId}/sessions/{sessionId}/text"; + resolvedPath = __resolvedPath(resolvedPath, input, "agentId", () => input.agentId!, "{agentId}", false); + resolvedPath = __resolvedPath( + resolvedPath, + input, + "agentAliasId", + () => input.agentAliasId!, + "{agentAliasId}", + false + ); + resolvedPath = __resolvedPath(resolvedPath, input, "sessionId", () => input.sessionId!, "{sessionId}", false); + let body: any; + body = JSON.stringify( + take(input, { + enableTrace: [], + endSession: [], + inputText: [], + sessionState: (_) => _json(_), + }) + ); + return new __HttpRequest({ + protocol, + hostname, + port, + method: "POST", + headers, + path: resolvedPath, + body, + }); +}; + +/** + * serializeAws_restJson1RetrieveCommand + */ +export const se_RetrieveCommand = async ( + input: RetrieveCommandInput, + context: __SerdeContext +): Promise<__HttpRequest> => { + const { hostname, protocol = "https", port, path: basePath } = await context.endpoint(); + const headers: any = { + "content-type": "application/json", + }; + let resolvedPath = + `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + + "/knowledgebases/{knowledgeBaseId}/retrieve"; + resolvedPath = __resolvedPath( + resolvedPath, + input, + "knowledgeBaseId", + () => input.knowledgeBaseId!, + "{knowledgeBaseId}", + false + ); + let body: any; + body = JSON.stringify( + take(input, { + nextToken: [], + retrievalConfiguration: (_) => _json(_), + retrievalQuery: (_) => _json(_), + }) + ); + return new __HttpRequest({ + protocol, + hostname, + port, + method: "POST", + headers, + path: resolvedPath, + body, + }); +}; + +/** + * serializeAws_restJson1RetrieveAndGenerateCommand + */ +export const se_RetrieveAndGenerateCommand = async ( + input: RetrieveAndGenerateCommandInput, + context: __SerdeContext +): Promise<__HttpRequest> => { + const { hostname, protocol = "https", port, path: basePath } = await context.endpoint(); + const headers: any = { + "content-type": "application/json", + }; + const resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/retrieveAndGenerate"; + let body: any; + body = JSON.stringify( + take(input, { + input: (_) => _json(_), + retrieveAndGenerateConfiguration: (_) => _json(_), + sessionConfiguration: (_) => _json(_), + sessionId: [], + }) + ); + return new __HttpRequest({ + protocol, + hostname, + port, + method: "POST", + headers, + path: resolvedPath, + body, + }); +}; + +/** + * deserializeAws_restJson1InvokeAgentCommand + */ +export const de_InvokeAgentCommand = async ( + output: __HttpResponse, + context: __SerdeContext & __EventStreamSerdeContext +): Promise => { + if (output.statusCode !== 200 && output.statusCode >= 300) { + return de_InvokeAgentCommandError(output, context); + } + const contents: any = map({ + $metadata: deserializeMetadata(output), + contentType: [, output.headers["x-amzn-bedrock-agent-content-type"]], + sessionId: [, output.headers["x-amz-bedrock-agent-session-id"]], + }); + const data: any = output.body; + contents.completion = de_ResponseStream(data, context); + return contents; +}; + +/** + * deserializeAws_restJson1InvokeAgentCommandError + */ +const de_InvokeAgentCommandError = async ( + output: __HttpResponse, + context: __SerdeContext +): Promise => { + const parsedOutput: any = { + ...output, + body: await parseErrorBody(output.body, context), + }; + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + switch (errorCode) { + case "AccessDeniedException": + case "com.amazonaws.bedrockagentruntime#AccessDeniedException": + throw await de_AccessDeniedExceptionRes(parsedOutput, context); + case "BadGatewayException": + case "com.amazonaws.bedrockagentruntime#BadGatewayException": + throw await de_BadGatewayExceptionRes(parsedOutput, context); + case "ConflictException": + case "com.amazonaws.bedrockagentruntime#ConflictException": + throw await de_ConflictExceptionRes(parsedOutput, context); + case "DependencyFailedException": + case "com.amazonaws.bedrockagentruntime#DependencyFailedException": + throw await de_DependencyFailedExceptionRes(parsedOutput, context); + case "InternalServerException": + case "com.amazonaws.bedrockagentruntime#InternalServerException": + throw await de_InternalServerExceptionRes(parsedOutput, context); + case "ResourceNotFoundException": + case "com.amazonaws.bedrockagentruntime#ResourceNotFoundException": + throw await de_ResourceNotFoundExceptionRes(parsedOutput, context); + case "ServiceQuotaExceededException": + case "com.amazonaws.bedrockagentruntime#ServiceQuotaExceededException": + throw await de_ServiceQuotaExceededExceptionRes(parsedOutput, context); + case "ThrottlingException": + case "com.amazonaws.bedrockagentruntime#ThrottlingException": + throw await de_ThrottlingExceptionRes(parsedOutput, context); + case "ValidationException": + case "com.amazonaws.bedrockagentruntime#ValidationException": + throw await de_ValidationExceptionRes(parsedOutput, context); + default: + const parsedBody = parsedOutput.body; + return throwDefaultError({ + output, + parsedBody, + errorCode, + }); + } +}; + +/** + * deserializeAws_restJson1RetrieveCommand + */ +export const de_RetrieveCommand = async ( + output: __HttpResponse, + context: __SerdeContext +): Promise => { + if (output.statusCode !== 200 && output.statusCode >= 300) { + return de_RetrieveCommandError(output, context); + } + const contents: any = map({ + $metadata: deserializeMetadata(output), + }); + const data: Record = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body"); + const doc = take(data, { + nextToken: __expectString, + retrievalResults: (_) => de_KnowledgeBaseRetrievalResults(_, context), + }); + Object.assign(contents, doc); + return contents; +}; + +/** + * deserializeAws_restJson1RetrieveCommandError + */ +const de_RetrieveCommandError = async ( + output: __HttpResponse, + context: __SerdeContext +): Promise => { + const parsedOutput: any = { + ...output, + body: await parseErrorBody(output.body, context), + }; + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + switch (errorCode) { + case "AccessDeniedException": + case "com.amazonaws.bedrockagentruntime#AccessDeniedException": + throw await de_AccessDeniedExceptionRes(parsedOutput, context); + case "BadGatewayException": + case "com.amazonaws.bedrockagentruntime#BadGatewayException": + throw await de_BadGatewayExceptionRes(parsedOutput, context); + case "ConflictException": + case "com.amazonaws.bedrockagentruntime#ConflictException": + throw await de_ConflictExceptionRes(parsedOutput, context); + case "DependencyFailedException": + case "com.amazonaws.bedrockagentruntime#DependencyFailedException": + throw await de_DependencyFailedExceptionRes(parsedOutput, context); + case "InternalServerException": + case "com.amazonaws.bedrockagentruntime#InternalServerException": + throw await de_InternalServerExceptionRes(parsedOutput, context); + case "ResourceNotFoundException": + case "com.amazonaws.bedrockagentruntime#ResourceNotFoundException": + throw await de_ResourceNotFoundExceptionRes(parsedOutput, context); + case "ServiceQuotaExceededException": + case "com.amazonaws.bedrockagentruntime#ServiceQuotaExceededException": + throw await de_ServiceQuotaExceededExceptionRes(parsedOutput, context); + case "ThrottlingException": + case "com.amazonaws.bedrockagentruntime#ThrottlingException": + throw await de_ThrottlingExceptionRes(parsedOutput, context); + case "ValidationException": + case "com.amazonaws.bedrockagentruntime#ValidationException": + throw await de_ValidationExceptionRes(parsedOutput, context); + default: + const parsedBody = parsedOutput.body; + return throwDefaultError({ + output, + parsedBody, + errorCode, + }); + } +}; + +/** + * deserializeAws_restJson1RetrieveAndGenerateCommand + */ +export const de_RetrieveAndGenerateCommand = async ( + output: __HttpResponse, + context: __SerdeContext +): Promise => { + if (output.statusCode !== 200 && output.statusCode >= 300) { + return de_RetrieveAndGenerateCommandError(output, context); + } + const contents: any = map({ + $metadata: deserializeMetadata(output), + }); + const data: Record = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body"); + const doc = take(data, { + citations: _json, + output: _json, + sessionId: __expectString, + }); + Object.assign(contents, doc); + return contents; +}; + +/** + * deserializeAws_restJson1RetrieveAndGenerateCommandError + */ +const de_RetrieveAndGenerateCommandError = async ( + output: __HttpResponse, + context: __SerdeContext +): Promise => { + const parsedOutput: any = { + ...output, + body: await parseErrorBody(output.body, context), + }; + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + switch (errorCode) { + case "AccessDeniedException": + case "com.amazonaws.bedrockagentruntime#AccessDeniedException": + throw await de_AccessDeniedExceptionRes(parsedOutput, context); + case "BadGatewayException": + case "com.amazonaws.bedrockagentruntime#BadGatewayException": + throw await de_BadGatewayExceptionRes(parsedOutput, context); + case "ConflictException": + case "com.amazonaws.bedrockagentruntime#ConflictException": + throw await de_ConflictExceptionRes(parsedOutput, context); + case "DependencyFailedException": + case "com.amazonaws.bedrockagentruntime#DependencyFailedException": + throw await de_DependencyFailedExceptionRes(parsedOutput, context); + case "InternalServerException": + case "com.amazonaws.bedrockagentruntime#InternalServerException": + throw await de_InternalServerExceptionRes(parsedOutput, context); + case "ResourceNotFoundException": + case "com.amazonaws.bedrockagentruntime#ResourceNotFoundException": + throw await de_ResourceNotFoundExceptionRes(parsedOutput, context); + case "ServiceQuotaExceededException": + case "com.amazonaws.bedrockagentruntime#ServiceQuotaExceededException": + throw await de_ServiceQuotaExceededExceptionRes(parsedOutput, context); + case "ThrottlingException": + case "com.amazonaws.bedrockagentruntime#ThrottlingException": + throw await de_ThrottlingExceptionRes(parsedOutput, context); + case "ValidationException": + case "com.amazonaws.bedrockagentruntime#ValidationException": + throw await de_ValidationExceptionRes(parsedOutput, context); + default: + const parsedBody = parsedOutput.body; + return throwDefaultError({ + output, + parsedBody, + errorCode, + }); + } +}; + +const throwDefaultError = withBaseException(__BaseException); +/** + * deserializeAws_restJson1AccessDeniedExceptionRes + */ +const de_AccessDeniedExceptionRes = async ( + parsedOutput: any, + context: __SerdeContext +): Promise => { + const contents: any = map({}); + const data: any = parsedOutput.body; + const doc = take(data, { + message: __expectString, + }); + Object.assign(contents, doc); + const exception = new AccessDeniedException({ + $metadata: deserializeMetadata(parsedOutput), + ...contents, + }); + return __decorateServiceException(exception, parsedOutput.body); +}; + +/** + * deserializeAws_restJson1BadGatewayExceptionRes + */ +const de_BadGatewayExceptionRes = async (parsedOutput: any, context: __SerdeContext): Promise => { + const contents: any = map({}); + const data: any = parsedOutput.body; + const doc = take(data, { + message: __expectString, + resourceName: __expectString, + }); + Object.assign(contents, doc); + const exception = new BadGatewayException({ + $metadata: deserializeMetadata(parsedOutput), + ...contents, + }); + return __decorateServiceException(exception, parsedOutput.body); +}; + +/** + * deserializeAws_restJson1ConflictExceptionRes + */ +const de_ConflictExceptionRes = async (parsedOutput: any, context: __SerdeContext): Promise => { + const contents: any = map({}); + const data: any = parsedOutput.body; + const doc = take(data, { + message: __expectString, + }); + Object.assign(contents, doc); + const exception = new ConflictException({ + $metadata: deserializeMetadata(parsedOutput), + ...contents, + }); + return __decorateServiceException(exception, parsedOutput.body); +}; + +/** + * deserializeAws_restJson1DependencyFailedExceptionRes + */ +const de_DependencyFailedExceptionRes = async ( + parsedOutput: any, + context: __SerdeContext +): Promise => { + const contents: any = map({}); + const data: any = parsedOutput.body; + const doc = take(data, { + message: __expectString, + resourceName: __expectString, + }); + Object.assign(contents, doc); + const exception = new DependencyFailedException({ + $metadata: deserializeMetadata(parsedOutput), + ...contents, + }); + return __decorateServiceException(exception, parsedOutput.body); +}; + +/** + * deserializeAws_restJson1InternalServerExceptionRes + */ +const de_InternalServerExceptionRes = async ( + parsedOutput: any, + context: __SerdeContext +): Promise => { + const contents: any = map({}); + const data: any = parsedOutput.body; + const doc = take(data, { + message: __expectString, + }); + Object.assign(contents, doc); + const exception = new InternalServerException({ + $metadata: deserializeMetadata(parsedOutput), + ...contents, + }); + return __decorateServiceException(exception, parsedOutput.body); +}; + +/** + * deserializeAws_restJson1ResourceNotFoundExceptionRes + */ +const de_ResourceNotFoundExceptionRes = async ( + parsedOutput: any, + context: __SerdeContext +): Promise => { + const contents: any = map({}); + const data: any = parsedOutput.body; + const doc = take(data, { + message: __expectString, + }); + Object.assign(contents, doc); + const exception = new ResourceNotFoundException({ + $metadata: deserializeMetadata(parsedOutput), + ...contents, + }); + return __decorateServiceException(exception, parsedOutput.body); +}; + +/** + * deserializeAws_restJson1ServiceQuotaExceededExceptionRes + */ +const de_ServiceQuotaExceededExceptionRes = async ( + parsedOutput: any, + context: __SerdeContext +): Promise => { + const contents: any = map({}); + const data: any = parsedOutput.body; + const doc = take(data, { + message: __expectString, + }); + Object.assign(contents, doc); + const exception = new ServiceQuotaExceededException({ + $metadata: deserializeMetadata(parsedOutput), + ...contents, + }); + return __decorateServiceException(exception, parsedOutput.body); +}; + +/** + * deserializeAws_restJson1ThrottlingExceptionRes + */ +const de_ThrottlingExceptionRes = async (parsedOutput: any, context: __SerdeContext): Promise => { + const contents: any = map({}); + const data: any = parsedOutput.body; + const doc = take(data, { + message: __expectString, + }); + Object.assign(contents, doc); + const exception = new ThrottlingException({ + $metadata: deserializeMetadata(parsedOutput), + ...contents, + }); + return __decorateServiceException(exception, parsedOutput.body); +}; + +/** + * deserializeAws_restJson1ValidationExceptionRes + */ +const de_ValidationExceptionRes = async (parsedOutput: any, context: __SerdeContext): Promise => { + const contents: any = map({}); + const data: any = parsedOutput.body; + const doc = take(data, { + message: __expectString, + }); + Object.assign(contents, doc); + const exception = new ValidationException({ + $metadata: deserializeMetadata(parsedOutput), + ...contents, + }); + return __decorateServiceException(exception, parsedOutput.body); +}; + +/** + * deserializeAws_restJson1ResponseStream + */ +const de_ResponseStream = ( + output: any, + context: __SerdeContext & __EventStreamSerdeContext +): AsyncIterable => { + return context.eventStreamMarshaller.deserialize(output, async (event) => { + if (event["chunk"] != null) { + return { + chunk: await de_PayloadPart_event(event["chunk"], context), + }; + } + if (event["trace"] != null) { + return { + trace: await de_TracePart_event(event["trace"], context), + }; + } + if (event["internalServerException"] != null) { + return { + internalServerException: await de_InternalServerException_event(event["internalServerException"], context), + }; + } + if (event["validationException"] != null) { + return { + validationException: await de_ValidationException_event(event["validationException"], context), + }; + } + if (event["resourceNotFoundException"] != null) { + return { + resourceNotFoundException: await de_ResourceNotFoundException_event( + event["resourceNotFoundException"], + context + ), + }; + } + if (event["serviceQuotaExceededException"] != null) { + return { + serviceQuotaExceededException: await de_ServiceQuotaExceededException_event( + event["serviceQuotaExceededException"], + context + ), + }; + } + if (event["throttlingException"] != null) { + return { + throttlingException: await de_ThrottlingException_event(event["throttlingException"], context), + }; + } + if (event["accessDeniedException"] != null) { + return { + accessDeniedException: await de_AccessDeniedException_event(event["accessDeniedException"], context), + }; + } + if (event["conflictException"] != null) { + return { + conflictException: await de_ConflictException_event(event["conflictException"], context), + }; + } + if (event["dependencyFailedException"] != null) { + return { + dependencyFailedException: await de_DependencyFailedException_event( + event["dependencyFailedException"], + context + ), + }; + } + if (event["badGatewayException"] != null) { + return { + badGatewayException: await de_BadGatewayException_event(event["badGatewayException"], context), + }; + } + return { $unknown: output }; + }); +}; +const de_AccessDeniedException_event = async (output: any, context: __SerdeContext): Promise => { + const parsedOutput: any = { + ...output, + body: await parseBody(output.body, context), + }; + return de_AccessDeniedExceptionRes(parsedOutput, context); +}; +const de_BadGatewayException_event = async (output: any, context: __SerdeContext): Promise => { + const parsedOutput: any = { + ...output, + body: await parseBody(output.body, context), + }; + return de_BadGatewayExceptionRes(parsedOutput, context); +}; +const de_ConflictException_event = async (output: any, context: __SerdeContext): Promise => { + const parsedOutput: any = { + ...output, + body: await parseBody(output.body, context), + }; + return de_ConflictExceptionRes(parsedOutput, context); +}; +const de_DependencyFailedException_event = async ( + output: any, + context: __SerdeContext +): Promise => { + const parsedOutput: any = { + ...output, + body: await parseBody(output.body, context), + }; + return de_DependencyFailedExceptionRes(parsedOutput, context); +}; +const de_InternalServerException_event = async ( + output: any, + context: __SerdeContext +): Promise => { + const parsedOutput: any = { + ...output, + body: await parseBody(output.body, context), + }; + return de_InternalServerExceptionRes(parsedOutput, context); +}; +const de_PayloadPart_event = async (output: any, context: __SerdeContext): Promise => { + const contents: PayloadPart = {} as any; + const data: any = await parseBody(output.body, context); + Object.assign(contents, de_PayloadPart(data, context)); + return contents; +}; +const de_ResourceNotFoundException_event = async ( + output: any, + context: __SerdeContext +): Promise => { + const parsedOutput: any = { + ...output, + body: await parseBody(output.body, context), + }; + return de_ResourceNotFoundExceptionRes(parsedOutput, context); +}; +const de_ServiceQuotaExceededException_event = async ( + output: any, + context: __SerdeContext +): Promise => { + const parsedOutput: any = { + ...output, + body: await parseBody(output.body, context), + }; + return de_ServiceQuotaExceededExceptionRes(parsedOutput, context); +}; +const de_ThrottlingException_event = async (output: any, context: __SerdeContext): Promise => { + const parsedOutput: any = { + ...output, + body: await parseBody(output.body, context), + }; + return de_ThrottlingExceptionRes(parsedOutput, context); +}; +const de_TracePart_event = async (output: any, context: __SerdeContext): Promise => { + const contents: TracePart = {} as any; + const data: any = await parseBody(output.body, context); + Object.assign(contents, de_TracePart(data, context)); + return contents; +}; +const de_ValidationException_event = async (output: any, context: __SerdeContext): Promise => { + const parsedOutput: any = { + ...output, + body: await parseBody(output.body, context), + }; + return de_ValidationExceptionRes(parsedOutput, context); +}; +// se_KnowledgeBaseQuery omitted. + +// se_KnowledgeBaseRetrievalConfiguration omitted. + +// se_KnowledgeBaseRetrieveAndGenerateConfiguration omitted. + +// se_KnowledgeBaseVectorSearchConfiguration omitted. + +// se_PromptSessionAttributesMap omitted. + +// se_RetrieveAndGenerateConfiguration omitted. + +// se_RetrieveAndGenerateInput omitted. + +// se_RetrieveAndGenerateSessionConfiguration omitted. + +// se_SessionAttributesMap omitted. + +// se_SessionState omitted. + +// de_ActionGroupInvocationInput omitted. + +// de_ActionGroupInvocationOutput omitted. + +// de_Attribution omitted. + +// de_Citation omitted. + +// de_Citations omitted. + +// de_ContentMap omitted. + +// de_FailureTrace omitted. + +// de_FinalResponse omitted. + +// de_GeneratedResponsePart omitted. + +/** + * deserializeAws_restJson1InferenceConfiguration + */ +const de_InferenceConfiguration = (output: any, context: __SerdeContext): InferenceConfiguration => { + return take(output, { + maximumLength: __expectInt32, + stopSequences: _json, + temperature: __limitedParseFloat32, + topK: __expectInt32, + topP: __limitedParseFloat32, + }) as any; +}; + +// de_InvocationInput omitted. + +// de_KnowledgeBaseLookupInput omitted. + +// de_KnowledgeBaseLookupOutput omitted. + +/** + * deserializeAws_restJson1KnowledgeBaseRetrievalResult + */ +const de_KnowledgeBaseRetrievalResult = (output: any, context: __SerdeContext): KnowledgeBaseRetrievalResult => { + return take(output, { + content: _json, + location: _json, + score: __limitedParseDouble, + }) as any; +}; + +/** + * deserializeAws_restJson1KnowledgeBaseRetrievalResults + */ +const de_KnowledgeBaseRetrievalResults = (output: any, context: __SerdeContext): KnowledgeBaseRetrievalResult[] => { + const retVal = (output || []) + .filter((e: any) => e != null) + .map((entry: any) => { + return de_KnowledgeBaseRetrievalResult(entry, context); + }); + return retVal; +}; + +/** + * deserializeAws_restJson1ModelInvocationInput + */ +const de_ModelInvocationInput = (output: any, context: __SerdeContext): ModelInvocationInput => { + return take(output, { + inferenceConfiguration: (_: any) => de_InferenceConfiguration(_, context), + overrideLambda: __expectString, + parserMode: __expectString, + promptCreationMode: __expectString, + text: __expectString, + traceId: __expectString, + type: __expectString, + }) as any; +}; + +// de_Observation omitted. + +/** + * deserializeAws_restJson1OrchestrationTrace + */ +const de_OrchestrationTrace = (output: any, context: __SerdeContext): OrchestrationTrace => { + if (output.invocationInput != null) { + return { + invocationInput: _json(output.invocationInput), + }; + } + if (output.modelInvocationInput != null) { + return { + modelInvocationInput: de_ModelInvocationInput(output.modelInvocationInput, context), + }; + } + if (output.observation != null) { + return { + observation: _json(output.observation), + }; + } + if (output.rationale != null) { + return { + rationale: _json(output.rationale), + }; + } + return { $unknown: Object.entries(output)[0] }; +}; + +// de_Parameter omitted. + +// de_Parameters omitted. + +/** + * deserializeAws_restJson1PayloadPart + */ +const de_PayloadPart = (output: any, context: __SerdeContext): PayloadPart => { + return take(output, { + attribution: _json, + bytes: context.base64Decoder, + }) as any; +}; + +// de_PostProcessingModelInvocationOutput omitted. + +// de_PostProcessingParsedResponse omitted. + +/** + * deserializeAws_restJson1PostProcessingTrace + */ +const de_PostProcessingTrace = (output: any, context: __SerdeContext): PostProcessingTrace => { + if (output.modelInvocationInput != null) { + return { + modelInvocationInput: de_ModelInvocationInput(output.modelInvocationInput, context), + }; + } + if (output.modelInvocationOutput != null) { + return { + modelInvocationOutput: _json(output.modelInvocationOutput), + }; + } + return { $unknown: Object.entries(output)[0] }; +}; + +// de_PreProcessingModelInvocationOutput omitted. + +// de_PreProcessingParsedResponse omitted. + +/** + * deserializeAws_restJson1PreProcessingTrace + */ +const de_PreProcessingTrace = (output: any, context: __SerdeContext): PreProcessingTrace => { + if (output.modelInvocationInput != null) { + return { + modelInvocationInput: de_ModelInvocationInput(output.modelInvocationInput, context), + }; + } + if (output.modelInvocationOutput != null) { + return { + modelInvocationOutput: _json(output.modelInvocationOutput), + }; + } + return { $unknown: Object.entries(output)[0] }; +}; + +// de_Rationale omitted. + +// de_RepromptResponse omitted. + +// de_RequestBody omitted. + +// de_RetrievalResultContent omitted. + +// de_RetrievalResultLocation omitted. + +// de_RetrievalResultS3Location omitted. + +// de_RetrieveAndGenerateOutput omitted. + +// de_RetrievedReference omitted. + +// de_RetrievedReferences omitted. + +// de_Span omitted. + +// de_StopSequences omitted. + +// de_TextResponsePart omitted. + +/** + * deserializeAws_restJson1Trace + */ +const de_Trace = (output: any, context: __SerdeContext): Trace => { + if (output.failureTrace != null) { + return { + failureTrace: _json(output.failureTrace), + }; + } + if (output.orchestrationTrace != null) { + return { + orchestrationTrace: de_OrchestrationTrace(__expectUnion(output.orchestrationTrace), context), + }; + } + if (output.postProcessingTrace != null) { + return { + postProcessingTrace: de_PostProcessingTrace(__expectUnion(output.postProcessingTrace), context), + }; + } + if (output.preProcessingTrace != null) { + return { + preProcessingTrace: de_PreProcessingTrace(__expectUnion(output.preProcessingTrace), context), + }; + } + return { $unknown: Object.entries(output)[0] }; +}; + +/** + * deserializeAws_restJson1TracePart + */ +const de_TracePart = (output: any, context: __SerdeContext): TracePart => { + return take(output, { + agentAliasId: __expectString, + agentId: __expectString, + sessionId: __expectString, + trace: (_: any) => de_Trace(__expectUnion(_), context), + }) as any; +}; + +const deserializeMetadata = (output: __HttpResponse): __ResponseMetadata => ({ + httpStatusCode: output.statusCode, + requestId: + output.headers["x-amzn-requestid"] ?? output.headers["x-amzn-request-id"] ?? output.headers["x-amz-request-id"], + extendedRequestId: output.headers["x-amz-id-2"], + cfId: output.headers["x-amz-cf-id"], +}); + +// Encode Uint8Array data into string with utf-8. +const collectBodyString = (streamBody: any, context: __SerdeContext): Promise => + collectBody(streamBody, context).then((body) => context.utf8Encoder(body)); + +const isSerializableHeaderValue = (value: any): boolean => + value !== undefined && + value !== null && + value !== "" && + (!Object.getOwnPropertyNames(value).includes("length") || value.length != 0) && + (!Object.getOwnPropertyNames(value).includes("size") || value.size != 0); + +const parseBody = (streamBody: any, context: __SerdeContext): any => + collectBodyString(streamBody, context).then((encoded) => { + if (encoded.length) { + return JSON.parse(encoded); + } + return {}; + }); + +const parseErrorBody = async (errorBody: any, context: __SerdeContext) => { + const value = await parseBody(errorBody, context); + value.message = value.message ?? value.Message; + return value; +}; + +/** + * Load an error code for the aws.rest-json-1.1 protocol. + */ +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { + const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); + + const sanitizeErrorCode = (rawValue: string | number): string => { + let cleanValue = rawValue; + if (typeof cleanValue === "number") { + cleanValue = cleanValue.toString(); + } + if (cleanValue.indexOf(",") >= 0) { + cleanValue = cleanValue.split(",")[0]; + } + if (cleanValue.indexOf(":") >= 0) { + cleanValue = cleanValue.split(":")[0]; + } + if (cleanValue.indexOf("#") >= 0) { + cleanValue = cleanValue.split("#")[1]; + } + return cleanValue; + }; + + const headerKey = findKey(output.headers, "x-amzn-errortype"); + if (headerKey !== undefined) { + return sanitizeErrorCode(output.headers[headerKey]); + } + + if (data.code !== undefined) { + return sanitizeErrorCode(data.code); + } + + if (data["__type"] !== undefined) { + return sanitizeErrorCode(data["__type"]); + } +}; diff --git a/clients/client-bedrock-agent-runtime/src/runtimeConfig.browser.ts b/clients/client-bedrock-agent-runtime/src/runtimeConfig.browser.ts new file mode 100644 index 000000000000..22627768d256 --- /dev/null +++ b/clients/client-bedrock-agent-runtime/src/runtimeConfig.browser.ts @@ -0,0 +1,46 @@ +// smithy-typescript generated code +// @ts-ignore: package.json will be imported from dist folders +import packageInfo from "../package.json"; // eslint-disable-line + +import { Sha256 } from "@aws-crypto/sha256-browser"; +import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; +import { DEFAULT_USE_DUALSTACK_ENDPOINT, DEFAULT_USE_FIPS_ENDPOINT } from "@smithy/config-resolver"; +import { eventStreamSerdeProvider } from "@smithy/eventstream-serde-browser"; +import { FetchHttpHandler as RequestHandler, streamCollector } from "@smithy/fetch-http-handler"; +import { invalidProvider } from "@smithy/invalid-dependency"; +import { calculateBodyLength } from "@smithy/util-body-length-browser"; +import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE } from "@smithy/util-retry"; +import { BedrockAgentRuntimeClientConfig } from "./BedrockAgentRuntimeClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; +import { loadConfigsForDefaultMode } from "@smithy/smithy-client"; +import { resolveDefaultsModeConfig } from "@smithy/util-defaults-mode-browser"; + +/** + * @internal + */ +export const getRuntimeConfig = (config: BedrockAgentRuntimeClientConfig) => { + const defaultsMode = resolveDefaultsModeConfig(config); + const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode); + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + defaultsMode, + bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config?.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config?.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + eventStreamSerdeProvider: config?.eventStreamSerdeProvider ?? eventStreamSerdeProvider, + maxAttempts: config?.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config?.region ?? invalidProvider("Region is missing"), + requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider), + retryMode: config?.retryMode ?? (async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE), + sha256: config?.sha256 ?? Sha256, + streamCollector: config?.streamCollector ?? streamCollector, + useDualstackEndpoint: config?.useDualstackEndpoint ?? (() => Promise.resolve(DEFAULT_USE_DUALSTACK_ENDPOINT)), + useFipsEndpoint: config?.useFipsEndpoint ?? (() => Promise.resolve(DEFAULT_USE_FIPS_ENDPOINT)), + }; +}; diff --git a/clients/client-bedrock-agent-runtime/src/runtimeConfig.native.ts b/clients/client-bedrock-agent-runtime/src/runtimeConfig.native.ts new file mode 100644 index 000000000000..6d14993e3b1f --- /dev/null +++ b/clients/client-bedrock-agent-runtime/src/runtimeConfig.native.ts @@ -0,0 +1,18 @@ +// smithy-typescript generated code +import { Sha256 } from "@aws-crypto/sha256-js"; + +import { BedrockAgentRuntimeClientConfig } from "./BedrockAgentRuntimeClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; + +/** + * @internal + */ +export const getRuntimeConfig = (config: BedrockAgentRuntimeClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config?.sha256 ?? Sha256, + }; +}; diff --git a/clients/client-bedrock-agent-runtime/src/runtimeConfig.shared.ts b/clients/client-bedrock-agent-runtime/src/runtimeConfig.shared.ts new file mode 100644 index 000000000000..f6bf4a1e4e2b --- /dev/null +++ b/clients/client-bedrock-agent-runtime/src/runtimeConfig.shared.ts @@ -0,0 +1,27 @@ +// smithy-typescript generated code +import { NoOpLogger } from "@smithy/smithy-client"; +import { parseUrl } from "@smithy/url-parser"; +import { fromBase64, toBase64 } from "@smithy/util-base64"; +import { fromUtf8, toUtf8 } from "@smithy/util-utf8"; + +import { BedrockAgentRuntimeClientConfig } from "./BedrockAgentRuntimeClient"; +import { defaultEndpointResolver } from "./endpoint/endpointResolver"; + +/** + * @internal + */ +export const getRuntimeConfig = (config: BedrockAgentRuntimeClientConfig) => { + return { + apiVersion: "2023-07-26", + base64Decoder: config?.base64Decoder ?? fromBase64, + base64Encoder: config?.base64Encoder ?? toBase64, + disableHostPrefix: config?.disableHostPrefix ?? false, + endpointProvider: config?.endpointProvider ?? defaultEndpointResolver, + extensions: config?.extensions ?? [], + logger: config?.logger ?? new NoOpLogger(), + serviceId: config?.serviceId ?? "Bedrock Agent Runtime", + urlParser: config?.urlParser ?? parseUrl, + utf8Decoder: config?.utf8Decoder ?? fromUtf8, + utf8Encoder: config?.utf8Encoder ?? toUtf8, + }; +}; diff --git a/clients/client-bedrock-agent-runtime/src/runtimeConfig.ts b/clients/client-bedrock-agent-runtime/src/runtimeConfig.ts new file mode 100644 index 000000000000..62490f87db15 --- /dev/null +++ b/clients/client-bedrock-agent-runtime/src/runtimeConfig.ts @@ -0,0 +1,63 @@ +// smithy-typescript generated code +// @ts-ignore: package.json will be imported from dist folders +import packageInfo from "../package.json"; // eslint-disable-line + +import { decorateDefaultCredentialProvider } from "@aws-sdk/client-sts"; +import { emitWarningIfUnsupportedVersion as awsCheckVersion } from "@aws-sdk/core"; +import { defaultProvider as credentialDefaultProvider } from "@aws-sdk/credential-provider-node"; +import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; +import { + NODE_REGION_CONFIG_FILE_OPTIONS, + NODE_REGION_CONFIG_OPTIONS, + NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS, + NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS, +} from "@smithy/config-resolver"; +import { eventStreamSerdeProvider } from "@smithy/eventstream-serde-node"; +import { Hash } from "@smithy/hash-node"; +import { NODE_MAX_ATTEMPT_CONFIG_OPTIONS, NODE_RETRY_MODE_CONFIG_OPTIONS } from "@smithy/middleware-retry"; +import { loadConfig as loadNodeConfig } from "@smithy/node-config-provider"; +import { NodeHttpHandler as RequestHandler, streamCollector } from "@smithy/node-http-handler"; +import { calculateBodyLength } from "@smithy/util-body-length-node"; +import { DEFAULT_RETRY_MODE } from "@smithy/util-retry"; +import { BedrockAgentRuntimeClientConfig } from "./BedrockAgentRuntimeClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; +import { loadConfigsForDefaultMode } from "@smithy/smithy-client"; +import { resolveDefaultsModeConfig } from "@smithy/util-defaults-mode-node"; +import { emitWarningIfUnsupportedVersion } from "@smithy/smithy-client"; + +/** + * @internal + */ +export const getRuntimeConfig = (config: BedrockAgentRuntimeClientConfig) => { + emitWarningIfUnsupportedVersion(process.version); + const defaultsMode = resolveDefaultsModeConfig(config); + const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode); + const clientSharedValues = getSharedRuntimeConfig(config); + awsCheckVersion(process.version); + return { + ...clientSharedValues, + ...config, + runtime: "node", + defaultsMode, + bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config?.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config?.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + eventStreamSerdeProvider: config?.eventStreamSerdeProvider ?? eventStreamSerdeProvider, + maxAttempts: config?.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config?.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider), + retryMode: + config?.retryMode ?? + loadNodeConfig({ + ...NODE_RETRY_MODE_CONFIG_OPTIONS, + default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE, + }), + sha256: config?.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config?.streamCollector ?? streamCollector, + useDualstackEndpoint: config?.useDualstackEndpoint ?? loadNodeConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS), + useFipsEndpoint: config?.useFipsEndpoint ?? loadNodeConfig(NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS), + }; +}; diff --git a/clients/client-bedrock-agent-runtime/src/runtimeExtensions.ts b/clients/client-bedrock-agent-runtime/src/runtimeExtensions.ts new file mode 100644 index 000000000000..e233d553e3e8 --- /dev/null +++ b/clients/client-bedrock-agent-runtime/src/runtimeExtensions.ts @@ -0,0 +1,45 @@ +// smithy-typescript generated code +import { + getAwsRegionExtensionConfiguration, + resolveAwsRegionExtensionConfiguration, +} from "@aws-sdk/region-config-resolver"; +import { getHttpHandlerExtensionConfiguration, resolveHttpHandlerRuntimeConfig } from "@smithy/protocol-http"; +import { getDefaultExtensionConfiguration, resolveDefaultRuntimeConfig } from "@smithy/smithy-client"; + +import { BedrockAgentRuntimeExtensionConfiguration } from "./extensionConfiguration"; + +/** + * @public + */ +export interface RuntimeExtension { + configure(extensionConfiguration: BedrockAgentRuntimeExtensionConfiguration): void; +} + +/** + * @public + */ +export interface RuntimeExtensionsConfig { + extensions: RuntimeExtension[]; +} + +const asPartial = >(t: T) => t; + +/** + * @internal + */ +export const resolveRuntimeExtensions = (runtimeConfig: any, extensions: RuntimeExtension[]) => { + const extensionConfiguration: BedrockAgentRuntimeExtensionConfiguration = { + ...asPartial(getAwsRegionExtensionConfiguration(runtimeConfig)), + ...asPartial(getDefaultExtensionConfiguration(runtimeConfig)), + ...asPartial(getHttpHandlerExtensionConfiguration(runtimeConfig)), + }; + + extensions.forEach((extension) => extension.configure(extensionConfiguration)); + + return { + ...runtimeConfig, + ...resolveAwsRegionExtensionConfiguration(extensionConfiguration), + ...resolveDefaultRuntimeConfig(extensionConfiguration), + ...resolveHttpHandlerRuntimeConfig(extensionConfiguration), + }; +}; diff --git a/clients/client-bedrock-agent-runtime/tsconfig.cjs.json b/clients/client-bedrock-agent-runtime/tsconfig.cjs.json new file mode 100644 index 000000000000..3567d85ba846 --- /dev/null +++ b/clients/client-bedrock-agent-runtime/tsconfig.cjs.json @@ -0,0 +1,6 @@ +{ + "extends": "./tsconfig", + "compilerOptions": { + "outDir": "dist-cjs" + } +} diff --git a/clients/client-bedrock-agent-runtime/tsconfig.es.json b/clients/client-bedrock-agent-runtime/tsconfig.es.json new file mode 100644 index 000000000000..809f57bde65e --- /dev/null +++ b/clients/client-bedrock-agent-runtime/tsconfig.es.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig", + "compilerOptions": { + "lib": ["dom"], + "module": "esnext", + "outDir": "dist-es" + } +} diff --git a/clients/client-bedrock-agent-runtime/tsconfig.json b/clients/client-bedrock-agent-runtime/tsconfig.json new file mode 100644 index 000000000000..344909de2128 --- /dev/null +++ b/clients/client-bedrock-agent-runtime/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "@tsconfig/node14/tsconfig.json", + "compilerOptions": { + "downlevelIteration": true, + "importHelpers": true, + "incremental": true, + "removeComments": true, + "resolveJsonModule": true, + "rootDir": "src", + "useUnknownInCatchVariables": false + }, + "exclude": ["test/"] +} diff --git a/clients/client-bedrock-agent-runtime/tsconfig.types.json b/clients/client-bedrock-agent-runtime/tsconfig.types.json new file mode 100644 index 000000000000..4c3dfa7b3d25 --- /dev/null +++ b/clients/client-bedrock-agent-runtime/tsconfig.types.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig", + "compilerOptions": { + "removeComments": false, + "declaration": true, + "declarationDir": "dist-types", + "emitDeclarationOnly": true + }, + "exclude": ["test/**/*", "dist-types/**/*"] +} diff --git a/clients/client-bedrock-agent-runtime/typedoc.json b/clients/client-bedrock-agent-runtime/typedoc.json new file mode 100644 index 000000000000..8a364aa93b69 --- /dev/null +++ b/clients/client-bedrock-agent-runtime/typedoc.json @@ -0,0 +1,6 @@ +{ + "extends": ["../../typedoc.client.json"], + "entryPoints": ["src/index.ts"], + "out": "docs", + "readme": "README.md" +} diff --git a/codegen/sdk-codegen/aws-models/bedrock-agent-runtime.json b/codegen/sdk-codegen/aws-models/bedrock-agent-runtime.json new file mode 100644 index 000000000000..cbf69dedd640 --- /dev/null +++ b/codegen/sdk-codegen/aws-models/bedrock-agent-runtime.json @@ -0,0 +1,2454 @@ +{ + "smithy": "2.0", + "shapes": { + "com.amazonaws.bedrockagentruntime#AccessDeniedException": { + "type": "structure", + "members": { + "message": { + "target": "com.amazonaws.bedrockagentruntime#NonBlankString" + } + }, + "traits": { + "smithy.api#documentation": "This exception is thrown when a request is denied per access permissions", + "smithy.api#error": "client", + "smithy.api#httpError": 403 + } + }, + "com.amazonaws.bedrockagentruntime#ActionGroupInvocationInput": { + "type": "structure", + "members": { + "actionGroupName": { + "target": "com.amazonaws.bedrockagentruntime#ActionGroupName" + }, + "verb": { + "target": "com.amazonaws.bedrockagentruntime#Verb" + }, + "apiPath": { + "target": "com.amazonaws.bedrockagentruntime#ApiPath" + }, + "parameters": { + "target": "com.amazonaws.bedrockagentruntime#Parameters" + }, + "requestBody": { + "target": "com.amazonaws.bedrockagentruntime#RequestBody" + } + }, + "traits": { + "smithy.api#documentation": "input to lambda used in action group" + } + }, + "com.amazonaws.bedrockagentruntime#ActionGroupInvocationOutput": { + "type": "structure", + "members": { + "text": { + "target": "com.amazonaws.bedrockagentruntime#ActionGroupOutputString" + } + }, + "traits": { + "smithy.api#documentation": "output from lambda used in action group" + } + }, + "com.amazonaws.bedrockagentruntime#ActionGroupName": { + "type": "string", + "traits": { + "smithy.api#documentation": "Agent Trace Action Group Name", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#ActionGroupOutputString": { + "type": "string", + "traits": { + "smithy.api#documentation": "Agent Trace Action Group Lambda Invocation Output String", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#AgentAliasId": { + "type": "string", + "traits": { + "smithy.api#documentation": "Identifier of the agent alias.", + "smithy.api#length": { + "max": 10 + }, + "smithy.api#pattern": "^[0-9a-zA-Z]+$" + } + }, + "com.amazonaws.bedrockagentruntime#AgentId": { + "type": "string", + "traits": { + "smithy.api#documentation": "Identifier of the agent.", + "smithy.api#length": { + "max": 10 + }, + "smithy.api#pattern": "^[0-9a-zA-Z]+$" + } + }, + "com.amazonaws.bedrockagentruntime#AmazonBedrockAgentRunTimeService": { + "type": "service", + "version": "2023-07-26", + "resources": [ + { + "target": "com.amazonaws.bedrockagentruntime#InferenceResource" + }, + { + "target": "com.amazonaws.bedrockagentruntime#RetrieveAndGenerateResource" + }, + { + "target": "com.amazonaws.bedrockagentruntime#RetrieveResource" + } + ], + "traits": { + "aws.api#service": { + "sdkId": "Bedrock Agent Runtime", + "arnNamespace": "bedrock", + "endpointPrefix": "bedrock-agent-runtime", + "cloudTrailEventSource": "bedrock.amazonaws.com" + }, + "aws.auth#sigv4": { + "name": "bedrock" + }, + "aws.protocols#restJson1": {}, + "smithy.api#documentation": "Amazon Bedrock Agent", + "smithy.api#title": "Agents for Amazon Bedrock Runtime", + "smithy.rules#endpointRuleSet": { + "version": "1.0", + "parameters": { + "Region": { + "builtIn": "AWS::Region", + "required": false, + "documentation": "The AWS region used to dispatch the request.", + "type": "String" + }, + "UseDualStack": { + "builtIn": "AWS::UseDualStack", + "required": true, + "default": false, + "documentation": "When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.", + "type": "Boolean" + }, + "UseFIPS": { + "builtIn": "AWS::UseFIPS", + "required": true, + "default": false, + "documentation": "When true, send this request to the FIPS-compliant regional endpoint. If the configured endpoint does not have a FIPS compliant endpoint, dispatching the request will return an error.", + "type": "Boolean" + }, + "Endpoint": { + "builtIn": "SDK::Endpoint", + "required": false, + "documentation": "Override the endpoint used to send this request", + "type": "String" + } + }, + "rules": [ + { + "conditions": [ + { + "fn": "isSet", + "argv": [ + { + "ref": "Endpoint" + } + ] + } + ], + "rules": [ + { + "conditions": [ + { + "fn": "booleanEquals", + "argv": [ + { + "ref": "UseFIPS" + }, + true + ] + } + ], + "error": "Invalid Configuration: FIPS and custom endpoint are not supported", + "type": "error" + }, + { + "conditions": [], + "rules": [ + { + "conditions": [ + { + "fn": "booleanEquals", + "argv": [ + { + "ref": "UseDualStack" + }, + true + ] + } + ], + "error": "Invalid Configuration: Dualstack and custom endpoint are not supported", + "type": "error" + }, + { + "conditions": [], + "endpoint": { + "url": { + "ref": "Endpoint" + }, + "properties": {}, + "headers": {} + }, + "type": "endpoint" + } + ], + "type": "tree" + } + ], + "type": "tree" + }, + { + "conditions": [], + "rules": [ + { + "conditions": [ + { + "fn": "isSet", + "argv": [ + { + "ref": "Region" + } + ] + } + ], + "rules": [ + { + "conditions": [ + { + "fn": "aws.partition", + "argv": [ + { + "ref": "Region" + } + ], + "assign": "PartitionResult" + } + ], + "rules": [ + { + "conditions": [ + { + "fn": "booleanEquals", + "argv": [ + { + "ref": "UseFIPS" + }, + true + ] + }, + { + "fn": "booleanEquals", + "argv": [ + { + "ref": "UseDualStack" + }, + true + ] + } + ], + "rules": [ + { + "conditions": [ + { + "fn": "booleanEquals", + "argv": [ + true, + { + "fn": "getAttr", + "argv": [ + { + "ref": "PartitionResult" + }, + "supportsFIPS" + ] + } + ] + }, + { + "fn": "booleanEquals", + "argv": [ + true, + { + "fn": "getAttr", + "argv": [ + { + "ref": "PartitionResult" + }, + "supportsDualStack" + ] + } + ] + } + ], + "rules": [ + { + "conditions": [], + "rules": [ + { + "conditions": [], + "endpoint": { + "url": "https://bedrock-agent-runtime-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", + "properties": {}, + "headers": {} + }, + "type": "endpoint" + } + ], + "type": "tree" + } + ], + "type": "tree" + }, + { + "conditions": [], + "error": "FIPS and DualStack are enabled, but this partition does not support one or both", + "type": "error" + } + ], + "type": "tree" + }, + { + "conditions": [ + { + "fn": "booleanEquals", + "argv": [ + { + "ref": "UseFIPS" + }, + true + ] + } + ], + "rules": [ + { + "conditions": [ + { + "fn": "booleanEquals", + "argv": [ + { + "fn": "getAttr", + "argv": [ + { + "ref": "PartitionResult" + }, + "supportsFIPS" + ] + }, + true + ] + } + ], + "rules": [ + { + "conditions": [], + "rules": [ + { + "conditions": [], + "endpoint": { + "url": "https://bedrock-agent-runtime-fips.{Region}.{PartitionResult#dnsSuffix}", + "properties": {}, + "headers": {} + }, + "type": "endpoint" + } + ], + "type": "tree" + } + ], + "type": "tree" + }, + { + "conditions": [], + "error": "FIPS is enabled but this partition does not support FIPS", + "type": "error" + } + ], + "type": "tree" + }, + { + "conditions": [ + { + "fn": "booleanEquals", + "argv": [ + { + "ref": "UseDualStack" + }, + true + ] + } + ], + "rules": [ + { + "conditions": [ + { + "fn": "booleanEquals", + "argv": [ + true, + { + "fn": "getAttr", + "argv": [ + { + "ref": "PartitionResult" + }, + "supportsDualStack" + ] + } + ] + } + ], + "rules": [ + { + "conditions": [], + "rules": [ + { + "conditions": [], + "endpoint": { + "url": "https://bedrock-agent-runtime.{Region}.{PartitionResult#dualStackDnsSuffix}", + "properties": {}, + "headers": {} + }, + "type": "endpoint" + } + ], + "type": "tree" + } + ], + "type": "tree" + }, + { + "conditions": [], + "error": "DualStack is enabled but this partition does not support DualStack", + "type": "error" + } + ], + "type": "tree" + }, + { + "conditions": [], + "rules": [ + { + "conditions": [], + "endpoint": { + "url": "https://bedrock-agent-runtime.{Region}.{PartitionResult#dnsSuffix}", + "properties": {}, + "headers": {} + }, + "type": "endpoint" + } + ], + "type": "tree" + } + ], + "type": "tree" + } + ], + "type": "tree" + }, + { + "conditions": [], + "error": "Invalid Configuration: Missing Region", + "type": "error" + } + ], + "type": "tree" + } + ] + }, + "smithy.rules#endpointTests": { + "testCases": [ + { + "documentation": "For region us-east-1 with FIPS enabled and DualStack enabled", + "expect": { + "endpoint": { + "url": "https://bedrock-agent-runtime-fips.us-east-1.api.aws" + } + }, + "params": { + "Region": "us-east-1", + "UseFIPS": true, + "UseDualStack": true + } + }, + { + "documentation": "For region us-east-1 with FIPS enabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://bedrock-agent-runtime-fips.us-east-1.amazonaws.com" + } + }, + "params": { + "Region": "us-east-1", + "UseFIPS": true, + "UseDualStack": false + } + }, + { + "documentation": "For region us-east-1 with FIPS disabled and DualStack enabled", + "expect": { + "endpoint": { + "url": "https://bedrock-agent-runtime.us-east-1.api.aws" + } + }, + "params": { + "Region": "us-east-1", + "UseFIPS": false, + "UseDualStack": true + } + }, + { + "documentation": "For region us-east-1 with FIPS disabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://bedrock-agent-runtime.us-east-1.amazonaws.com" + } + }, + "params": { + "Region": "us-east-1", + "UseFIPS": false, + "UseDualStack": false + } + }, + { + "documentation": "For region cn-north-1 with FIPS enabled and DualStack enabled", + "expect": { + "endpoint": { + "url": "https://bedrock-agent-runtime-fips.cn-north-1.api.amazonwebservices.com.cn" + } + }, + "params": { + "Region": "cn-north-1", + "UseFIPS": true, + "UseDualStack": true + } + }, + { + "documentation": "For region cn-north-1 with FIPS enabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://bedrock-agent-runtime-fips.cn-north-1.amazonaws.com.cn" + } + }, + "params": { + "Region": "cn-north-1", + "UseFIPS": true, + "UseDualStack": false + } + }, + { + "documentation": "For region cn-north-1 with FIPS disabled and DualStack enabled", + "expect": { + "endpoint": { + "url": "https://bedrock-agent-runtime.cn-north-1.api.amazonwebservices.com.cn" + } + }, + "params": { + "Region": "cn-north-1", + "UseFIPS": false, + "UseDualStack": true + } + }, + { + "documentation": "For region cn-north-1 with FIPS disabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://bedrock-agent-runtime.cn-north-1.amazonaws.com.cn" + } + }, + "params": { + "Region": "cn-north-1", + "UseFIPS": false, + "UseDualStack": false + } + }, + { + "documentation": "For region us-gov-east-1 with FIPS enabled and DualStack enabled", + "expect": { + "endpoint": { + "url": "https://bedrock-agent-runtime-fips.us-gov-east-1.api.aws" + } + }, + "params": { + "Region": "us-gov-east-1", + "UseFIPS": true, + "UseDualStack": true + } + }, + { + "documentation": "For region us-gov-east-1 with FIPS enabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://bedrock-agent-runtime-fips.us-gov-east-1.amazonaws.com" + } + }, + "params": { + "Region": "us-gov-east-1", + "UseFIPS": true, + "UseDualStack": false + } + }, + { + "documentation": "For region us-gov-east-1 with FIPS disabled and DualStack enabled", + "expect": { + "endpoint": { + "url": "https://bedrock-agent-runtime.us-gov-east-1.api.aws" + } + }, + "params": { + "Region": "us-gov-east-1", + "UseFIPS": false, + "UseDualStack": true + } + }, + { + "documentation": "For region us-gov-east-1 with FIPS disabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://bedrock-agent-runtime.us-gov-east-1.amazonaws.com" + } + }, + "params": { + "Region": "us-gov-east-1", + "UseFIPS": false, + "UseDualStack": false + } + }, + { + "documentation": "For region us-iso-east-1 with FIPS enabled and DualStack enabled", + "expect": { + "error": "FIPS and DualStack are enabled, but this partition does not support one or both" + }, + "params": { + "Region": "us-iso-east-1", + "UseFIPS": true, + "UseDualStack": true + } + }, + { + "documentation": "For region us-iso-east-1 with FIPS enabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://bedrock-agent-runtime-fips.us-iso-east-1.c2s.ic.gov" + } + }, + "params": { + "Region": "us-iso-east-1", + "UseFIPS": true, + "UseDualStack": false + } + }, + { + "documentation": "For region us-iso-east-1 with FIPS disabled and DualStack enabled", + "expect": { + "error": "DualStack is enabled but this partition does not support DualStack" + }, + "params": { + "Region": "us-iso-east-1", + "UseFIPS": false, + "UseDualStack": true + } + }, + { + "documentation": "For region us-iso-east-1 with FIPS disabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://bedrock-agent-runtime.us-iso-east-1.c2s.ic.gov" + } + }, + "params": { + "Region": "us-iso-east-1", + "UseFIPS": false, + "UseDualStack": false + } + }, + { + "documentation": "For region us-isob-east-1 with FIPS enabled and DualStack enabled", + "expect": { + "error": "FIPS and DualStack are enabled, but this partition does not support one or both" + }, + "params": { + "Region": "us-isob-east-1", + "UseFIPS": true, + "UseDualStack": true + } + }, + { + "documentation": "For region us-isob-east-1 with FIPS enabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://bedrock-agent-runtime-fips.us-isob-east-1.sc2s.sgov.gov" + } + }, + "params": { + "Region": "us-isob-east-1", + "UseFIPS": true, + "UseDualStack": false + } + }, + { + "documentation": "For region us-isob-east-1 with FIPS disabled and DualStack enabled", + "expect": { + "error": "DualStack is enabled but this partition does not support DualStack" + }, + "params": { + "Region": "us-isob-east-1", + "UseFIPS": false, + "UseDualStack": true + } + }, + { + "documentation": "For region us-isob-east-1 with FIPS disabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://bedrock-agent-runtime.us-isob-east-1.sc2s.sgov.gov" + } + }, + "params": { + "Region": "us-isob-east-1", + "UseFIPS": false, + "UseDualStack": false + } + }, + { + "documentation": "For custom endpoint with region set and fips disabled and dualstack disabled", + "expect": { + "endpoint": { + "url": "https://example.com" + } + }, + "params": { + "Region": "us-east-1", + "UseFIPS": false, + "UseDualStack": false, + "Endpoint": "https://example.com" + } + }, + { + "documentation": "For custom endpoint with region not set and fips disabled and dualstack disabled", + "expect": { + "endpoint": { + "url": "https://example.com" + } + }, + "params": { + "UseFIPS": false, + "UseDualStack": false, + "Endpoint": "https://example.com" + } + }, + { + "documentation": "For custom endpoint with fips enabled and dualstack disabled", + "expect": { + "error": "Invalid Configuration: FIPS and custom endpoint are not supported" + }, + "params": { + "Region": "us-east-1", + "UseFIPS": true, + "UseDualStack": false, + "Endpoint": "https://example.com" + } + }, + { + "documentation": "For custom endpoint with fips disabled and dualstack enabled", + "expect": { + "error": "Invalid Configuration: Dualstack and custom endpoint are not supported" + }, + "params": { + "Region": "us-east-1", + "UseFIPS": false, + "UseDualStack": true, + "Endpoint": "https://example.com" + } + }, + { + "documentation": "Missing region", + "expect": { + "error": "Invalid Configuration: Missing Region" + } + } + ], + "version": "1.0" + } + } + }, + "com.amazonaws.bedrockagentruntime#ApiPath": { + "type": "string", + "traits": { + "smithy.api#documentation": "Agent Trace Action Group API path", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#Attribution": { + "type": "structure", + "members": { + "citations": { + "target": "com.amazonaws.bedrockagentruntime#Citations" + } + }, + "traits": { + "smithy.api#documentation": "Citations associated with final agent response" + } + }, + "com.amazonaws.bedrockagentruntime#BadGatewayException": { + "type": "structure", + "members": { + "message": { + "target": "com.amazonaws.bedrockagentruntime#NonBlankString" + }, + "resourceName": { + "target": "com.amazonaws.bedrockagentruntime#NonBlankString" + } + }, + "traits": { + "smithy.api#documentation": "This exception is thrown when a request fails due to dependency like Lambda, Bedrock, STS resource", + "smithy.api#error": "server", + "smithy.api#httpError": 502 + } + }, + "com.amazonaws.bedrockagentruntime#BedrockModelArn": { + "type": "string", + "traits": { + "smithy.api#documentation": "Arn of a Bedrock model.", + "smithy.api#length": { + "min": 20, + "max": 1011 + }, + "smithy.api#pattern": "^arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:(([0-9]{12}:custom-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}/[a-z0-9]{12})|(:foundation-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}))$" + } + }, + "com.amazonaws.bedrockagentruntime#Citation": { + "type": "structure", + "members": { + "generatedResponsePart": { + "target": "com.amazonaws.bedrockagentruntime#GeneratedResponsePart" + }, + "retrievedReferences": { + "target": "com.amazonaws.bedrockagentruntime#RetrievedReferences" + } + }, + "traits": { + "smithy.api#documentation": "Citation associated with the agent response" + } + }, + "com.amazonaws.bedrockagentruntime#Citations": { + "type": "list", + "member": { + "target": "com.amazonaws.bedrockagentruntime#Citation" + }, + "traits": { + "smithy.api#documentation": "List of citations" + } + }, + "com.amazonaws.bedrockagentruntime#ConflictException": { + "type": "structure", + "members": { + "message": { + "target": "com.amazonaws.bedrockagentruntime#NonBlankString" + } + }, + "traits": { + "smithy.api#documentation": "This exception is thrown when there is a conflict performing an operation", + "smithy.api#error": "client", + "smithy.api#httpError": 409 + } + }, + "com.amazonaws.bedrockagentruntime#ContentMap": { + "type": "map", + "key": { + "target": "smithy.api#String" + }, + "value": { + "target": "com.amazonaws.bedrockagentruntime#Parameters" + }, + "traits": { + "smithy.api#documentation": "Content type paramter map" + } + }, + "com.amazonaws.bedrockagentruntime#CreationMode": { + "type": "enum", + "members": { + "DEFAULT": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "DEFAULT" + } + }, + "OVERRIDDEN": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "OVERRIDDEN" + } + } + }, + "traits": { + "smithy.api#documentation": "indicates if agent uses default prompt or overriden prompt" + } + }, + "com.amazonaws.bedrockagentruntime#DependencyFailedException": { + "type": "structure", + "members": { + "message": { + "target": "com.amazonaws.bedrockagentruntime#NonBlankString" + }, + "resourceName": { + "target": "com.amazonaws.bedrockagentruntime#NonBlankString" + } + }, + "traits": { + "smithy.api#documentation": "This exception is thrown when a request fails due to dependency like Lambda, Bedrock, STS resource due to a customer fault (i.e. bad configuration)", + "smithy.api#error": "client", + "smithy.api#httpError": 424 + } + }, + "com.amazonaws.bedrockagentruntime#FailureReasonString": { + "type": "string", + "traits": { + "smithy.api#documentation": "Agent Trace Failed Reason String", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#FailureTrace": { + "type": "structure", + "members": { + "traceId": { + "target": "com.amazonaws.bedrockagentruntime#TraceId" + }, + "failureReason": { + "target": "com.amazonaws.bedrockagentruntime#FailureReasonString" + } + }, + "traits": { + "smithy.api#documentation": "Trace Part which is emitted when agent trace could not be generated", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#FinalResponse": { + "type": "structure", + "members": { + "text": { + "target": "com.amazonaws.bedrockagentruntime#FinalResponseString" + } + }, + "traits": { + "smithy.api#documentation": "Agent finish output" + } + }, + "com.amazonaws.bedrockagentruntime#FinalResponseString": { + "type": "string", + "traits": { + "smithy.api#documentation": "Agent Trace Action Group Lambda Invocation Output String", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#GeneratedResponsePart": { + "type": "structure", + "members": { + "textResponsePart": { + "target": "com.amazonaws.bedrockagentruntime#TextResponsePart" + } + }, + "traits": { + "smithy.api#documentation": "Generate response part" + } + }, + "com.amazonaws.bedrockagentruntime#InferenceConfiguration": { + "type": "structure", + "members": { + "temperature": { + "target": "com.amazonaws.bedrockagentruntime#Temperature" + }, + "topP": { + "target": "com.amazonaws.bedrockagentruntime#TopP" + }, + "topK": { + "target": "com.amazonaws.bedrockagentruntime#TopK" + }, + "maximumLength": { + "target": "com.amazonaws.bedrockagentruntime#MaximumLength" + }, + "stopSequences": { + "target": "com.amazonaws.bedrockagentruntime#StopSequences" + } + }, + "traits": { + "smithy.api#documentation": "Configurations for controlling the inference response of an InvokeAgent API call" + } + }, + "com.amazonaws.bedrockagentruntime#InferenceResource": { + "type": "resource", + "operations": [ + { + "target": "com.amazonaws.bedrockagentruntime#InvokeAgent" + } + ] + }, + "com.amazonaws.bedrockagentruntime#InputText": { + "type": "string", + "traits": { + "smithy.api#documentation": "Model text input", + "smithy.api#length": { + "max": 25000000 + }, + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#InternalServerException": { + "type": "structure", + "members": { + "message": { + "target": "com.amazonaws.bedrockagentruntime#NonBlankString" + } + }, + "traits": { + "smithy.api#documentation": "This exception is thrown if there was an unexpected error during processing of request", + "smithy.api#error": "server", + "smithy.api#httpError": 500 + } + }, + "com.amazonaws.bedrockagentruntime#InvocationInput": { + "type": "structure", + "members": { + "traceId": { + "target": "com.amazonaws.bedrockagentruntime#TraceId" + }, + "invocationType": { + "target": "com.amazonaws.bedrockagentruntime#InvocationType" + }, + "actionGroupInvocationInput": { + "target": "com.amazonaws.bedrockagentruntime#ActionGroupInvocationInput" + }, + "knowledgeBaseLookupInput": { + "target": "com.amazonaws.bedrockagentruntime#KnowledgeBaseLookupInput" + } + }, + "traits": { + "smithy.api#documentation": "Trace Part which contains input details for action group or knowledge base", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#InvocationType": { + "type": "enum", + "members": { + "ACTION_GROUP": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "ACTION_GROUP" + } + }, + "KNOWLEDGE_BASE": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "KNOWLEDGE_BASE" + } + }, + "FINISH": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "FINISH" + } + } + }, + "traits": { + "smithy.api#documentation": "types of invocations" + } + }, + "com.amazonaws.bedrockagentruntime#InvokeAgent": { + "type": "operation", + "input": { + "target": "com.amazonaws.bedrockagentruntime#InvokeAgentRequest" + }, + "output": { + "target": "com.amazonaws.bedrockagentruntime#InvokeAgentResponse" + }, + "errors": [ + { + "target": "com.amazonaws.bedrockagentruntime#AccessDeniedException" + }, + { + "target": "com.amazonaws.bedrockagentruntime#BadGatewayException" + }, + { + "target": "com.amazonaws.bedrockagentruntime#ConflictException" + }, + { + "target": "com.amazonaws.bedrockagentruntime#DependencyFailedException" + }, + { + "target": "com.amazonaws.bedrockagentruntime#InternalServerException" + }, + { + "target": "com.amazonaws.bedrockagentruntime#ResourceNotFoundException" + }, + { + "target": "com.amazonaws.bedrockagentruntime#ServiceQuotaExceededException" + }, + { + "target": "com.amazonaws.bedrockagentruntime#ThrottlingException" + }, + { + "target": "com.amazonaws.bedrockagentruntime#ValidationException" + } + ], + "traits": { + "smithy.api#documentation": "Invokes the specified Bedrock model to run inference using the input provided in the request body.", + "smithy.api#http": { + "code": 200, + "method": "POST", + "uri": "/agents/{agentId}/agentAliases/{agentAliasId}/sessions/{sessionId}/text" + } + } + }, + "com.amazonaws.bedrockagentruntime#InvokeAgentRequest": { + "type": "structure", + "members": { + "sessionState": { + "target": "com.amazonaws.bedrockagentruntime#SessionState", + "traits": { + "smithy.api#documentation": "Session state passed by customer. Base64 encoded json string representation of SessionState." + } + }, + "agentId": { + "target": "com.amazonaws.bedrockagentruntime#AgentId", + "traits": { + "smithy.api#documentation": "Identifier for Agent", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "agentAliasId": { + "target": "com.amazonaws.bedrockagentruntime#AgentAliasId", + "traits": { + "smithy.api#documentation": "Identifier for Agent Alias", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "sessionId": { + "target": "com.amazonaws.bedrockagentruntime#SessionId", + "traits": { + "smithy.api#documentation": "Identifier used for the current session", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "endSession": { + "target": "smithy.api#Boolean", + "traits": { + "smithy.api#documentation": "End current session" + } + }, + "enableTrace": { + "target": "smithy.api#Boolean", + "traits": { + "smithy.api#documentation": "Enable agent trace events for improved debugging" + } + }, + "inputText": { + "target": "com.amazonaws.bedrockagentruntime#InputText", + "traits": { + "smithy.api#documentation": "Input data in the format specified in the Content-Type request header.", + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "InvokeAgent Request", + "smithy.api#input": {} + } + }, + "com.amazonaws.bedrockagentruntime#InvokeAgentResponse": { + "type": "structure", + "members": { + "completion": { + "target": "com.amazonaws.bedrockagentruntime#ResponseStream", + "traits": { + "smithy.api#documentation": "Inference response from the model in the format specified in the Content-Type response header.", + "smithy.api#httpPayload": {}, + "smithy.api#required": {} + } + }, + "contentType": { + "target": "com.amazonaws.bedrockagentruntime#MimeType", + "traits": { + "smithy.api#documentation": "streaming response mimetype of the model", + "smithy.api#httpHeader": "x-amzn-bedrock-agent-content-type", + "smithy.api#required": {} + } + }, + "sessionId": { + "target": "com.amazonaws.bedrockagentruntime#SessionId", + "traits": { + "smithy.api#documentation": "streaming response mimetype of the model", + "smithy.api#httpHeader": "x-amz-bedrock-agent-session-id", + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "InvokeAgent Response", + "smithy.api#output": {} + } + }, + "com.amazonaws.bedrockagentruntime#KmsKeyArn": { + "type": "string", + "traits": { + "smithy.api#documentation": "A KMS key ARN", + "smithy.api#length": { + "min": 1, + "max": 2048 + }, + "smithy.api#pattern": "^arn:aws(|-cn|-us-gov):kms:[a-zA-Z0-9-]*:[0-9]{12}:key/[a-zA-Z0-9-]{36}$" + } + }, + "com.amazonaws.bedrockagentruntime#KnowledgeBaseId": { + "type": "string", + "traits": { + "smithy.api#documentation": "Identifier of the KnowledgeBase", + "smithy.api#length": { + "max": 10 + }, + "smithy.api#pattern": "^[0-9a-zA-Z]+$" + } + }, + "com.amazonaws.bedrockagentruntime#KnowledgeBaseLookupInput": { + "type": "structure", + "members": { + "text": { + "target": "com.amazonaws.bedrockagentruntime#KnowledgeBaseLookupInputString" + }, + "knowledgeBaseId": { + "target": "com.amazonaws.bedrockagentruntime#TraceKnowledgeBaseId" + } + }, + "traits": { + "smithy.api#documentation": "Input to lambda used in action group" + } + }, + "com.amazonaws.bedrockagentruntime#KnowledgeBaseLookupInputString": { + "type": "string", + "traits": { + "smithy.api#documentation": "Agent Trace Action Group Lambda Invocation Output String", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#KnowledgeBaseLookupOutput": { + "type": "structure", + "members": { + "retrievedReferences": { + "target": "com.amazonaws.bedrockagentruntime#RetrievedReferences" + } + }, + "traits": { + "smithy.api#documentation": "Input to lambda used in action group" + } + }, + "com.amazonaws.bedrockagentruntime#KnowledgeBaseQuery": { + "type": "structure", + "members": { + "text": { + "target": "smithy.api#String", + "traits": { + "smithy.api#documentation": "Knowledge base input query in text", + "smithy.api#length": { + "max": 1000 + }, + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "Knowledge base input query.", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#KnowledgeBaseRetrievalConfiguration": { + "type": "structure", + "members": { + "vectorSearchConfiguration": { + "target": "com.amazonaws.bedrockagentruntime#KnowledgeBaseVectorSearchConfiguration", + "traits": { + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "Search parameters for retrieving from knowledge base." + } + }, + "com.amazonaws.bedrockagentruntime#KnowledgeBaseRetrievalResult": { + "type": "structure", + "members": { + "content": { + "target": "com.amazonaws.bedrockagentruntime#RetrievalResultContent", + "traits": { + "smithy.api#required": {} + } + }, + "location": { + "target": "com.amazonaws.bedrockagentruntime#RetrievalResultLocation" + }, + "score": { + "target": "smithy.api#Double", + "traits": { + "smithy.api#documentation": "The relevance score of a result." + } + } + }, + "traits": { + "smithy.api#documentation": "Result item returned from a knowledge base retrieval." + } + }, + "com.amazonaws.bedrockagentruntime#KnowledgeBaseRetrievalResults": { + "type": "list", + "member": { + "target": "com.amazonaws.bedrockagentruntime#KnowledgeBaseRetrievalResult" + }, + "traits": { + "smithy.api#documentation": "List of knowledge base retrieval results", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#KnowledgeBaseRetrieveAndGenerateConfiguration": { + "type": "structure", + "members": { + "knowledgeBaseId": { + "target": "com.amazonaws.bedrockagentruntime#KnowledgeBaseId", + "traits": { + "smithy.api#required": {} + } + }, + "modelArn": { + "target": "com.amazonaws.bedrockagentruntime#BedrockModelArn", + "traits": { + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "Configurations for retrieval and generation for knowledge base." + } + }, + "com.amazonaws.bedrockagentruntime#KnowledgeBaseVectorSearchConfiguration": { + "type": "structure", + "members": { + "numberOfResults": { + "target": "smithy.api#Integer", + "traits": { + "smithy.api#documentation": "Top-K results to retrieve from knowledge base.", + "smithy.api#range": { + "min": 1, + "max": 10 + }, + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "Knowledge base vector search configuration" + } + }, + "com.amazonaws.bedrockagentruntime#LambdaArn": { + "type": "string", + "traits": { + "smithy.api#documentation": "ARN of a Lambda." + } + }, + "com.amazonaws.bedrockagentruntime#MaximumLength": { + "type": "integer", + "traits": { + "smithy.api#documentation": "Maximum length of output", + "smithy.api#range": { + "min": 0, + "max": 4096 + } + } + }, + "com.amazonaws.bedrockagentruntime#MimeType": { + "type": "string", + "traits": { + "smithy.api#documentation": "Content type of the request" + } + }, + "com.amazonaws.bedrockagentruntime#ModelInvocationInput": { + "type": "structure", + "members": { + "traceId": { + "target": "com.amazonaws.bedrockagentruntime#TraceId" + }, + "text": { + "target": "com.amazonaws.bedrockagentruntime#PromptText" + }, + "type": { + "target": "com.amazonaws.bedrockagentruntime#PromptType" + }, + "inferenceConfiguration": { + "target": "com.amazonaws.bedrockagentruntime#InferenceConfiguration" + }, + "overrideLambda": { + "target": "com.amazonaws.bedrockagentruntime#LambdaArn" + }, + "promptCreationMode": { + "target": "com.amazonaws.bedrockagentruntime#CreationMode" + }, + "parserMode": { + "target": "com.amazonaws.bedrockagentruntime#CreationMode" + } + }, + "traits": { + "smithy.api#documentation": "Trace Part which contains information used to call Invoke Model", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#NextToken": { + "type": "string", + "traits": { + "smithy.api#documentation": "Opaque continuation token of previous paginated response.", + "smithy.api#length": { + "min": 1, + "max": 2048 + }, + "smithy.api#pattern": "^\\S*$" + } + }, + "com.amazonaws.bedrockagentruntime#NonBlankString": { + "type": "string", + "traits": { + "smithy.api#documentation": "Non Blank String", + "smithy.api#pattern": "^[\\s\\S]*$" + } + }, + "com.amazonaws.bedrockagentruntime#Observation": { + "type": "structure", + "members": { + "traceId": { + "target": "com.amazonaws.bedrockagentruntime#TraceId" + }, + "type": { + "target": "com.amazonaws.bedrockagentruntime#Type" + }, + "actionGroupInvocationOutput": { + "target": "com.amazonaws.bedrockagentruntime#ActionGroupInvocationOutput" + }, + "knowledgeBaseLookupOutput": { + "target": "com.amazonaws.bedrockagentruntime#KnowledgeBaseLookupOutput" + }, + "finalResponse": { + "target": "com.amazonaws.bedrockagentruntime#FinalResponse" + }, + "repromptResponse": { + "target": "com.amazonaws.bedrockagentruntime#RepromptResponse" + } + }, + "traits": { + "smithy.api#documentation": "Trace Part which contains output details for action group or knowledge base or final response", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#OrchestrationTrace": { + "type": "union", + "members": { + "rationale": { + "target": "com.amazonaws.bedrockagentruntime#Rationale" + }, + "invocationInput": { + "target": "com.amazonaws.bedrockagentruntime#InvocationInput" + }, + "observation": { + "target": "com.amazonaws.bedrockagentruntime#Observation" + }, + "modelInvocationInput": { + "target": "com.amazonaws.bedrockagentruntime#ModelInvocationInput" + } + }, + "traits": { + "smithy.api#documentation": "Trace contains intermidate response during orchestration", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#OutputString": { + "type": "string", + "traits": { + "smithy.api#documentation": "Agent Trace Output String", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#Parameter": { + "type": "structure", + "members": { + "name": { + "target": "smithy.api#String", + "traits": { + "smithy.api#documentation": "Name of parameter" + } + }, + "type": { + "target": "smithy.api#String", + "traits": { + "smithy.api#documentation": "Type of parameter" + } + }, + "value": { + "target": "smithy.api#String", + "traits": { + "smithy.api#documentation": "Value of parameter" + } + } + }, + "traits": { + "smithy.api#documentation": "parameters included in action group invocation" + } + }, + "com.amazonaws.bedrockagentruntime#Parameters": { + "type": "list", + "member": { + "target": "com.amazonaws.bedrockagentruntime#Parameter" + }, + "traits": { + "smithy.api#documentation": "list of parameters included in action group invocation" + } + }, + "com.amazonaws.bedrockagentruntime#PartBody": { + "type": "blob", + "traits": { + "smithy.api#documentation": "PartBody of the payload in bytes", + "smithy.api#length": { + "max": 1000000 + }, + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#PayloadPart": { + "type": "structure", + "members": { + "bytes": { + "target": "com.amazonaws.bedrockagentruntime#PartBody" + }, + "attribution": { + "target": "com.amazonaws.bedrockagentruntime#Attribution" + } + }, + "traits": { + "smithy.api#documentation": "Base 64 endoded byte response", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#PostProcessingModelInvocationOutput": { + "type": "structure", + "members": { + "traceId": { + "target": "com.amazonaws.bedrockagentruntime#TraceId" + }, + "parsedResponse": { + "target": "com.amazonaws.bedrockagentruntime#PostProcessingParsedResponse" + } + }, + "traits": { + "smithy.api#documentation": "Trace Part which contains information related to postprocessing", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#PostProcessingParsedResponse": { + "type": "structure", + "members": { + "text": { + "target": "com.amazonaws.bedrockagentruntime#OutputString" + } + }, + "traits": { + "smithy.api#documentation": "Trace Part which contains information if preprocessing was successful", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#PostProcessingTrace": { + "type": "union", + "members": { + "modelInvocationInput": { + "target": "com.amazonaws.bedrockagentruntime#ModelInvocationInput" + }, + "modelInvocationOutput": { + "target": "com.amazonaws.bedrockagentruntime#PostProcessingModelInvocationOutput" + } + }, + "traits": { + "smithy.api#documentation": "Trace Part which contains information related to post processing step", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#PreProcessingModelInvocationOutput": { + "type": "structure", + "members": { + "traceId": { + "target": "com.amazonaws.bedrockagentruntime#TraceId" + }, + "parsedResponse": { + "target": "com.amazonaws.bedrockagentruntime#PreProcessingParsedResponse" + } + }, + "traits": { + "smithy.api#documentation": "Trace Part which contains information related to preprocessing", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#PreProcessingParsedResponse": { + "type": "structure", + "members": { + "rationale": { + "target": "com.amazonaws.bedrockagentruntime#RationaleString" + }, + "isValid": { + "target": "smithy.api#Boolean", + "traits": { + "smithy.api#documentation": "Boolean value" + } + } + }, + "traits": { + "smithy.api#documentation": "Trace Part which contains information if preprocessing was successful", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#PreProcessingTrace": { + "type": "union", + "members": { + "modelInvocationInput": { + "target": "com.amazonaws.bedrockagentruntime#ModelInvocationInput" + }, + "modelInvocationOutput": { + "target": "com.amazonaws.bedrockagentruntime#PreProcessingModelInvocationOutput" + } + }, + "traits": { + "smithy.api#documentation": "Trace Part which contains information related to preprocessing step", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#PromptSessionAttributesMap": { + "type": "map", + "key": { + "target": "smithy.api#String" + }, + "value": { + "target": "smithy.api#String" + }, + "traits": { + "smithy.api#documentation": "Session attributes that go to the prompt" + } + }, + "com.amazonaws.bedrockagentruntime#PromptText": { + "type": "string", + "traits": { + "smithy.api#documentation": "Prompt Message", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#PromptType": { + "type": "enum", + "members": { + "PRE_PROCESSING": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "PRE_PROCESSING" + } + }, + "ORCHESTRATION": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "ORCHESTRATION" + } + }, + "KNOWLEDGE_BASE_RESPONSE_GENERATION": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "KNOWLEDGE_BASE_RESPONSE_GENERATION" + } + }, + "POST_PROCESSING": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "POST_PROCESSING" + } + } + }, + "traits": { + "smithy.api#documentation": "types of prompts" + } + }, + "com.amazonaws.bedrockagentruntime#Rationale": { + "type": "structure", + "members": { + "traceId": { + "target": "com.amazonaws.bedrockagentruntime#TraceId" + }, + "text": { + "target": "com.amazonaws.bedrockagentruntime#RationaleString" + } + }, + "traits": { + "smithy.api#documentation": "Trace Part which contains information related to reasoning", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#RationaleString": { + "type": "string", + "traits": { + "smithy.api#documentation": "Agent Trace Rationale String", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#RepromptResponse": { + "type": "structure", + "members": { + "text": { + "target": "smithy.api#String", + "traits": { + "smithy.api#documentation": "Reprompt response text" + } + }, + "source": { + "target": "com.amazonaws.bedrockagentruntime#Source" + } + }, + "traits": { + "smithy.api#documentation": "Observation information if there were reprompts", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#RequestBody": { + "type": "structure", + "members": { + "content": { + "target": "com.amazonaws.bedrockagentruntime#ContentMap" + } + }, + "traits": { + "smithy.api#documentation": "Request Body Content Map" + } + }, + "com.amazonaws.bedrockagentruntime#ResourceNotFoundException": { + "type": "structure", + "members": { + "message": { + "target": "com.amazonaws.bedrockagentruntime#NonBlankString" + } + }, + "traits": { + "smithy.api#documentation": "This exception is thrown when a resource referenced by the operation does not exist", + "smithy.api#error": "client", + "smithy.api#httpError": 404 + } + }, + "com.amazonaws.bedrockagentruntime#ResponseStream": { + "type": "union", + "members": { + "chunk": { + "target": "com.amazonaws.bedrockagentruntime#PayloadPart" + }, + "trace": { + "target": "com.amazonaws.bedrockagentruntime#TracePart" + }, + "internalServerException": { + "target": "com.amazonaws.bedrockagentruntime#InternalServerException" + }, + "validationException": { + "target": "com.amazonaws.bedrockagentruntime#ValidationException" + }, + "resourceNotFoundException": { + "target": "com.amazonaws.bedrockagentruntime#ResourceNotFoundException" + }, + "serviceQuotaExceededException": { + "target": "com.amazonaws.bedrockagentruntime#ServiceQuotaExceededException" + }, + "throttlingException": { + "target": "com.amazonaws.bedrockagentruntime#ThrottlingException" + }, + "accessDeniedException": { + "target": "com.amazonaws.bedrockagentruntime#AccessDeniedException" + }, + "conflictException": { + "target": "com.amazonaws.bedrockagentruntime#ConflictException" + }, + "dependencyFailedException": { + "target": "com.amazonaws.bedrockagentruntime#DependencyFailedException" + }, + "badGatewayException": { + "target": "com.amazonaws.bedrockagentruntime#BadGatewayException" + } + }, + "traits": { + "smithy.api#documentation": "Response body of is a stream", + "smithy.api#streaming": {} + } + }, + "com.amazonaws.bedrockagentruntime#RetrievalResultContent": { + "type": "structure", + "members": { + "text": { + "target": "smithy.api#String", + "traits": { + "smithy.api#documentation": "Content of a retrieval result in text", + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "Content of a retrieval result." + } + }, + "com.amazonaws.bedrockagentruntime#RetrievalResultLocation": { + "type": "structure", + "members": { + "type": { + "target": "com.amazonaws.bedrockagentruntime#RetrievalResultLocationType", + "traits": { + "smithy.api#required": {} + } + }, + "s3Location": { + "target": "com.amazonaws.bedrockagentruntime#RetrievalResultS3Location" + } + }, + "traits": { + "smithy.api#documentation": "The source location of a retrieval result." + } + }, + "com.amazonaws.bedrockagentruntime#RetrievalResultLocationType": { + "type": "enum", + "members": { + "S3": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "S3" + } + } + }, + "traits": { + "smithy.api#documentation": "The location type of a retrieval result." + } + }, + "com.amazonaws.bedrockagentruntime#RetrievalResultS3Location": { + "type": "structure", + "members": { + "uri": { + "target": "smithy.api#String", + "traits": { + "smithy.api#documentation": "URI of S3 location" + } + } + }, + "traits": { + "smithy.api#documentation": "The S3 location of a retrieval result." + } + }, + "com.amazonaws.bedrockagentruntime#Retrieve": { + "type": "operation", + "input": { + "target": "com.amazonaws.bedrockagentruntime#RetrieveRequest" + }, + "output": { + "target": "com.amazonaws.bedrockagentruntime#RetrieveResponse" + }, + "errors": [ + { + "target": "com.amazonaws.bedrockagentruntime#AccessDeniedException" + }, + { + "target": "com.amazonaws.bedrockagentruntime#BadGatewayException" + }, + { + "target": "com.amazonaws.bedrockagentruntime#ConflictException" + }, + { + "target": "com.amazonaws.bedrockagentruntime#DependencyFailedException" + }, + { + "target": "com.amazonaws.bedrockagentruntime#InternalServerException" + }, + { + "target": "com.amazonaws.bedrockagentruntime#ResourceNotFoundException" + }, + { + "target": "com.amazonaws.bedrockagentruntime#ServiceQuotaExceededException" + }, + { + "target": "com.amazonaws.bedrockagentruntime#ThrottlingException" + }, + { + "target": "com.amazonaws.bedrockagentruntime#ValidationException" + } + ], + "traits": { + "smithy.api#documentation": "Retrieve from knowledge base.", + "smithy.api#http": { + "code": 200, + "method": "POST", + "uri": "/knowledgebases/{knowledgeBaseId}/retrieve" + }, + "smithy.api#paginated": { + "inputToken": "nextToken", + "outputToken": "nextToken", + "items": "retrievalResults" + }, + "smithy.api#readonly": {} + } + }, + "com.amazonaws.bedrockagentruntime#RetrieveAndGenerate": { + "type": "operation", + "input": { + "target": "com.amazonaws.bedrockagentruntime#RetrieveAndGenerateRequest" + }, + "output": { + "target": "com.amazonaws.bedrockagentruntime#RetrieveAndGenerateResponse" + }, + "errors": [ + { + "target": "com.amazonaws.bedrockagentruntime#AccessDeniedException" + }, + { + "target": "com.amazonaws.bedrockagentruntime#BadGatewayException" + }, + { + "target": "com.amazonaws.bedrockagentruntime#ConflictException" + }, + { + "target": "com.amazonaws.bedrockagentruntime#DependencyFailedException" + }, + { + "target": "com.amazonaws.bedrockagentruntime#InternalServerException" + }, + { + "target": "com.amazonaws.bedrockagentruntime#ResourceNotFoundException" + }, + { + "target": "com.amazonaws.bedrockagentruntime#ServiceQuotaExceededException" + }, + { + "target": "com.amazonaws.bedrockagentruntime#ThrottlingException" + }, + { + "target": "com.amazonaws.bedrockagentruntime#ValidationException" + } + ], + "traits": { + "smithy.api#documentation": "RetrieveAndGenerate API", + "smithy.api#http": { + "code": 200, + "method": "POST", + "uri": "/retrieveAndGenerate" + } + } + }, + "com.amazonaws.bedrockagentruntime#RetrieveAndGenerateConfiguration": { + "type": "structure", + "members": { + "type": { + "target": "com.amazonaws.bedrockagentruntime#RetrieveAndGenerateType", + "traits": { + "smithy.api#required": {} + } + }, + "knowledgeBaseConfiguration": { + "target": "com.amazonaws.bedrockagentruntime#KnowledgeBaseRetrieveAndGenerateConfiguration" + } + }, + "traits": { + "smithy.api#documentation": "Configures the retrieval and generation for the session." + } + }, + "com.amazonaws.bedrockagentruntime#RetrieveAndGenerateInput": { + "type": "structure", + "members": { + "text": { + "target": "smithy.api#String", + "traits": { + "smithy.api#documentation": "Customer input of the turn in text", + "smithy.api#length": { + "max": 1000 + }, + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "Customer input of the turn", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#RetrieveAndGenerateOutput": { + "type": "structure", + "members": { + "text": { + "target": "smithy.api#String", + "traits": { + "smithy.api#documentation": "Service response of the turn in text", + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "Service response of the turn", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#RetrieveAndGenerateRequest": { + "type": "structure", + "members": { + "sessionId": { + "target": "com.amazonaws.bedrockagentruntime#SessionId" + }, + "input": { + "target": "com.amazonaws.bedrockagentruntime#RetrieveAndGenerateInput", + "traits": { + "smithy.api#required": {} + } + }, + "retrieveAndGenerateConfiguration": { + "target": "com.amazonaws.bedrockagentruntime#RetrieveAndGenerateConfiguration" + }, + "sessionConfiguration": { + "target": "com.amazonaws.bedrockagentruntime#RetrieveAndGenerateSessionConfiguration" + } + }, + "traits": { + "smithy.api#input": {} + } + }, + "com.amazonaws.bedrockagentruntime#RetrieveAndGenerateResource": { + "type": "resource", + "operations": [ + { + "target": "com.amazonaws.bedrockagentruntime#RetrieveAndGenerate" + } + ] + }, + "com.amazonaws.bedrockagentruntime#RetrieveAndGenerateResponse": { + "type": "structure", + "members": { + "sessionId": { + "target": "com.amazonaws.bedrockagentruntime#SessionId", + "traits": { + "smithy.api#required": {} + } + }, + "output": { + "target": "com.amazonaws.bedrockagentruntime#RetrieveAndGenerateOutput", + "traits": { + "smithy.api#required": {} + } + }, + "citations": { + "target": "com.amazonaws.bedrockagentruntime#Citations" + } + }, + "traits": { + "smithy.api#output": {} + } + }, + "com.amazonaws.bedrockagentruntime#RetrieveAndGenerateSessionConfiguration": { + "type": "structure", + "members": { + "kmsKeyArn": { + "target": "com.amazonaws.bedrockagentruntime#KmsKeyArn", + "traits": { + "smithy.api#documentation": "The KMS key arn to encrypt the customer data of the session.", + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "Configures common parameters of the session." + } + }, + "com.amazonaws.bedrockagentruntime#RetrieveAndGenerateType": { + "type": "enum", + "members": { + "KNOWLEDGE_BASE": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "KNOWLEDGE_BASE" + } + } + }, + "traits": { + "smithy.api#documentation": "The type of RetrieveAndGenerate." + } + }, + "com.amazonaws.bedrockagentruntime#RetrieveRequest": { + "type": "structure", + "members": { + "knowledgeBaseId": { + "target": "com.amazonaws.bedrockagentruntime#KnowledgeBaseId", + "traits": { + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "retrievalQuery": { + "target": "com.amazonaws.bedrockagentruntime#KnowledgeBaseQuery", + "traits": { + "smithy.api#required": {} + } + }, + "retrievalConfiguration": { + "target": "com.amazonaws.bedrockagentruntime#KnowledgeBaseRetrievalConfiguration" + }, + "nextToken": { + "target": "com.amazonaws.bedrockagentruntime#NextToken" + } + }, + "traits": { + "smithy.api#input": {} + } + }, + "com.amazonaws.bedrockagentruntime#RetrieveResource": { + "type": "resource", + "operations": [ + { + "target": "com.amazonaws.bedrockagentruntime#Retrieve" + } + ] + }, + "com.amazonaws.bedrockagentruntime#RetrieveResponse": { + "type": "structure", + "members": { + "retrievalResults": { + "target": "com.amazonaws.bedrockagentruntime#KnowledgeBaseRetrievalResults", + "traits": { + "smithy.api#required": {} + } + }, + "nextToken": { + "target": "com.amazonaws.bedrockagentruntime#NextToken" + } + }, + "traits": { + "smithy.api#output": {} + } + }, + "com.amazonaws.bedrockagentruntime#RetrievedReference": { + "type": "structure", + "members": { + "content": { + "target": "com.amazonaws.bedrockagentruntime#RetrievalResultContent" + }, + "location": { + "target": "com.amazonaws.bedrockagentruntime#RetrievalResultLocation" + } + }, + "traits": { + "smithy.api#documentation": "Retrieved reference" + } + }, + "com.amazonaws.bedrockagentruntime#RetrievedReferences": { + "type": "list", + "member": { + "target": "com.amazonaws.bedrockagentruntime#RetrievedReference" + }, + "traits": { + "smithy.api#documentation": "list of retrieved references" + } + }, + "com.amazonaws.bedrockagentruntime#ServiceQuotaExceededException": { + "type": "structure", + "members": { + "message": { + "target": "com.amazonaws.bedrockagentruntime#NonBlankString" + } + }, + "traits": { + "smithy.api#documentation": "This exception is thrown when a request is made beyond the service quota", + "smithy.api#error": "client", + "smithy.api#httpError": 400 + } + }, + "com.amazonaws.bedrockagentruntime#SessionAttributesMap": { + "type": "map", + "key": { + "target": "smithy.api#String" + }, + "value": { + "target": "smithy.api#String" + }, + "traits": { + "smithy.api#documentation": "Session attributes are pass through attributes passed to the action group" + } + }, + "com.amazonaws.bedrockagentruntime#SessionId": { + "type": "string", + "traits": { + "smithy.api#documentation": "Identifier of the session.", + "smithy.api#length": { + "min": 2, + "max": 100 + }, + "smithy.api#pattern": "^[0-9a-zA-Z._:-]+$" + } + }, + "com.amazonaws.bedrockagentruntime#SessionState": { + "type": "structure", + "members": { + "sessionAttributes": { + "target": "com.amazonaws.bedrockagentruntime#SessionAttributesMap", + "traits": { + "smithy.api#documentation": "Session Attributes" + } + }, + "promptSessionAttributes": { + "target": "com.amazonaws.bedrockagentruntime#PromptSessionAttributesMap", + "traits": { + "smithy.api#documentation": "Prompt Session Attributes" + } + } + }, + "traits": { + "smithy.api#documentation": "Session state provided" + } + }, + "com.amazonaws.bedrockagentruntime#Source": { + "type": "enum", + "members": { + "ACTION_GROUP": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "ACTION_GROUP" + } + }, + "KNOWLEDGE_BASE": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "KNOWLEDGE_BASE" + } + }, + "PARSER": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "PARSER" + } + } + }, + "traits": { + "smithy.api#documentation": "Parsing error source", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#Span": { + "type": "structure", + "members": { + "start": { + "target": "smithy.api#Integer", + "traits": { + "smithy.api#documentation": "Start of span", + "smithy.api#range": { + "min": 0 + } + } + }, + "end": { + "target": "smithy.api#Integer", + "traits": { + "smithy.api#documentation": "End of span", + "smithy.api#range": { + "min": 0 + } + } + } + }, + "traits": { + "smithy.api#documentation": "Span of text" + } + }, + "com.amazonaws.bedrockagentruntime#StopSequences": { + "type": "list", + "member": { + "target": "smithy.api#String" + }, + "traits": { + "smithy.api#documentation": "List of stop sequences", + "smithy.api#length": { + "min": 0, + "max": 4 + } + } + }, + "com.amazonaws.bedrockagentruntime#Temperature": { + "type": "float", + "traits": { + "smithy.api#documentation": "Controls randomness, higher values increase diversity", + "smithy.api#range": { + "min": 0, + "max": 1 + } + } + }, + "com.amazonaws.bedrockagentruntime#TextResponsePart": { + "type": "structure", + "members": { + "text": { + "target": "smithy.api#String", + "traits": { + "smithy.api#documentation": "Response part in text" + } + }, + "span": { + "target": "com.amazonaws.bedrockagentruntime#Span" + } + }, + "traits": { + "smithy.api#documentation": "Text response part" + } + }, + "com.amazonaws.bedrockagentruntime#ThrottlingException": { + "type": "structure", + "members": { + "message": { + "target": "com.amazonaws.bedrockagentruntime#NonBlankString" + } + }, + "traits": { + "smithy.api#documentation": "This exception is thrown when the number of requests exceeds the limit", + "smithy.api#error": "client", + "smithy.api#httpError": 429 + } + }, + "com.amazonaws.bedrockagentruntime#TopK": { + "type": "integer", + "traits": { + "smithy.api#documentation": "Sample from the k most likely next tokens", + "smithy.api#range": { + "min": 0, + "max": 500 + } + } + }, + "com.amazonaws.bedrockagentruntime#TopP": { + "type": "float", + "traits": { + "smithy.api#documentation": "Cumulative probability cutoff for token selection", + "smithy.api#range": { + "min": 0, + "max": 1 + } + } + }, + "com.amazonaws.bedrockagentruntime#Trace": { + "type": "union", + "members": { + "preProcessingTrace": { + "target": "com.amazonaws.bedrockagentruntime#PreProcessingTrace" + }, + "orchestrationTrace": { + "target": "com.amazonaws.bedrockagentruntime#OrchestrationTrace" + }, + "postProcessingTrace": { + "target": "com.amazonaws.bedrockagentruntime#PostProcessingTrace" + }, + "failureTrace": { + "target": "com.amazonaws.bedrockagentruntime#FailureTrace" + } + }, + "traits": { + "smithy.api#documentation": "Trace contains intermidate response for customer", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#TraceId": { + "type": "string", + "traits": { + "smithy.api#documentation": "Identifier for trace", + "smithy.api#length": { + "min": 2, + "max": 16 + } + } + }, + "com.amazonaws.bedrockagentruntime#TraceKnowledgeBaseId": { + "type": "string", + "traits": { + "smithy.api#documentation": "Agent Trace Action Group Knowledge Base Id", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#TracePart": { + "type": "structure", + "members": { + "agentId": { + "target": "com.amazonaws.bedrockagentruntime#AgentId" + }, + "agentAliasId": { + "target": "com.amazonaws.bedrockagentruntime#AgentAliasId" + }, + "sessionId": { + "target": "com.amazonaws.bedrockagentruntime#SessionId" + }, + "trace": { + "target": "com.amazonaws.bedrockagentruntime#Trace" + } + }, + "traits": { + "smithy.api#documentation": "Trace Part which contains intermidate response for customer", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.bedrockagentruntime#Type": { + "type": "enum", + "members": { + "ACTION_GROUP": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "ACTION_GROUP" + } + }, + "KNOWLEDGE_BASE": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "KNOWLEDGE_BASE" + } + }, + "FINISH": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "FINISH" + } + }, + "ASK_USER": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "ASK_USER" + } + }, + "REPROMPT": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "REPROMPT" + } + } + }, + "traits": { + "smithy.api#documentation": "types of observations" + } + }, + "com.amazonaws.bedrockagentruntime#ValidationException": { + "type": "structure", + "members": { + "message": { + "target": "com.amazonaws.bedrockagentruntime#NonBlankString" + } + }, + "traits": { + "smithy.api#documentation": "This exception is thrown when the request's input validation fails", + "smithy.api#error": "client", + "smithy.api#httpError": 400 + } + }, + "com.amazonaws.bedrockagentruntime#Verb": { + "type": "string", + "traits": { + "smithy.api#documentation": "Agent Trace Action Group Action verb", + "smithy.api#sensitive": {} + } + } + } +}