Skip to content

kamalviewcode-spec/Project_5_AI_ChatBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

AI Chatbot

A simple, intelligent chatbot built with Streamlit and Groq's language models. This chatbot maintains conversation history and uses system instructions to define its behavior.

Features

  • 💬 Real-time Chat Interface - Built with Streamlit for an interactive experience
  • 🧠 Powered by Groq LLM - Uses the fast llama-3.3-70b-versatile model
  • 📝 Conversation History - Maintains chat history throughout the session
  • 🎯 Customizable System Instructions - Define the AI's role and behavior
  • ⚠️ Error Handling - Full call stack debugging for troubleshooting

Requirements

  • Python 3.8+
  • pip (Python package manager)

Installation

  1. Clone or download the project

    cd Project_1_AI_Chatbot
  2. Create a virtual environment (optional but recommended)

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Set up your Groq API Key

    • Get your API key from Groq Console
    • Create a .env file in the project root:
      GROQ_API_KEY=your_api_key_here
      

Usage

  1. Run the chatbot

    streamlit run Src/Chatbot.py
  2. Access the app

    • The app will automatically open in your browser at http://localhost:8501
    • If it doesn't open, manually navigate to that URL
  3. Interact with the chatbot

    • Type your questions in the chat input box
    • The chatbot will respond with AI-generated answers
    • Your conversation history is maintained throughout the session

Customization

Change the AI's Behavior

Edit the SYSTEM_INSTRUCTIONS variable in Src/Chatbot.py:

SYSTEM_INSTRUCTIONS = """You are a helpful and friendly AI assistant.
Your role is to:
- Answer questions accurately and helpfully
- Provide clear and concise explanations
...etc"""

Change the Model

Update the model_name parameter in the ChatGroq initialization:

llm = ChatGroq(
    temperature=0.7,
    model_name="llama-3.1-8b-instant",  # Use a different model
)

Available Groq Models:

  • llama-3.3-70b-versatile - Large, powerful model (default)
  • llama-3.1-8b-instant - Smaller, faster model
  • gpt-oss-120b - High-performance open-source model

Adjust Temperature

The temperature parameter controls AI creativity (0-1):

  • Lower (0.3) - More focused and deterministic
  • Higher (0.9) - More creative and varied
llm = ChatGroq(
    temperature=0.3,  # More focused responses
    model_name="llama-3.3-70b-versatile",
)

Project Structure

Project_1_AI_Chatbot/
├── Src/
│   └── Chatbot.py          # Main chatbot application
├── .env                    # Environment variables (API keys)
├── requirements.txt        # Python dependencies
└── README.md              # This file

Troubleshooting

"Model has been decommissioned" error

  • Update the model_name in Chatbot.py to a current Groq model
  • Check available models at Groq Models Docs

"GROQ_API_KEY not found" error

  • Ensure your .env file exists and contains GROQ_API_KEY=your_key_here
  • Restart the Streamlit app after creating/updating the .env file

Streamlit app won't open

  • The app runs on http://localhost:8501 by default
  • If port 8501 is in use, Streamlit will use the next available port
  • Check the terminal output for the correct URL

To stop the chatbot

  • Press Ctrl+C in the terminal where Streamlit is running

Debugging

The chatbot includes error handling with full call stack display:

  • Errors will appear with the message "❌ Error occurred"
  • The full Python traceback is shown below for debugging

Using VS Code Debugger

  1. Press F5 to start debugging
  2. Select "Python" as the debugger
  3. Set breakpoints by clicking on line numbers
  4. View the call stack in the left sidebar under "Call Stack"

Dependencies

  • streamlit - Web UI framework
  • langchain-groq - Groq LLM integration
  • langchain-core - LangChain core utilities
  • python-dotenv - Environment variable management

See requirements.txt for exact versions.

License

This project is created for learning and testing purposes.

Resources


Questions or Issues? Check the Troubleshooting section or review the code comments in Src/Chatbot.py for more details.

About

AI chatbot powered by Groq (Llama 3.3 70B) + LangChain + Streamlit with personality switching, conversation history, and a modern dark UI.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages