aws-samples / amazon-kendra-langchain-extensions

Samples to build Generative AI applications with LangChain and Amazon Kendra
https://aws.amazon.com/blogs/machine-learning/quickly-build-high-accuracy-generative-ai-applications-on-enterprise-data-using-amazon-kendra-langchain-and-large-language-models/
MIT No Attribution
158 stars 104 forks source link

Update kendra_chat_bedrock_claudev2.py #46

Closed jimburtoft closed 11 months ago

jimburtoft commented 11 months ago

*Issue #, if available:This also fixes issue #45

Description of changes: I put the chat history at the beginning of the prompt instead of in the middle.
The order of the history had to be changed because the Bedrock API expects to see alternating Human:/Assistant: lines for Claude. Without this change, the first query would work, but subsequent queries would generate an error from the Bedrock API:

ValueError: Error: Prompt must alternate between '

Human:' and '

Assistant:'.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

jacobtaunton commented 11 months ago

langchain version in requirements.txt file needed to be updated for this fix to work for me. Tested with langchain==0.0.306