A modern conversational chatbot built with Streamlit and LangChain, powered by Together AI's LLM models.
This repository includes two chatbot applications:
- app.py - Standard conversational chatbot
- hinglish_bot.py - Hinglish chatbot with customizable system messages
- 💬 Interactive chat interface with message history
- 🧠 Powered by Meta's Llama 4 Maverick model via Together AI
- 🔄 Conversation memory using LangChain's latest patterns
- 🎨 Clean and intuitive UI built with Streamlit
- 🔒 Secure API key management with Streamlit secrets
- 🇮🇳 NEW: Hinglish bot with customizable personality
- ⚙️ NEW: Editable system messages and preset templates
- Frontend: Streamlit
- LLM Framework: LangChain (latest version)
- LLM Provider: Together AI
- Model: meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8
- Python: 3.8+
- Python 3.8 or higher
- Together AI API key (Get one here)
-
Clone the repository (or navigate to the project directory):
cd chatbot_Course -
Install dependencies:
pip install -r requirements.txt
-
Set up your API key:
- Open
.streamlit/secrets.toml - Replace
your-together-api-key-herewith your actual Together AI API key:TOGETHER_API_KEY = "your-actual-api-key-here"
- Open
-
Run the application:
streamlit run app.py
-
Access the chatbot:
- The app will automatically open in your browser
- Default URL:
http://localhost:8501
-
Start chatting:
- Type your message in the chat input at the bottom
- Press Enter to send
- The AI will respond with context from your conversation history
-
Run the Hinglish bot:
streamlit run hinglish_bot.py
-
Customize the bot (Optional):
- Open
hinglish_bot.pyin a text editor - Edit the
system_messagevariable (line 17) - Save and restart the bot
- Open
-
Chat in Hinglish:
- Type in Hindi, English, or Hinglish
- The bot will respond in natural Hinglish
- Example: "Bhai, machine learning kaise seekhun?"
chatbot_Course/
├── app.py # Standard conversational chatbot
├── hinglish_bot.py # Hinglish chatbot (customizable)
├── requirements.txt # Python dependencies
├── README.md # Main documentation
├── .streamlit/
│ └── secrets.toml # API keys (not committed to git)
└── .gitignore # Git ignore file
To use a different model, modify the llm initialization in app.py:
llm = ChatOpenAI(
model="your-model-name", # Change this
api_key=st.secrets["TOGETHER_API_KEY"],
base_url="https://api.together.xyz/v1",
temperature=0.7 # Adjust temperature (0.0 - 1.0)
)- Update
requirements.txtto include OpenAI support - Add your OpenAI API key to
.streamlit/secrets.toml:OPENAI_API_KEY = "your-openai-api-key"
- Update the LLM initialization:
llm = ChatOpenAI( model="gpt-4o-mini", api_key=st.secrets["OPENAI_API_KEY"] )
The chatbot uses InMemoryChatMessageHistory to maintain conversation context. To limit the number of messages remembered, you can implement a custom message history with a window size.
The Hinglish bot allows you to customize the AI's personality by editing the code:
- Open
hinglish_bot.pyin any text editor - Find the
system_messagevariable (around line 17) - Replace the text with your custom message
- Save and restart the bot
Example custom system message:
system_message = """You are a coding tutor who teaches in Hinglish.
Explain programming concepts using simple Hindi-English mix.
Use examples that Indian students can relate to.
Be encouraging and patient.
"""This project uses the latest LangChain patterns:
- ✅
RunnableWithMessageHistoryfor conversation management - ✅
ChatPromptTemplatewithMessagesPlaceholderfor structured prompts - ✅ LCEL (LangChain Expression Language) with the
|operator - ✅ Proper session management with configurable session IDs
All deprecated imports and patterns have been removed:
- ❌ No
ConversationChain - ❌ No
ConversationBufferWindowMemory - ✅ Uses modern
langchain_corecomponents
.streamlit/secrets.toml file to version control. It's already included in .gitignore to prevent accidental exposure of API keys.
If you see an error about the model not being available:
- Check that your Together AI API key is valid
- Verify the model name is correct and available
- Some models require a dedicated endpoint - check the Together AI dashboard
If you encounter import errors:
pip install --upgrade langchain langchain-openai streamlitlangchain- LLM frameworklangchain-openai- OpenAI-compatible LLM integrationstreamlit- Web interfacestreamlit-chat- Chat UI components
Feel free to submit issues, fork the repository, and create pull requests for any improvements.
This project is open source and available under the MIT License.
- Built with Streamlit
- Powered by LangChain
- LLM by Together AI
- Tutorial by Build Fast with AI
For questions or issues:
- Check the LangChain documentation
- Review Streamlit documentation
- Visit Together AI documentation
Happy Chatting! 🚀