diff --git a/docs/core_docs/docs/integrations/llms/bedrock.ipynb b/docs/core_docs/docs/integrations/llms/bedrock.ipynb index f32e3d181cea..8786797eea5f 100644 --- a/docs/core_docs/docs/integrations/llms/bedrock.ipynb +++ b/docs/core_docs/docs/integrations/llms/bedrock.ipynb @@ -106,199 +106,10 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": null, "id": "093ae37f", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[Module: null prototype] {\n", - " EndpointURLScheme: { HTTP: \u001b[32m\"http\"\u001b[39m, HTTPS: \u001b[32m\"https\"\u001b[39m },\n", - " HostAddressType: { AAAA: \u001b[32m\"AAAA\"\u001b[39m, A: \u001b[32m\"A\"\u001b[39m },\n", - " HttpAuthLocation: { HEADER: \u001b[32m\"header\"\u001b[39m, QUERY: \u001b[32m\"query\"\u001b[39m },\n", - " RequestHandlerProtocol: { HTTP_0_9: \u001b[32m\"http/0.9\"\u001b[39m, HTTP_1_0: \u001b[32m\"http/1.0\"\u001b[39m, TDS_8_0: \u001b[32m\"tds/8.0\"\u001b[39m },\n", - " default: {\n", - " AbortController: \u001b[36m[Getter]\u001b[39m,\n", - " AbortHandler: \u001b[36m[Getter]\u001b[39m,\n", - " AbortSignal: \u001b[36m[Getter]\u001b[39m,\n", - " AbsoluteLocation: \u001b[36m[Getter]\u001b[39m,\n", - " AuthScheme: \u001b[36m[Getter]\u001b[39m,\n", - " AvailableMessage: \u001b[36m[Getter]\u001b[39m,\n", - " AvailableMessages: \u001b[36m[Getter]\u001b[39m,\n", - " AwsCredentialIdentity: \u001b[36m[Getter]\u001b[39m,\n", - " AwsCredentialIdentityProvider: \u001b[36m[Getter]\u001b[39m,\n", - " BinaryHeaderValue: \u001b[36m[Getter]\u001b[39m,\n", - " BlobTypes: \u001b[36m[Getter]\u001b[39m,\n", - " BodyLengthCalculator: \u001b[36m[Getter]\u001b[39m,\n", - " BooleanHeaderValue: \u001b[36m[Getter]\u001b[39m,\n", - " BuildHandler: \u001b[36m[Getter]\u001b[39m,\n", - " BuildHandlerArguments: \u001b[36m[Getter]\u001b[39m,\n", - " BuildHandlerOptions: \u001b[36m[Getter]\u001b[39m,\n", - " BuildHandlerOutput: \u001b[36m[Getter]\u001b[39m,\n", - " BuildMiddleware: \u001b[36m[Getter]\u001b[39m,\n", - " ByteHeaderValue: \u001b[36m[Getter]\u001b[39m,\n", - " Checksum: \u001b[36m[Getter]\u001b[39m,\n", - " ChecksumConstructor: \u001b[36m[Getter]\u001b[39m,\n", - " Client: \u001b[36m[Getter]\u001b[39m,\n", - " Command: \u001b[36m[Getter]\u001b[39m,\n", - " ConnectConfiguration: \u001b[36m[Getter]\u001b[39m,\n", - " ConnectionManager: \u001b[36m[Getter]\u001b[39m,\n", - " ConnectionManagerConfiguration: \u001b[36m[Getter]\u001b[39m,\n", - " ConnectionPool: \u001b[36m[Getter]\u001b[39m,\n", - " DateInput: \u001b[36m[Getter]\u001b[39m,\n", - " Decoder: \u001b[36m[Getter]\u001b[39m,\n", - " DeserializeHandler: \u001b[36m[Getter]\u001b[39m,\n", - " DeserializeHandlerArguments: \u001b[36m[Getter]\u001b[39m,\n", - " DeserializeHandlerOptions: \u001b[36m[Getter]\u001b[39m,\n", - " DeserializeHandlerOutput: \u001b[36m[Getter]\u001b[39m,\n", - " DeserializeMiddleware: \u001b[36m[Getter]\u001b[39m,\n", - " DocumentType: \u001b[36m[Getter]\u001b[39m,\n", - " Encoder: \u001b[36m[Getter]\u001b[39m,\n", - " Endpoint: \u001b[36m[Getter]\u001b[39m,\n", - " EndpointARN: \u001b[36m[Getter]\u001b[39m,\n", - " EndpointBearer: \u001b[36m[Getter]\u001b[39m,\n", - " EndpointObjectProperty: \u001b[36m[Getter]\u001b[39m,\n", - " EndpointParameters: \u001b[36m[Getter]\u001b[39m,\n", - " EndpointPartition: \u001b[36m[Getter]\u001b[39m,\n", - " EndpointURL: \u001b[36m[Getter]\u001b[39m,\n", - " EndpointURLScheme: \u001b[36m[Getter]\u001b[39m,\n", - " EndpointV2: \u001b[36m[Getter]\u001b[39m,\n", - " EventSigner: \u001b[36m[Getter]\u001b[39m,\n", - " EventSigningArguments: \u001b[36m[Getter]\u001b[39m,\n", - " EventStreamMarshaller: \u001b[36m[Getter]\u001b[39m,\n", - " EventStreamMarshallerDeserFn: \u001b[36m[Getter]\u001b[39m,\n", - " EventStreamMarshallerSerFn: \u001b[36m[Getter]\u001b[39m,\n", - " EventStreamPayloadHandler: \u001b[36m[Getter]\u001b[39m,\n", - " EventStreamPayloadHandlerProvider: \u001b[36m[Getter]\u001b[39m,\n", - " EventStreamRequestSigner: \u001b[36m[Getter]\u001b[39m,\n", - " EventStreamSerdeContext: \u001b[36m[Getter]\u001b[39m,\n", - " EventStreamSerdeProvider: \u001b[36m[Getter]\u001b[39m,\n", - " EventStreamSignerProvider: \u001b[36m[Getter]\u001b[39m,\n", - " ExponentialBackoffJitterType: \u001b[36m[Getter]\u001b[39m,\n", - " ExponentialBackoffStrategyOptions: \u001b[36m[Getter]\u001b[39m,\n", - " FinalizeHandler: \u001b[36m[Getter]\u001b[39m,\n", - " FinalizeHandlerArguments: \u001b[36m[Getter]\u001b[39m,\n", - " FinalizeHandlerOutput: \u001b[36m[Getter]\u001b[39m,\n", - " FinalizeRequestHandlerOptions: \u001b[36m[Getter]\u001b[39m,\n", - " FinalizeRequestMiddleware: \u001b[36m[Getter]\u001b[39m,\n", - " FormattedEvent: \u001b[36m[Getter]\u001b[39m,\n", - " GetAwsChunkedEncodingStream: \u001b[36m[Getter]\u001b[39m,\n", - " GetAwsChunkedEncodingStreamOptions: \u001b[36m[Getter]\u001b[39m,\n", - " Handler: \u001b[36m[Getter]\u001b[39m,\n", - " HandlerExecutionContext: \u001b[36m[Getter]\u001b[39m,\n", - " HandlerOptions: \u001b[36m[Getter]\u001b[39m,\n", - " Hash: \u001b[36m[Getter]\u001b[39m,\n", - " HashConstructor: \u001b[36m[Getter]\u001b[39m,\n", - " HeaderBag: \u001b[36m[Getter]\u001b[39m,\n", - " HostAddressType: \u001b[36m[Getter]\u001b[39m,\n", - " HttpAuthDefinition: \u001b[36m[Getter]\u001b[39m,\n", - " HttpAuthLocation: \u001b[36m[Getter]\u001b[39m,\n", - " HttpHandlerOptions: \u001b[36m[Getter]\u001b[39m,\n", - " HttpMessage: \u001b[36m[Getter]\u001b[39m,\n", - " HttpRequest: \u001b[36m[Getter]\u001b[39m,\n", - " HttpResponse: \u001b[36m[Getter]\u001b[39m,\n", - " Identity: \u001b[36m[Getter]\u001b[39m,\n", - " IdentityProvider: \u001b[36m[Getter]\u001b[39m,\n", - " IniSection: \u001b[36m[Getter]\u001b[39m,\n", - " InitializeHandler: \u001b[36m[Getter]\u001b[39m,\n", - " InitializeHandlerArguments: \u001b[36m[Getter]\u001b[39m,\n", - " InitializeHandlerOptions: \u001b[36m[Getter]\u001b[39m,\n", - " InitializeHandlerOutput: \u001b[36m[Getter]\u001b[39m,\n", - " InitializeMiddleware: \u001b[36m[Getter]\u001b[39m,\n", - " Int64: \u001b[36m[Getter]\u001b[39m,\n", - " IntegerHeaderValue: \u001b[36m[Getter]\u001b[39m,\n", - " LongHeaderValue: \u001b[36m[Getter]\u001b[39m,\n", - " MemoizedProvider: \u001b[36m[Getter]\u001b[39m,\n", - " Message: \u001b[36m[Getter]\u001b[39m,\n", - " MessageDecoder: \u001b[36m[Getter]\u001b[39m,\n", - " MessageEncoder: \u001b[36m[Getter]\u001b[39m,\n", - " MessageHeaderValue: \u001b[36m[Getter]\u001b[39m,\n", - " MessageHeaders: \u001b[36m[Getter]\u001b[39m,\n", - " MessageSigner: \u001b[36m[Getter]\u001b[39m,\n", - " MetadataBearer: \u001b[36m[Getter]\u001b[39m,\n", - " MiddlewareStack: \u001b[36m[Getter]\u001b[39m,\n", - " MiddlewareType: \u001b[36m[Getter]\u001b[39m,\n", - " PaginationConfiguration: \u001b[36m[Getter]\u001b[39m,\n", - " Paginator: \u001b[36m[Getter]\u001b[39m,\n", - " ParsedIniData: \u001b[36m[Getter]\u001b[39m,\n", - " Pluggable: \u001b[36m[Getter]\u001b[39m,\n", - " Priority: \u001b[36m[Getter]\u001b[39m,\n", - " Profile: \u001b[36m[Getter]\u001b[39m,\n", - " Provider: \u001b[36m[Getter]\u001b[39m,\n", - " QueryParameterBag: \u001b[36m[Getter]\u001b[39m,\n", - " RegionInfo: \u001b[36m[Getter]\u001b[39m,\n", - " RegionInfoProvider: \u001b[36m[Getter]\u001b[39m,\n", - " RegionInfoProviderOptions: \u001b[36m[Getter]\u001b[39m,\n", - " Relation: \u001b[36m[Getter]\u001b[39m,\n", - " RelativeLocation: \u001b[36m[Getter]\u001b[39m,\n", - " RelativeMiddlewareOptions: \u001b[36m[Getter]\u001b[39m,\n", - " RequestContext: \u001b[36m[Getter]\u001b[39m,\n", - " RequestHandler: \u001b[36m[Getter]\u001b[39m,\n", - " RequestHandlerMetadata: \u001b[36m[Getter]\u001b[39m,\n", - " RequestHandlerOutput: \u001b[36m[Getter]\u001b[39m,\n", - " RequestHandlerProtocol: \u001b[36m[Getter]\u001b[39m,\n", - " RequestPresigner: \u001b[36m[Getter]\u001b[39m,\n", - " RequestPresigningArguments: \u001b[36m[Getter]\u001b[39m,\n", - " RequestSerializer: \u001b[36m[Getter]\u001b[39m,\n", - " RequestSigner: \u001b[36m[Getter]\u001b[39m,\n", - " RequestSigningArguments: \u001b[36m[Getter]\u001b[39m,\n", - " ResponseDeserializer: \u001b[36m[Getter]\u001b[39m,\n", - " ResponseMetadata: \u001b[36m[Getter]\u001b[39m,\n", - " RetryBackoffStrategy: \u001b[36m[Getter]\u001b[39m,\n", - " RetryErrorInfo: \u001b[36m[Getter]\u001b[39m,\n", - " RetryErrorType: \u001b[36m[Getter]\u001b[39m,\n", - " RetryStrategy: \u001b[36m[Getter]\u001b[39m,\n", - " RetryStrategyOptions: \u001b[36m[Getter]\u001b[39m,\n", - " RetryStrategyV2: \u001b[36m[Getter]\u001b[39m,\n", - " RetryToken: \u001b[36m[Getter]\u001b[39m,\n", - " RetryableTrait: \u001b[36m[Getter]\u001b[39m,\n", - " SdkError: \u001b[36m[Getter]\u001b[39m,\n", - " SdkStream: \u001b[36m[Getter]\u001b[39m,\n", - " SdkStreamMixin: \u001b[36m[Getter]\u001b[39m,\n", - " SdkStreamMixinInjector: \u001b[36m[Getter]\u001b[39m,\n", - " SdkStreamSerdeContext: \u001b[36m[Getter]\u001b[39m,\n", - " SerdeContext: \u001b[36m[Getter]\u001b[39m,\n", - " SerializeHandler: \u001b[36m[Getter]\u001b[39m,\n", - " SerializeHandlerArguments: \u001b[36m[Getter]\u001b[39m,\n", - " SerializeHandlerOptions: \u001b[36m[Getter]\u001b[39m,\n", - " SerializeHandlerOutput: \u001b[36m[Getter]\u001b[39m,\n", - " SerializeMiddleware: \u001b[36m[Getter]\u001b[39m,\n", - " SharedConfigFiles: \u001b[36m[Getter]\u001b[39m,\n", - " ShortHeaderValue: \u001b[36m[Getter]\u001b[39m,\n", - " SignableMessage: \u001b[36m[Getter]\u001b[39m,\n", - " SignedMessage: \u001b[36m[Getter]\u001b[39m,\n", - " SigningArguments: \u001b[36m[Getter]\u001b[39m,\n", - " SmithyException: \u001b[36m[Getter]\u001b[39m,\n", - " SourceData: \u001b[36m[Getter]\u001b[39m,\n", - " StandardRetryBackoffStrategy: \u001b[36m[Getter]\u001b[39m,\n", - " StandardRetryToken: \u001b[36m[Getter]\u001b[39m,\n", - " Step: \u001b[36m[Getter]\u001b[39m,\n", - " StreamCollector: \u001b[36m[Getter]\u001b[39m,\n", - " StreamHasher: \u001b[36m[Getter]\u001b[39m,\n", - " StringHeaderValue: \u001b[36m[Getter]\u001b[39m,\n", - " StringSigner: \u001b[36m[Getter]\u001b[39m,\n", - " Terminalware: \u001b[36m[Getter]\u001b[39m,\n", - " TimestampHeaderValue: \u001b[36m[Getter]\u001b[39m,\n", - " TokenIdentity: \u001b[36m[Getter]\u001b[39m,\n", - " TokenIdentityProvider: \u001b[36m[Getter]\u001b[39m,\n", - " URI: \u001b[36m[Getter]\u001b[39m,\n", - " UrlParser: \u001b[36m[Getter]\u001b[39m,\n", - " UserAgent: \u001b[36m[Getter]\u001b[39m,\n", - " UserAgentPair: \u001b[36m[Getter]\u001b[39m,\n", - " UuidHeaderValue: \u001b[36m[Getter]\u001b[39m,\n", - " WaiterConfiguration: \u001b[36m[Getter]\u001b[39m,\n", - " WithSdkStreamMixin: \u001b[36m[Getter]\u001b[39m,\n", - " randomValues: \u001b[36m[Getter]\u001b[39m\n", - " }\n", - "}" - ] - }, - "execution_count": 17, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "// @lc-docs-hide-cell\n", "// Deno requires these imports, and way of loading env vars.\n", @@ -314,14 +125,15 @@ "import \"@smithy/util-utf8\";\n", "import \"@aws-sdk/types\";\n", "import { Bedrock } from \"@langchain/community/llms/bedrock\"\n", + "import { getEnvironmentVariable } from \"@langchain/core/utils/env\";\n", "\n", "const llm = new Bedrock({\n", " model: \"anthropic.claude-v2\",\n", " region: \"us-east-1\",\n", " // endpointUrl: \"custom.amazonaws.com\",\n", " credentials: {\n", - " accessKeyId: Deno.env.get(\"BEDROCK_AWS_ACCESS_KEY_ID\"),\n", - " secretAccessKey: Deno.env.get(\"BEDROCK_AWS_SECRET_ACCESS_KEY\"),\n", + " accessKeyId: getEnvironmentVariable(\"BEDROCK_AWS_ACCESS_KEY_ID\"),\n", + " secretAccessKey: getEnvironmentVariable(\"BEDROCK_AWS_SECRET_ACCESS_KEY\"),\n", " },\n", " temperature: 0,\n", " maxTokens: undefined,\n", @@ -367,7 +179,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 3, "id": "035dea0f", "metadata": { "tags": [] @@ -378,10 +190,10 @@ "text/plain": [ "\u001b[32m\" Here are a few key points about Bedrock AI:\\n\"\u001b[39m +\n", " \u001b[32m\"\\n\"\u001b[39m +\n", - " \u001b[32m\"- Bedrock was founded in 2021 and is based in San Fran\"\u001b[39m... 113 more characters" + " \u001b[32m\"- Bedrock was founded in 2021 and is based in San Fran\"\u001b[39m... 116 more characters" ] }, - "execution_count": 18, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" }