chain.predict(input="こんにちは。") > Entering new ConversationChain chain... Prompt after formatting: The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know. Current conversation: Human: こんにちは。 AI: > Finished chain. 'こんにちは!元気ですか?どのようにお手伝いできますか?' 6
chain.predict(input="今日は晴れです。どのようなタスクができますか?") > Entering new ConversationChain chain... Prompt after formatting: The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know. Current conversation: Human: こんにちは。 AI: こんにちは!元気ですか?どのようにお手伝いできますか? Human: 今日は晴れです。どのようなタスクができますか? AI: > Finished chain. '私はさまざまなタスクをこなすことができます。例えば、日常生活のアドバイスや情報の提供、予定の管理、翻訳、ニュースの読み 上げ、天気予報の提供などができます。どのようなタスクが必要ですか?' チャット履歴も覚えてくれてますね 7
chain.predict(input="こんにちは。") > Entering new ConversationChain chain... Prompt after formatting: The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know. Current conversation: Human: こんにちは。 AI: /home/ubuntu/workspace/2310-line-slack-bedrock/.venv/lib/python3.10/site- packages/langchain/llms/bedrock.py:50: UserWarning: Error: Prompt must alternate between ' Human:' and ' Assistant:'. Received 10
Human: The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know. Current conversation: Human: こんにちは。 AI: Assistant: warnings.warn(ALTERNATION_ERROR + f" Received {input_text}") > Finished chain. ' こんにちは。はじめまして。私は人工知能のアシスタントです。質問があればしっかり答えられるようにベストを尽くしますが、知 識の範囲は限られています。よろしくお願いします。' 回答は返ってきましたが、Warningが出てます。。 11
ところで今のプロンプトは? chain.prompt PromptTemplate( input_variables=['history', 'input'], template='The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.\n\nCurrent conversation:\n{history}\nHuman: {input}\nAI:') なるほど。 17
from langchain.chains import ConversationChain from langchain.chat_models import BedrockChat from langchain.memory import ConversationBufferMemory from langchain.prompts import PromptTemplate prompt_template = PromptTemplate( input_variables=['history', 'input'], template='''The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know. Current conversation:
chain.predict(input="こんにちは。") > Entering new ConversationChain chain... Prompt after formatting: The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know. Current conversation:
chain.predict(input="今日は晴れです。どのようなタスクができますか?") > Entering new ConversationChain chain... Prompt after formatting: The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know. Current conversation:
bedrock.py にまとめる from langchain.chains import ConversationChain from langchain.chat_models import BedrockChat from langchain.memory import ConversationBufferWindowMemory from langchain.memory.chat_message_histories import DynamoDBChatMessageHistory from langchain.prompts import PromptTemplate prompt_template = PromptTemplate( input_variables=['history', 'input'], template='''The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know. Current conversation:
# Lambdaのエントリーポイント def lambda_handler(event, context): # get X-Line-Signature header value signature = event['headers']['x-line-signature'] # get request body as text body = event['body'] line_handler.handle(body,signature) return { 'statusCode': 200, 'body': 'OK' } 41