- Newest
- Most votes
- Most comments
Hey! Thanks for your question. This case looks like it can be solved with creating a "role" for your bot, as well as ensuring it has chat memory. The "role" your bot will play can be contained in the prompt similar to your example outlined above. Whereas the "chat memory" can be created with the Langchain library.
I would highly suggest you check out this notebook within our Bedrock workshop. It uses AI21 labs + Langchain to created a chatbot: https://github.com/aws-samples/amazon-bedrock-workshop/blob/main/04_Chatbot/00_Chatbot_AI21.ipynb
In particular I would look at the section called "Chatbot with Persona" for a code sample similar to your use case.
Specifically the code I will outline below:
'''
memory = ConversationBufferMemory()
memory.chat_memory.add_user_message("Context:You will be acting as a career coach. Your goal is to give career advice to users")
memory.chat_memory.add_ai_message("I am career coach and give career advice") ai21_llm = Bedrock(model_id="ai21.j2-ultra-v1",client=boto3_bedrock)
conversation = ConversationChain(
llm=ai21_llm, verbose=True, memory=memory
)
print_ww(conversation.predict(input="What are the career options in AI?")
'''
We can look at the line
"memory.chat_memory.add_user_message("Context:You will be acting as a career coach. Your goal is to give career advice to users")"
Here is where you can set your bot's name to "Robert" and outline how it should behave accordingly.
Please let me know if this solution works I will be more than happy to continue helping.
-Moh
Relevant content
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 3 years ago