-
Notifications
You must be signed in to change notification settings - Fork 337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add token usage to Bedrock Claude + Migrated chain for this model #564
Conversation
c7c605e
to
f7b01b4
Compare
With the older ConversationRetrievalChain, I limited how much history I would pass into a model. In my organization, we are seeing chat history messages grow across a variety of topics and it can cause inaccurate rephrasing of questions. I subclassed ConversationBufferMemory to give a rolling window of conversation history that is a smaller subset of the entire history. eg:
I want to do something similar with RunnableWithMessageHistory but I'm still getting up to speed on this new API. Do you think that limiting the message history to a smaller slice of data is an important feature? |
The memory used by Line 48 in 9de3e55
To implement it I would just add a max messages returned parameter: aws-genai-llm-chatbot/lib/model-interfaces/langchain/functions/request-handler/adapters/base/base.py Line 111 in 9de3e55
This would make this independent of the chain.
|
Issue #, if available:
#502 #495 #230
Description of changes:
To add usage tracking to bedrock models, I migrated the langchain chain for the claude model (ConversationChain is deprecated)
Instead it uses RunnableWithMessageHistory with ChatBedrockConverse that relied on the Bedrock Converse API that is consistent across models and provide the usage in the response.
Changes
npm run vet-all
to quickly verify formatting and testsTesting
Future Change
Note: This change is modifying the prompts to match the new Langchain patterns. For example:
Before
After
Image with metdata usage
Dashboard
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.