This repository contains a simple yet powerful chatbot built with Streamlit, OpenAI, and LangChain. The chatbot maintains conversational memory, meaning it can reference past exchanges in its responses.
The chatbot is a demonstration of integrating OpenAI's GPT model, the LangChain library, and Streamlit for creating interactive web applications. The bot's conversational memory allows it to maintain context during the chat session, leading to a more coherent and engaging user experience. Importantly, this feature-rich chatbot application is implemented in less than 40 lines of code (excluding whitespace and comments)!
- Streamlit: A powerful, fast Python framework used to create the web interface for the chatbot.
- OpenAI's GPT: A state-of-the-art language processing AI model that generates the chatbot's responses.
- LangChain: A wrapper library for the ChatGPT model that helps manage conversation history and structure the model's responses.
- Python 3.6 or higher
- Streamlit
- LangChain
- OpenAI API key
- Clone this repository.
- Install the necessary Python packages using the command
pip install -r requirements.txt
. - Set the environment variable for your OpenAI API key.
- Run the Streamlit app using the command
streamlit run streamlit_app.py
.
The chatbot starts with a system message that sets the tone for the conversation. It then alternates between receiving user inputs and generating AI responses. The conversation history is stored and used as context for generating future responses, allowing the chatbot to maintain conversational continuity.
Contributions, issues, and feature requests are welcome. Feel free to check the Issues page if you want to contribute.
This project is licensed under the terms of the MIT license.