This is an example showing you how to enable coherent conversation with OpenAI by the support of Langchain framework.
The key components we are using are as follows:
- ConversationChain
- ConversationBufferMemory
- ConversationSummaryMemory
- ConversationBufferWindowMemory
- ConversationSummaryBufferMemory
There are 3 Python notebooks included in this repository.
This is a simple example of ConversationBufferMemory usage.
This is a simple example of ConversationSummaryMemory usage.
In this notebook, we will run 10 queries with the 4 different types of memory components ConversationBufferMemory, ConversationSummaryMemory, ConversationBufferWindowMemory and ConversationSummaryBufferMemory respectively.
Token usage per conversation will be collected in these 4 executions and plotted so that we can have a better understanding on how tokens are consumed differently.
Hope it helps. Feel free to PR if you see any issue. Thanks.