{"id":4168,"date":"2023-11-24T13:55:25","date_gmt":"2023-11-24T04:55:25","guid":{"rendered":"https:\/\/blog.since2020.jp\/?p=4168"},"modified":"2023-11-24T13:55:25","modified_gmt":"2023-11-24T04:55:25","slug":"aws-bedrock_claude2","status":"publish","type":"post","link":"https:\/\/since2020.jp\/media\/aws-bedrock_claude2\/","title":{"rendered":"AWS Bedrock\u304b\u3089GPT\u3067\u306f\u306a\u3044\u751f\u6210\u7cfbAI\u3001Claude2\u3092\u4f7f\u3063\u3066\u307f\u305f"},"content":{"rendered":"\n<p>AWS Bedrock\u3092\u4f7f\u3063\u3066Claude2\u3092\u89e6\u3063\u3066\u307f\u305f\u306e\u3067\u3001AWS Bedrock\u306e\u4f7f\u3044\u65b9\u304b\u3089\u3054\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n\n\n<h2>\u306f\u3058\u3081\u306b<\/h2>\n<p>\u4eca\u56de\u306fAnthropic\u793e\u306e\u57fa\u76e4\u30e2\u30c7\u30ebClaude2\u3092AWS\u306eBedrock\u3092\u4f7f\u3063\u3066\u4f7f\u7528\u3057\u3066\u307f\u305f\u306e\u3067\u3001<span data-token-index=\"1\" class=\"discussion-level-1 discussion-id-fbd5dc54-7a4a-40ab-86d1-75c16c4dc68b notion-enable-hover\">\u305d\u306e\u4f7f\u7528\u624b\u9806<\/span>\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002<!-- notionvc: 8e7e55c0-c6d7-4e70-a983-a847a068230a --><\/p>\n\n<h2>AWS bedrock\u3092\u4f7f\u3046\u305f\u3081\u306e\u6e96\u5099<\/h2>\n\u4ee5\u4e0b\u306e\u3088\u3046\u306a3\u6bb5\u968e\u306b\u5206\u3051\u3066\u884c\u3044\u307e\u3059\u3002\r\n1. AWS\u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u4f5c\u6210\r\n2. IAM\u30e6\u30fc\u30b6\u306e\u4f5c\u6210\u3068\u8a2d\u5b9a\r\n3. Bedrock\u4e0a\u306e\u8a2d\u5b9a\n\n<h2>AWS\u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u4f5c\u6210<\/h2>\n<p>\u3053\u306e\u5de5\u7a0b\u306fAWS\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u65b0\u3057\u304f\u4f5c\u308b\u5fc5\u8981\u304c\u3042\u308b\u5834\u5408\u306e\u307f\u884c\u3044\u307e\u3059\u3002<\/p>\r\n<p>\u3053\u306eAWS\u306e<a href=\"https:\/\/portal.aws.amazon.com\/billing\/signup#\/start\/email\">\u30b5\u30a4\u30f3\u30a2\u30c3\u30d7\u30da\u30fc\u30b8<\/a>\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30da\u30fc\u30b8\u304c\u51fa\u3066\u304f\u308b\u306e\u3067\u3001\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u4f5c\u308a\u307e\u3057\u3087\u3046\u3002\u3053\u306e\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306b\u5bfe\u5fdc\u3057\u305f\u30e6\u30fc\u30b6\u304c\u30eb\u30fc\u30c8\u30e6\u30fc\u30b6\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n\n<h2>IAM\u30e6\u30fc\u30b6\u30fc\u306e\u4f5c\u6210<\/h2>\n<p>AWS\u30a2\u30ab\u30a6\u30f3\u30c8\u4f5c\u6210\u6642\u306b\u4f5c\u3089\u308c\u308b\u30eb\u30fc\u30c8\u30e6\u30fc\u30b6\u306f\u5168\u3066\u306e\u6a29\u9650\u3092\u6301\u3063\u3066\u3044\u3066\u3001\u305d\u306e\u307e\u307e\u5229\u7528\u3059\u308b\u3053\u3068\u306f\u5371\u967a\u3067\u3059\u3002\u305d\u3053\u3067\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u5358\u4f4d\u3067\u6271\u3048\u308b\u7bc4\u56f2\u3092\u9650\u5b9a\u3057\u305fIAM\u30e6\u30fc\u30b6\u30fc\u3068\u3044\u3046\u3082\u306e\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u4eca\u56de\u306f\u958b\u767a\u5468\u308a\u306b\u3064\u3044\u3066\u306f\u3042\u308b\u7a0b\u5ea6\u81ea\u7531\u306b\u884c\u3048\u308b\u6a29\u9650\u3092\u6301\u3064\u304c\u3001\u30a2\u30ab\u30a6\u30f3\u30c8\u5468\u308a\u306e\u30b5\u30fc\u30d3\u30b9\u3078\u306e\u6a29\u9650\u306b\u3064\u3044\u3066\u306f\u5236\u9650\u3055\u308c\u3066\u3044\u308b\u3068\u3044\u3046\u3001\u3042\u308b\u7a0b\u5ea6\u6a29\u9650\u306e\u5f37\u3044IAM\u30e6\u30fc\u30b6\u30fc\u3092\u4f7f\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\r\n<p>\u3053\u306e\u6a29\u9650\u3092\u30e6\u30fc\u30b6\u30fc\u306b\u4ed8\u4e0e\u3059\u308b1\u3064\u306e\u65b9\u6cd5\u304c\u30dd\u30ea\u30b7\u30fc\u3068\u547c\u3070\u308c\u308b\u3082\u306e\u3067\u3001\u4eca\u56de\u306e\u3088\u3046\u306a\u7528\u9014\u3067\u306fPowerUserAccess\u3068\u3044\u3046\u30dd\u30ea\u30b7\u30fc\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002\u3069\u306e\u7a0b\u5ea6\u306e\u6a29\u9650\u3092\u4e0e\u3048\u308b\u304b\u306b\u3064\u3044\u3066\u306f\u3001\u3054\u81ea\u5206\u306e\u4f7f\u7528\u72b6\u6cc1\u7b49\u3092\u8e0f\u307e\u3048\u3066\u6c7a\u3081\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\r\n<p><strong>\u624b\u9806<\/strong><\/p>\r\n<p>\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u306e\u30c8\u30c3\u30d7\u30da\u30fc\u30b8\u304b\u3089\u4ee5\u4e0b\u306e\u3088\u3046\u306bIAM\u30e6\u30fc\u30b6\u306e\u7de8\u96c6\u30da\u30fc\u30b8\u306b\u79fb\u52d5\u3057\u3001\u300c\u30e6\u30fc\u30b6\u306e\u4f5c\u6210\u300d\u30dc\u30bf\u30f3\u3092\u62bc\u3057\u307e\u3059\u3002<\/p>\r\n<p><img decoding=\"async\" src=\"https:\/\/since2020.jp\/media\/wp-content\/uploads\/2023\/11\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2023-11-10-12.00.41.png\" alt=\"\" \/><\/p>\r\n<p>\u00a0<\/p>\r\n<p>\u4ee5\u4e0b\u306e\u30da\u30fc\u30b8\u306b\u79fb\u3063\u305f\u3089\u3001\u4f7f\u7528\u3057\u305f\u3044\u30e6\u30fc\u30b6\u30fc\u540d\u3092\u5165\u529b\u3057\u307e\u3059\u3002\u30de\u30cd\u30b8\u30e1\u30f3\u30c8\u30b3\u30f3\u30bd\u30fc\u30eb\u3078\u306e\u30e6\u30fc\u30b6\u30a2\u30af\u30bb\u30b9\u3068\u3044\u3046\u306e\u306f\u3001\u4eca\u30eb\u30fc\u30c8\u30e6\u30fc\u30b6\u3068\u3057\u3066\u884c\u306a\u3063\u3066\u3044\u308b\u3088\u3046\u306a\u30b3\u30f3\u30bd\u30fc\u30eb\u306e\u64cd\u4f5c\u3092\u3053\u306eIAM\u30e6\u30fc\u30b6\u306b\u5bfe\u3057\u3066\u3082\u8a31\u53ef\u3059\u308b\u5834\u5408\u306b\u30aa\u30f3\u306b\u3057\u307e\u3059\u3002\u4eca\u56de\u306fBedrock\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3060\u3051\u306a\u306e\u3067\u3001\u30aa\u30d5\u3092\u9078\u629e\u3057\u3066\u6b21\u306b\u9032\u307f\u307e\u3059\u3002<!-- notionvc: 9887fe9a-ab3c-43fd-8610-d2acdb2dbd59 --><\/p>\r\n<p><img decoding=\"async\" src=\"https:\/\/since2020.jp\/media\/wp-content\/uploads\/2023\/11\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2023-11-10-12.10.08.png\" alt=\"\" \/><\/p>\r\n<p>\u00a0<\/p>\r\n<p>\u305d\u306e\u6b21\u306b\u8a31\u53ef\u3092\u8a2d\u5b9a\u3068\u3044\u3046\u30da\u30fc\u30b8\u304c\u51fa\u3066\u304d\u307e\u3059\u3002\u3053\u3053\u3067\u3001\u305d\u306eIAM\u30e6\u30fc\u30b6\u306b\u3069\u306e\u3088\u3046\u306a\u6a29\u9650(\u30dd\u30ea\u30b7\u30fc)\u3092\u4e0e\u3048\u308b\u304b\u3092\u6c7a\u5b9a\u3057\u307e\u3059\u3002\u30b0\u30eb\u30fc\u30d7\u3068\u547c\u3070\u308c\u308b\u5171\u901a\u306e\u6a29\u9650\u3092\u4e0e\u3048\u308b\u96c6\u56e3\u3092\u4f5c\u3063\u3066\u3001\u305d\u3053\u306b\u8ffd\u52a0\u3057\u3066\u3082\u3044\u3044\u3067\u3059\u304c\u3053\u3053\u3067\u306f\u500b\u5225\u306b\u52a0\u3048\u3066\u3044\u304d\u307e\u3059\u3002\u4eca\u56de\u306e\u6a29\u9650\u3067\u306f\u3001PowerUserAccess\u3068\u3044\u3046\u30dd\u30ea\u30b7\u30fc\u3092\u4f7f\u3046\u306e\u3067\u3001\u3053\u308c\u3092\u9078\u629e\u3057\u305f\u306e\u3061\u78ba\u8a8d\u753b\u9762\u3067\u4fdd\u5b58\u3057\u307e\u3059\u3002<\/p>\r\n<p><img decoding=\"async\" src=\"https:\/\/since2020.jp\/media\/wp-content\/uploads\/2023\/11\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2023-11-10-12.23.24.png\" alt=\"\" \/><\/p>\r\n<p>\u00a0<\/p>\r\n<p>\u305d\u306e\u5f8c\u3001IAM\u30e6\u30fc\u30b6\u306e\u7de8\u96c6\u30da\u30fc\u30b8\u306b\u623b\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30e6\u30fc\u30b6\u306e\u4e00\u89a7\u306e\u4e2d\u306b\u4f5c\u3063\u305f\u30e6\u30fc\u30b6\u304c\u3042\u308b\u306f\u305a\u3067\u3059\u3002\u305d\u306e\u30e6\u30fc\u30b6\u540d\u306e\u90e8\u5206\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001\u305d\u306eIAM\u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u30da\u30fc\u30b8\u306b\u98db\u3079\u308b\u306e\u3067\u30a2\u30af\u30bb\u30b9\u30ad\u30fc\u3092\u4f5c\u6210\u3057\u3001\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u3068\u3057\u3066\u30ed\u30fc\u30ab\u30eb\u30b3\u30fc\u30c9\u3092\u9078\u629e\u3057\u307e\u3059\u3002\u30a2\u30af\u30bb\u30b9\u30ad\u30fc\u3068\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u30a2\u30af\u30bb\u30b9\u30ad\u30fc\u3068\u547c\u3070\u308c\u308b\u3082\u306e\u304c\u51fa\u529b\u3055\u308c\u308b\u306e\u3067\u4fdd\u5b58\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002API\u306e\u4f7f\u7528\u6642\u306b\u4f7f\u3044\u307e\u3059\u3002<\/p>\r\n<p><img decoding=\"async\" src=\"https:\/\/since2020.jp\/media\/wp-content\/uploads\/2023\/11\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2023-11-17-9.49.15.png\" alt=\"\" \/><\/p>\n\n<h2>Bedrock\u306e\u8a2d\u5b9a<\/h2>\n<p>\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u306e\u30c8\u30c3\u30d7\u30da\u30fc\u30b8\u304b\u3089\u540c\u3058\u3088\u3046\u306bBedrock\u3092\u691c\u7d22\u3057\u3001\u4ee5\u4e0b\u306e\u30da\u30fc\u30b8\u3067Base models\u3092\u9078\u629e\u3057\u307e\u3059\u3002\u521d\u56de\u306f\u30e2\u30c7\u30eb\u304c\u958b\u653e\u3055\u308c\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u5229\u7528\u7528\u9014\u7b49\u3092\u8a18\u5165\u3059\u308b\u3053\u3068\u3067\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\u79c1\u306e\u5834\u5408\u3067\u306f\u3001\u8a18\u5165\u3057\u30661\u6642\u9593\u3082\u3057\u306a\u3044\u3046\u3061\u306b\u6c17\u3065\u3044\u305f\u3089\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\r\n<p>\u6ce8\u610f\u70b9\u3068\u3057\u3066\u306fregion\u306b\u3088\u3063\u3066\u4f7f\u3048\u308b\u30e2\u30c7\u30eb\u304c\u5236\u9650\u3055\u308c\u3066\u3057\u307e\u3046\u3053\u3068\u3067\u3059\u3002us-east-1\u3092\u4f7f\u3046\u3068\u3044\u3044\u3067\u3057\u3087\u3046\u3002<br \/>\r\n<img decoding=\"async\" src=\"https:\/\/since2020.jp\/media\/wp-content\/uploads\/2023\/11\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2023-11-10-13.03.42.png\" alt=\"\" \/><\/p>\n\n<h2>\u30e2\u30b8\u30e5\u30fc\u30eb\u7cfb\u306eimport<\/h2>\n<p>\u4eca\u56de\u306fLangChain\u3092\u4f7f\u3063\u3066\u5b9f\u88c5\u3057\u307e\u3059\u3002\u307e\u305a\u306f\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u30a4\u30f3\u30dd\u30fc\u30c8\u3068\u30bb\u30c3\u30b7\u30e7\u30f3\u306e\u78ba\u7acb\u3067\u3059\u3002\u30a2\u30af\u30bb\u30b9\u30ad\u30fc\u7b49\u306f\u81ea\u5206\u306e\u3092\u4f7f\u7528\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\r\n<div class=\"hcb_wrap\">\r\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>from boto3.session import Session\r\nfrom langchain.chat_models import BedrockChat\r\nfrom langchain.chains import ConversationChain\r\nfrom langchain.memory import ConversationBufferMemory\r\nfrom langchain.prompts.chat import (\r\n    ChatPromptTemplate,\r\n    HumanMessagePromptTemplate,\r\n    MessagesPlaceholder,\r\n)\r\n\r\nsession = Session(\r\n    aws_access_key_id='your access key',\r\n    aws_secret_access_key='your seacret access key',\r\n)\r\n\r\nbedrock_runtime = session.client(\"bedrock-runtime\", region_name=\"your region\")<\/code><\/pre>\r\n<\/div>\n\n<h2>\u30c1\u30e3\u30c3\u30c8\u30dc\u30c3\u30c8\u3092\u4f5c\u6210<\/h2>\n<p>\u5168\u4f53\u306e\u6982\u8981\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u3067\u3059\u3002\u6700\u5f8c\u306e\u884c\u306b\u81ea\u5206\u306e\u805e\u304d\u305f\u3044\u5185\u5bb9\u3092\u5165\u308c\u307e\u3059\u3002\u305d\u308c\u305e\u308c\u5177\u4f53\u7684\u306b\u8aac\u660e\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\r\n<div class=\"hcb_wrap\">\r\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>llm = BedrockChat(\r\n    client=bedrock_runtime,\r\n    model_id=\"anthropic.claude-v2\",\r\n    model_kwargs={\"temperature\":0.0, \"max_tokens_to_sample\": 8192},\r\n)\r\n\r\nmemory = ConversationBufferMemory(return_messages=True)\r\nprompt = ChatPromptTemplate.from_messages([\r\n    MessagesPlaceholder(variable_name=\"history\"),\r\n    HumanMessagePromptTemplate.from_template(\"\"\"{input}\"\"\")\r\n])\r\n\r\nllm_chain = ConversationChain(llm=llm, prompt=prompt, memory=memory)\r\nresult = llm_chain.run(\"Your message to chatbot.\")<\/code><\/pre>\r\n<\/div>\r\n<p><strong>\u8a00\u8a9e\u30e2\u30c7\u30eb\u306e\u53d6\u5f97<\/strong><\/p>\r\n<p>BedrockChat\u3067\u8a00\u8a9e\u30e2\u30c7\u30eb\u3092\u3068\u3063\u3066\u304d\u307e\u3059\u3002\u3053\u3053\u3067\u3068\u3063\u3066\u6765\u308b\u30e2\u30c7\u30eb\u306fmodel_id\u3067\u6307\u5b9a\u3067\u304d\u307e\u3059\u3002\r\nmodel_kwargs\u3067\u306f\u4ee5\u4e0b\u306e\uff12\u70b9\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002\r\n<ul>\r\n\t<li>temperature: 0\u304b\u30891\u306e\u5024\u30670\u306b\u8fd1\u3065\u304f\u307b\u3069\u6c7a\u5b9a\u8ad6\u7684\u306b\u306a\u308a\u307e\u3059\u3002\u30bf\u30b9\u30af\u304c\u6c7a\u307e\u3063\u3066\u3044\u308b\u5834\u5408\u306f0\u306b\u3057\u307e\u3057\u3087\u3046\u3002<\/li>\r\n\t<li>max_tokens_to_sample: \u51fa\u529b\u306e\u6700\u5927\u30c8\u30fc\u30af\u30f3\u6570\u3067\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u51fa\u529b\u304c\u5fc5\u8981\u4ee5\u4e0a\u306b\u9577\u304f\u306a\u308b\u3053\u3068\u3092\u9632\u3050\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/li>\r\n<\/ul>\r\n\u3088\u304f\u4f7f\u3046\u306e\u306f\u3053\u3053\u3089\u8fba\u3067\u3059\u304c\u3001\u4ed6\u306b\u3082\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u306e\u6642\u9593\u7b49\u6307\u5b9a\u3067\u304d\u308b\u8981\u7d20\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\r\n<p><strong>\u30e2\u30c7\u30eb\u306e\u8a18\u61b6<\/strong><\/p>\r\n<p>memory\u306f\u3053\u306e\u30c1\u30e3\u30c3\u30c8\u30dc\u30c3\u30c8\u304c\u6301\u3064\u8a18\u61b6\u3092\u8868\u3057\u307e\u3059\u3002ConversationBufferMemory\u3092\u4eca\u56de\u306f\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u308c\u306f\u30dc\u30c3\u30c8\u306b\u3059\u3079\u3066\u306e\u4f1a\u8a71\u3092\u305d\u306e\u307e\u307e\u8a18\u61b6\u3055\u305b\u308b\u65b9\u6cd5\u3067\u3059\u304c\u3001\u5f53\u7136\u3084\u308a\u3068\u308a\u304c\u9577\u304f\u306a\u308b\u3068\u5fc5\u8981\u3068\u3059\u308b\u30c8\u30fc\u30af\u30f3\u6570\u304c\u7206\u767a\u7684\u306b\u5897\u3048\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\r\n<p>\u4ed6\u306b\u3082\u69d8\u3005\u306a\u8a18\u61b6\u6a5f\u80fd\u304c\u3042\u308a\u3001\u4e00\u4f8b\u3068\u3057\u3066\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u3082\u306e\u304c\u3042\u308a\u307e\u3059\u3002\r\n<ul>\r\n\t<li>ConversationBufferWindowMemory: \u6700\u8fd1n\u500b\u306e\u4f1a\u8a71\u306e\u307f\u3092\u8a18\u61b6\u3002<\/li>\r\n\t<li>ConversationSummaryMemory: \u4eca\u307e\u3067\u306e\u4f1a\u8a71\u306e\u8981\u7d04\u3092\u8a18\u61b6\u3002<\/li>\r\n<\/ul>\r\n<\/p>\r\n<p><strong>\u30d7\u30ed\u30f3\u30d7\u30c8\u306e\u4f5c\u6210<\/strong><\/p>\r\nChatPromptTemplate.from_messages\u306f\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u30ea\u30b9\u30c8\u304b\u3089\u30d7\u30ed\u30f3\u30d7\u30c8\u306e\u5909\u63db\u3057\u307e\u3059\u3002\u307e\u305f\u3001MessagePlaceholder\u3068HumanMessagePromptTemplate\u306f\u3001\u4f7f\u3044\u305f\u3044\u5185\u5bb9\u306b\u8a71\u8005\u3084\u5c5e\u6027\u306e\u60c5\u5831\u3092\u4ed8\u4e0e\u3057\u3066\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u4f5c\u308b\u6a5f\u80fd\u3060\u3068\u601d\u3046\u3068\u7406\u89e3\u3057\u3084\u3059\u3044\u3067\u3059\u3002\r\n\r\n\u5f8c\u8005\u306eHumanMessagePromptTemplate\u306b\u3064\u3044\u3066\u306f\u4e0e\u3048\u308b\u6587\u7ae0\u306b\u5909\u6570\u3092\u5165\u308c\u308b\u3053\u3068\u304c\u3067\u304d\u3001\u4eca\u56de\u306e\u4f8b\u3067\u306finput\u3068\u3044\u3046\u5909\u6570\u3092\u5165\u308c\u3066\u3044\u307e\u3059\u3002input\u306f\u5165\u529b\u3057\u305f\u5185\u5bb9\u304c\u5165\u308b\u3042\u3089\u304b\u3058\u3081\u5b9a\u7fa9\u3055\u308c\u305f\u5909\u6570\u3067\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u30e6\u30fc\u30b6\u304c\u5165\u529b\u3057\u305f\u6587\u7ae0\u3092\u30d7\u30ed\u30f3\u30d7\u30c8\u306b\u53d6\u308a\u8fbc\u307f\u307e\u3059\u3002\n\n<h2>\u7c21\u5358\u306a\u51fa\u529b\u4f8b<\/h2>\n\u7c21\u5358\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5165\u529b\u3092\u5165\u308c\u3066\u307f\u307e\u3057\u305f\u3002\r\n<div class=\"hcb_wrap\">\r\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>result = llm_chain.run(\"\u304a\u3059\u3059\u3081\u306e\u30e9\u30f3\u30c1\u30e1\u30cb\u30e5\u30fc\u306f?\")<\/code><\/pre>\r\n<\/div>\r\n\u305d\u308c\u306b\u5bfe\u3059\u308b\u51fa\u529b\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002\r\n\r\n\u30e9\u30f3\u30c1\u30e1\u30cb\u30e5\u30fc\u306e\u304a\u3059\u3059\u3081\u306f\u6b21\u306e\u3068\u304a\u308a\u3067\u3059\u3002\r\n\r\n&#8211; \u548c\u98df\u306e\u30e9\u30f3\u30c1\u30bb\u30c3\u30c8\r\n&#8211; \u30ab\u30ec\u30fc\u3068\u30b5\u30e9\u30c0\u306e\u30bb\u30c3\u30c8\r\n&#8211; \u30cf\u30f3\u30d0\u30fc\u30b0\u3068\u30b5\u30e9\u30c0\u306e\u30bb\u30c3\u30c8\r\n&#8211; \u30d1\u30b9\u30bf\u3068\u30b5\u30e9\u30c0\u306e\u30bb\u30c3\u30c8\r\n&#8211; \u5929\u3077\u3089\u76db\u308a\u5408\u308f\u305b\u30bb\u30c3\u30c8\r\n\r\n\u548c\u98df\u306e\u30e9\u30f3\u30c1\u30bb\u30c3\u30c8\u306f\u3001\u304a\u7c73\u3001\u5473\u564c\u6c41\u3001\u304a\u65b0\u9999\u3001\u6f2c\u7269\u306a\u3069\u65e5\u672c\u98df\u306e\u5b9a\u756a\u304c\u63c3\u3063\u3066\u3044\u3066\u6e80\u8db3\u3067\u304d\u307e\u3059\u3002\u30ab\u30ec\u30fc\u306f\u30b3\u30af\u3068\u6df1\u307f\u304c\u3042\u308a\u3001\u30b5\u30e9\u30c0\u3068\u4e00\u7dd2\u306b\u30dc\u30ea\u30e5\u30fc\u30e0\u611f\u3082\u3042\u308a\u307e\u3059\u3002\u30cf\u30f3\u30d0\u30fc\u30b0\u306f\u30b8\u30e5\u30fc\u30b7\u30fc\u306a\u8089\u306e\u65e8\u5473\u304c\u697d\u3057\u3081\u3066\u30aa\u30b9\u30b9\u30e1\u3067\u3059\u3002\u30d1\u30b9\u30bf\u306f\u8efd\u3081\u3067\u3042\u3063\u3055\u308a\u3057\u3066\u3044\u3066\u3001\u30b5\u30e9\u30c0\u3068\u5408\u308f\u305b\u308b\u3068\u30d0\u30e9\u30f3\u30b9\u304c\u826f\u3044\u3067\u3059\u306d\u3002\u5929\u3077\u3089\u76db\u308a\u5408\u308f\u305b\u306f\u63da\u3052\u305f\u3066\u304c\u5473\u308f\u3048\u3066\u30af\u30bb\u306b\u306a\u308b\u4e00\u54c1\u3067\u3059\u3002\r\n\r\n\u3054\u4e88\u7b97\u3084\u98df\u3079\u305f\u3044\u6599\u7406\u306e\u7a2e\u985e\u306b\u5408\u308f\u305b\u3066\u3001\u4e0a\u8a18\u306e\u4e2d\u304b\u3089\u304a\u9078\u3073\u3044\u305f\u3060\u3051\u308c\u3070\u3068\u601d\u3044\u307e\u3059\u3002\r\n\r\n\u7d9a\u3051\u3066\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5165\u529b\u3059\u308b\u3068\r\n<div class=\"hcb_wrap\">\r\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>result = llm_chain.run(\"\u304a\u8089\u6599\u7406\u306e\u304a\u3059\u3059\u3081\u306f\u3042\u308b\uff1f\")<\/code><\/pre>\r\n<\/div>\r\n\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u51fa\u529b\u304c\u5f97\u3089\u308c\u307e\u3059\u3002\r\n\r\n\u304a\u8089\u6599\u7406\u304c\u304a\u3059\u3059\u3081\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u306d\u3002\u30e9\u30f3\u30c1\u6642\u306e\u304a\u8089\u30e1\u30cb\u30e5\u30fc\u3068\u3057\u3066\u306f\u4ee5\u4e0b\u304c\u304a\u3059\u3059\u3081\u3067\u3059\u3002\r\n\r\n&#8211; \u30cf\u30f3\u30d0\u30fc\u30b0\u30d7\u30ec\u30fc\u30c8\r\n&#8211; \u5510\u63da\u3052\u3068\u30cf\u30f3\u30d0\u30fc\u30b0\u306e\u30bb\u30c3\u30c8\r\n&#8211; \u751f\u59dc\u713c\u304d\u3068\u30ed\u30fc\u30b9\u30c8\u30d3\u30fc\u30d5\u306e\u76db\u308a\u5408\u308f\u305b\r\n&#8211; \u716e\u8fbc\u307f\u30cf\u30f3\u30d0\u30fc\u30b0\u4e3c\r\n&#8211; \u30b9\u30c6\u30fc\u30ad\u30e9\u30f3\u30c1\r\n\r\n\u30cf\u30f3\u30d0\u30fc\u30b0\u306f\u30b8\u30e5\u30fc\u30b7\u30fc\u306a\u8089\u306e\u65e8\u5473\u304c\u5473\u308f\u3048\u307e\u3059\u3002\u5510\u63da\u3052\u3084\u751f\u59dc\u713c\u304d\u3068\u4e00\u7dd2\u306b\u76db\u308a\u5408\u308f\u305b\u308b\u3068\u30dc\u30ea\u30e5\u30fc\u30e0\u611f\u3082\u3042\u308a\u597d\u8a55\u3067\u3059\u3002\u716e\u8fbc\u307f\u30cf\u30f3\u30d0\u30fc\u30b0\u306f\u5473\u304c\u67d3\u307f\u8fbc\u3093\u3067\u3044\u3066\u98df\u3079\u5fdc\u3048\u629c\u7fa4\u3002\u30b9\u30c6\u30fc\u30ad\u306f\u9ad8\u7d1a\u611f\u304c\u3042\u308a\u3001\u30e9\u30f3\u30c1\u306b\u306f\u3061\u3087\u3046\u3069\u3044\u3044\u4e00\u54c1\u304b\u3068\u601d\u3044\u307e\u3059\u3002\r\n\r\n\u3054\u4e88\u7b97\u3084\u30dc\u30ea\u30e5\u30fc\u30e0\u611f\u306a\u3069\u306b\u5408\u308f\u305b\u3066\u3001\u3053\u306e\u4e2d\u304b\u3089\u304a\u9078\u3073\u3044\u305f\u3060\u3051\u308c\u3070\u5e78\u3044\u3067\u3059\u3002\u30e9\u30f3\u30c1\u30bf\u30a4\u30e0\u3092\u304a\u8089\u6599\u7406\u3067\u6e80\u55ab\u3057\u3066\u304f\u3060\u3055\u3044\u3002\r\n\r\n\u3053\u306e\u3088\u3046\u306b\u3001\u30e9\u30f3\u30c1\u30e1\u30cb\u30e5\u30fc\u3067\u3042\u308b\u3068\u3044\u3046\u8a18\u61b6\u3092\u5f15\u304d\u7d99\u3044\u3067\u3044\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3057\u305f\u3002\n\n<h2>\u6700\u5f8c\u306b<\/h2>\n\u4eca\u56de\u306fAWS\u306eBedrock\u3068LangChain\u3092\u4f7f\u3063\u3066Claude2\u3092\u7c21\u5358\u306b\u89e6\u3063\u3066\u307f\u307e\u3057\u305f\u3002AWS\u306eBedrock\u3092\u4f7f\u3046\u3068\u4ed6\u306b\u3082\u69d8\u3005\u306a\u57fa\u76e4\u30e2\u30c7\u30eb\u304c\u89e6\u308c\u308b\u306e\u3067\u8a66\u3057\u3066\u307f\u308b\u3068\u9762\u767d\u3044\u3067\u3059\u3002","protected":false},"excerpt":{"rendered":"<p>AWS Bedrock\u3092\u4f7f\u3063\u3066Claude2\u3092\u89e6\u3063\u3066\u307f\u305f\u306e\u3067\u3001AWS Bedrock\u306e\u4f7f\u3044\u65b9\u304b\u3089\u3054\u8aac\u660e\u3057\u307e\u3059\u3002 \u306f\u3058\u3081\u306b \u4eca\u56de\u306fAnthropic\u793e\u306e\u57fa\u76e4\u30e2\u30c7\u30ebClaude2\u3092AWS\u306eBedrock\u3092\u4f7f\u3063\u3066\u4f7f\u7528\u3057\u3066\u307f\u305f\u306e [&hellip;]<\/p>\n","protected":false},"author":26,"featured_media":4175,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"content-type":"","swell_btn_cv_data":"","footnotes":"","_wp_rev_ctl_limit":""},"categories":[1249],"tags":[96,201,35],"class_list":["post-4168","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-knowledge","tag-ai","tag-aws","tag-35"],"_links":{"self":[{"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/posts\/4168","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/users\/26"}],"replies":[{"embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/comments?post=4168"}],"version-history":[{"count":0,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/posts\/4168\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/media\/4175"}],"wp:attachment":[{"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/media?parent=4168"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/categories?post=4168"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/tags?post=4168"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}