From fc031b998e0c3eeb037e1e7307b3e56c3d7909da Mon Sep 17 00:00:00 2001 From: bracesproul Date: Thu, 1 Aug 2024 16:10:54 -0700 Subject: [PATCH 1/4] docs[minor]: Update bedrock llm integration doc --- deno.json | 9 +- .../docs/integrations/llms/bedrock.ipynb | 475 ++++++++++++++++++ .../docs/integrations/llms/bedrock.mdx | 43 -- .../src/cli/docs/templates/llms.ipynb | 1 + 4 files changed, 484 insertions(+), 44 deletions(-) create mode 100644 docs/core_docs/docs/integrations/llms/bedrock.ipynb delete mode 100644 docs/core_docs/docs/integrations/llms/bedrock.mdx diff --git a/deno.json b/deno.json index 75907ca225ae..dbb94a073424 100644 --- a/deno.json +++ b/deno.json @@ -31,6 +31,13 @@ "youtube-transcript": "npm:/youtube-transcript", "neo4j-driver": "npm:/neo4j-driver", "axios": "npm:/axios", - "@mendable/firecrawl-js": "npm:/@mendable/firecrawl-js" + "@mendable/firecrawl-js": "npm:/@mendable/firecrawl-js", + "@aws-crypto/sha256-js": "npm:/@aws-crypto/sha256-js", + "@aws-sdk/credential-provider-node": "npm:/@aws-sdk/credential-provider-node", + "@smithy/protocol-http": "npm:/@smithy/protocol-http", + "@smithy/signature-v4": "npm:/@smithy/signature-v4", + "@smithy/eventstream-codec": "npm:/@smithy/eventstream-codec", + "@smithy/util-utf8": "npm:/@smithy/util-utf8", + "@aws-sdk/types": "npm:/@aws-sdk/types" } } \ No newline at end of file diff --git a/docs/core_docs/docs/integrations/llms/bedrock.ipynb b/docs/core_docs/docs/integrations/llms/bedrock.ipynb new file mode 100644 index 000000000000..f32e3d181cea --- /dev/null +++ b/docs/core_docs/docs/integrations/llms/bedrock.ipynb @@ -0,0 +1,475 @@ +{ + "cells": [ + { + "cell_type": "raw", + "id": "67db2992", + "metadata": {}, + "source": [ + "---\n", + "sidebar_label: Bedrock\n", + "---" + ] + }, + { + "cell_type": "markdown", + "id": "9597802c", + "metadata": {}, + "source": [ + "# Bedrock\n", + "\n", + "```{=mdx}\n", + "\n", + ":::caution\n", + "You are currently on a page documenting the use of Amazon Bedrock models as [text completion models](/docs/concepts/#llms). Many popular models available on Bedrock are [chat completion models](/docs/concepts/#chat-models).\n", + "\n", + "You may be looking for [this page instead](/docs/integrations/chat/bedrock/).\n", + ":::\n", + "\n", + "```\n", + "\n", + "> [Amazon Bedrock](https://aws.amazon.com/bedrock/) is a fully managed service that makes Foundation Models (FMs)\n", + "> from leading AI startups and Amazon available via an API. You can choose from a wide range of FMs to find the model that is best suited for your use case.\n", + "\n", + "This will help you get started with Bedrock completion models (LLMs) using LangChain. For detailed documentation on `Bedrock` features and configuration options, please refer to the [API reference](https://api.js.langchain.com/classes/langchain_community_llms_bedrock.Bedrock.html).\n", + "\n", + "## Overview\n", + "### Integration details\n", + "\n", + "- TODO: Fill in table features.\n", + "- TODO: Remove JS support link if not relevant, otherwise ensure link is correct.\n", + "- TODO: Make sure API reference links are correct.\n", + "\n", + "| Class | Package | Local | Serializable | [PY support](https://python.langchain.com/docs/integrations/llms/bedrock) | Package downloads | Package latest |\n", + "| :--- | :--- | :---: | :---: | :---: | :---: | :---: |\n", + "| [Bedrock](https://api.js.langchain.com/classes/langchain_community_llms_bedrock.Bedrock.html) | [@langchain/community](https://api.js.langchain.com/modules/langchain_community_llms_bedrock.html) | ❌ | ✅ | ✅ | ![NPM - Downloads](https://img.shields.io/npm/dm/@langchain/community?style=flat-square&label=%20&) | ![NPM - Version](https://img.shields.io/npm/v/@langchain/community?style=flat-square&label=%20&) |\n", + "\n", + "## Setup\n", + "\n", + "To access Bedrock models you'll need to create an AWS account, get an API key, and install the `@langchain/community` integration, along with a few peer dependencies.\n", + "\n", + "### Credentials\n", + "\n", + "Head to [aws.amazon.com](https://aws.amazon.com) to sign up to AWS Bedrock and generate an API key. Once you've done this set the environment variables:\n", + "\n", + "```bash\n", + "export BEDROCK_AWS_REGION=\"your-region-url\"\n", + "export BEDROCK_AWS_ACCESS_KEY_ID=\"your-access-key-id\"\n", + "export BEDROCK_AWS_SECRET_ACCESS_KEY=\"your-secret-access-key\"\n", + "```\n", + "\n", + "If you want to get automated tracing of your model calls you can also set your [LangSmith](https://docs.smith.langchain.com/) API key by uncommenting below:\n", + "\n", + "```bash\n", + "# export LANGCHAIN_TRACING_V2=\"true\"\n", + "# export LANGCHAIN_API_KEY=\"your-api-key\"\n", + "```\n", + "\n", + "### Installation\n", + "\n", + "The LangChain Bedrock integration lives in the `@langchain/community` package:\n", + "\n", + "```{=mdx}\n", + "import IntegrationInstallTooltip from \"@mdx_components/integration_install_tooltip.mdx\";\n", + "import Npm2Yarn from \"@theme/Npm2Yarn\";\n", + "\n", + "\n", + "\n", + "\n", + " @langchain/community\n", + "\n", + "\n", + "And install the peer dependencies:\n", + "\n", + "\n", + " @aws-crypto/sha256-js @aws-sdk/credential-provider-node @smithy/protocol-http @smithy/signature-v4 @smithy/eventstream-codec @smithy/util-utf8 @aws-sdk/types\n", + "\n", + "\n", + "You can also use Bedrock in web environments such as Edge functions or Cloudflare Workers by omitting the `@aws-sdk/credential-provider-node` dependency\n", + "and using the `web` entrypoint:\n", + "\n", + "\n", + " @aws-crypto/sha256-js @smithy/protocol-http @smithy/signature-v4 @smithy/eventstream-codec @smithy/util-utf8 @aws-sdk/types\n", + "\n", + "\n", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "0a760037", + "metadata": {}, + "source": [ + "## Instantiation\n", + "\n", + "Now we can instantiate our model object and generate chat completions:" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "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" + } + ], + "source": [ + "// @lc-docs-hide-cell\n", + "// Deno requires these imports, and way of loading env vars.\n", + "// we don't want to expose in the docs.\n", + "// Below this cell we have a typescript markdown codeblock with\n", + "// the node code.\n", + "import \"@aws-sdk/credential-provider-node\";\n", + "import \"@smithy/protocol-http\";\n", + "import \"@aws-crypto/sha256-js\";\n", + "import \"@smithy/protocol-http\";\n", + "import \"@smithy/signature-v4\";\n", + "import \"@smithy/eventstream-codec\";\n", + "import \"@smithy/util-utf8\";\n", + "import \"@aws-sdk/types\";\n", + "import { Bedrock } from \"@langchain/community/llms/bedrock\"\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", + " },\n", + " temperature: 0,\n", + " maxTokens: undefined,\n", + " maxRetries: 2,\n", + " // other params...\n", + "})" + ] + }, + { + "cell_type": "markdown", + "id": "a0562a13", + "metadata": {}, + "source": [ + "```typescript\n", + "import { Bedrock } from \"@langchain/community/llms/bedrock\"\n", + "\n", + "const llm = new Bedrock({\n", + " model: \"anthropic.claude-v2\",\n", + " region: process.env.BEDROCK_AWS_REGION ?? \"us-east-1\",\n", + " // endpointUrl: \"custom.amazonaws.com\",\n", + " credentials: {\n", + " accessKeyId: process.env.BEDROCK_AWS_ACCESS_KEY_ID,\n", + " secretAccessKey: process.env.BEDROCK_AWS_SECRET_ACCESS_KEY,\n", + " },\n", + " temperature: 0,\n", + " maxTokens: undefined,\n", + " maxRetries: 2,\n", + " // other params...\n", + "})\n", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "0ee90032", + "metadata": {}, + "source": [ + "## Invocation\n", + "\n", + "Note that some models require specific prompting techniques. For example, Anthropic's Claude-v2 model will throw an error if\n", + "the prompt does not start with `Human: `." + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "035dea0f", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "data": { + "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" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "const inputText = \"Human: Bedrock is an AI company that\\nAssistant: \"\n", + "\n", + "const completion = await llm.invoke(inputText)\n", + "completion" + ] + }, + { + "cell_type": "markdown", + "id": "add38532", + "metadata": {}, + "source": [ + "## Chaining\n", + "\n", + "We can [chain](/docs/how_to/sequence/) our completion model with a prompt template like so:" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "078e9db2", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "\u001b[32m' Here is how to say \"I love programming\" in German:\\n'\u001b[39m +\n", + " \u001b[32m\"\\n\"\u001b[39m +\n", + " \u001b[32m\"Ich liebe das Programmieren.\"\u001b[39m" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import { PromptTemplate } from \"@langchain/core/prompts\"\n", + "\n", + "const prompt = new PromptTemplate({\n", + " template: \"Human: How to say {input} in {output_language}:\\nAssistant:\",\n", + " inputVariables: [\"input\", \"output_language\"],\n", + "})\n", + "\n", + "const chain = prompt.pipe(llm);\n", + "await chain.invoke(\n", + " {\n", + " output_language: \"German\",\n", + " input: \"I love programming.\",\n", + " }\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "e9bdfcef", + "metadata": {}, + "source": [ + "## API reference\n", + "\n", + "For detailed documentation of all Bedrock features and configurations head to the API reference: https://api.js.langchain.com/classes/langchain_community_llms_bedrock.Bedrock.html" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Deno", + "language": "typescript", + "name": "deno" + }, + "language_info": { + "file_extension": ".ts", + "mimetype": "text/x.typescript", + "name": "typescript", + "nb_converter": "script", + "pygments_lexer": "typescript", + "version": "5.3.3" + }, + "vscode": { + "interpreter": { + "hash": "e971737741ff4ec9aff7dc6155a1060a59a8a6d52c757dbbe66bf8ee389494b1" + } + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/docs/core_docs/docs/integrations/llms/bedrock.mdx b/docs/core_docs/docs/integrations/llms/bedrock.mdx deleted file mode 100644 index 12627060a129..000000000000 --- a/docs/core_docs/docs/integrations/llms/bedrock.mdx +++ /dev/null @@ -1,43 +0,0 @@ -# Bedrock - -:::caution -You are currently on a page documenting the use of Amazon Bedrock models as [text completion models](/docs/concepts/#llms). Many popular models available on Bedrock are [chat completion models](/docs/concepts/#chat-models). - -You may be looking for [this page instead](/docs/integrations/chat/bedrock/). -::: - -> [Amazon Bedrock](https://aws.amazon.com/bedrock/) is a fully managed service that makes Foundation Models (FMs) -> from leading AI startups and Amazon available via an API. You can choose from a wide range of FMs to find the model that is best suited for your use case. - -## Setup - -You'll need to install a few official AWS packages as peer dependencies: - -```bash npm2yarn -npm install @aws-crypto/sha256-js @aws-sdk/credential-provider-node @smithy/protocol-http @smithy/signature-v4 @smithy/eventstream-codec @smithy/util-utf8 @aws-sdk/types -``` - -You can also use Bedrock in web environments such as Edge functions or Cloudflare Workers by omitting the `@aws-sdk/credential-provider-node` dependency -and using the `web` entrypoint: - -```bash npm2yarn -npm install @aws-crypto/sha256-js @smithy/protocol-http @smithy/signature-v4 @smithy/eventstream-codec @smithy/util-utf8 @aws-sdk/types -``` - -## Usage - -import IntegrationInstallTooltip from "@mdx_components/integration_install_tooltip.mdx"; - - - -```bash npm2yarn -npm install @langchain/community -``` - -Note that some models require specific prompting techniques. For example, Anthropic's Claude-v2 model will throw an error if -the prompt does not start with `Human: `. - -import CodeBlock from "@theme/CodeBlock"; -import BedrockExample from "@examples/models/llm/bedrock.ts"; - -{BedrockExample} diff --git a/libs/langchain-scripts/src/cli/docs/templates/llms.ipynb b/libs/langchain-scripts/src/cli/docs/templates/llms.ipynb index 659639446b34..6dadea4339d3 100644 --- a/libs/langchain-scripts/src/cli/docs/templates/llms.ipynb +++ b/libs/langchain-scripts/src/cli/docs/templates/llms.ipynb @@ -162,6 +162,7 @@ "\n", "const prompt = new PromptTemplate({\n", " template: \"How to say {input} in {output_language}:\\n\",\n", + " inputVariables: [\"input\", \"output_language\"],\n", "})\n", "\n", "const chain = prompt.pipe(llm);\n", From 32f740bb500a06d946892213166850104e975a5f Mon Sep 17 00:00:00 2001 From: bracesproul Date: Thu, 1 Aug 2024 16:48:45 -0700 Subject: [PATCH 2/4] getEnvVar util func instead of Deno.env.get(...) --- .../docs/integrations/llms/bedrock.ipynb | 204 +----------------- 1 file changed, 8 insertions(+), 196 deletions(-) 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" } From 25128a458f1ebad49ca880c7082a072e37ff805b Mon Sep 17 00:00:00 2001 From: bracesproul Date: Thu, 1 Aug 2024 18:18:46 -0700 Subject: [PATCH 3/4] cr --- docs/core_docs/docs/integrations/llms/bedrock.ipynb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docs/core_docs/docs/integrations/llms/bedrock.ipynb b/docs/core_docs/docs/integrations/llms/bedrock.ipynb index 8786797eea5f..be1ff211a38e 100644 --- a/docs/core_docs/docs/integrations/llms/bedrock.ipynb +++ b/docs/core_docs/docs/integrations/llms/bedrock.ipynb @@ -237,10 +237,7 @@ "source": [ "import { PromptTemplate } from \"@langchain/core/prompts\"\n", "\n", - "const prompt = new PromptTemplate({\n", - " template: \"Human: How to say {input} in {output_language}:\\nAssistant:\",\n", - " inputVariables: [\"input\", \"output_language\"],\n", - "})\n", + "const prompt = PromptTemplate.fromTemplate(\"Human: How to say {input} in {output_language}:\\nAssistant:\")\n", "\n", "const chain = prompt.pipe(llm);\n", "await chain.invoke(\n", From 97038cd0e99b99d0259561187b6c7134758aea14 Mon Sep 17 00:00:00 2001 From: bracesproul Date: Thu, 1 Aug 2024 18:19:24 -0700 Subject: [PATCH 4/4] cr --- libs/langchain-scripts/src/cli/docs/templates/llms.ipynb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libs/langchain-scripts/src/cli/docs/templates/llms.ipynb b/libs/langchain-scripts/src/cli/docs/templates/llms.ipynb index 6dadea4339d3..eac6a24b611d 100644 --- a/libs/langchain-scripts/src/cli/docs/templates/llms.ipynb +++ b/libs/langchain-scripts/src/cli/docs/templates/llms.ipynb @@ -160,10 +160,7 @@ "source": [ "import { PromptTemplate } from \"@langchain/core/prompts\"\n", "\n", - "const prompt = new PromptTemplate({\n", - " template: \"How to say {input} in {output_language}:\\n\",\n", - " inputVariables: [\"input\", \"output_language\"],\n", - "})\n", + "const prompt = PromptTemplate.fromTemplate(\"How to say {input} in {output_language}:\\n\")\n", "\n", "const chain = prompt.pipe(llm);\n", "await chain.invoke(\n",