Slide 11
Slide 11 text
チャットモデル:ChatBedrock / ChatBedrockConverse
● Bedrockテキストモデルを
LangChain経由で呼び出すための
コンポーネント
● Invoke APIを呼び出す
ChatBedrockと、Converse APIを
呼び出すChatBedrockConverseが
存在する
● 今後Converse APIがChatBedrock
にも統合される予定との事
11
# Instantiation
from langchain_aws import ChatBedrock
llm = ChatBedrock(
model_id="anthropic.claude-3-sonnet-20240229-v1:0",
model_kwargs=dict(temperature=0),
# other params...
)
# Invocation
messages = [
(
"system",
"You are a helpful assistant that translates English to
French. Translate the user sentence.",
),
("human", "I love programming."),
]
ai_msg = llm.invoke(messages)
print(ai_msg.content)