Welcome to your personal AI companion! This interactive chatbot, crafted with Streamlit, lets you dive into conversations with the powerful LLaMA 3 language model, supercharged by Groq's blazing-fast API. Get ready for a smooth, responsive, and customizable chat experience! 💬
- ⚡️ LLaMA 3 Integration: Experience lightning-fast responses from the LLaMA 3 model, thanks to Groq's cutting-edge inference engine. It's like having a super-speedy brain at your fingertips! 🧠💨
- 🎨 Customizable Themes: Express yourself! Choose from "Default" 🌟, "Professional" 👔, and "Fun" 🎉 themes to match your mood and personalize the chatbot's look and feel.
- 📝 System Prompt Presets: Need a coding buddy? A creative muse? A math whiz? Instantly switch between diverse system prompt presets (e.g., "General Assistant," "Code Assistant," "Creative Writer") or craft your very own custom persona! 🎭
- 📜 Chat History: Never lose your train of thought! Your entire conversation history is seamlessly preserved within your session. 📖
- 🔄 Reset Chat: Ready for a fresh start? A single click clears the slate, letting you embark on a brand new conversational journey. ✨
- ✨ Dynamic Styling: Watch your messages come to life! All chat bubbles are dynamically styled with delightful backgrounds and fonts based on your chosen theme, making every interaction a pleasure to read. 🌈
Follow these simple steps to bring your Groq Chatbot to life. It's quick, easy, and rewarding! 👇
Before we embark on this exciting adventure, make sure you have these essentials:
- Python 3.8+: Our chatbot loves a modern Python environment. 🐍
- Groq API Key: This is your golden ticket! 🎟️ You'll need an API key from Groq to unleash the power of LLaMA 3. Sign up and grab yours from the Groq website.
-
Clone the repository (or grab the code): If you've got the code as a file, just skip to the next step. If it's part of a Git repo, let's clone it first:
git clone <repository_url> cd <repository_directory>
-
Create a virtual environment (highly recommended for a clean setup!):
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install dependencies: Our app relies on
streamlitfor its beautiful UI andgroqfor connecting to the AI magic.pip install streamlit groq
-
Set your Groq API Key: The application expects a file named
groq_api.pywith achat_with_groqfunction. Inside this file, you'll securely store your Groq API key. For top-notch security, always use environment variables for your API keys! 🔒Create a file named
groq_api.pyin the same directory as your main app file (e.g.,app.py). Paste this content into it:import os from groq import Groq def chat_with_groq(messages): # Retrieve API key from environment variable for security client = Groq(api_key=os.environ.get("GROQ_API_KEY")) # You could also directly paste your key here for quick testing: "gsk_..." chat_completion = client.chat.completions.create( messages=messages, model="llama3-8b-8192", # Or another LLaMA 3 model you prefer! ) return chat_completion.choices[0].message.content
🚨 Important! Before launching the app, set your
GROQ_API_KEYenvironment variable:- 🐧 Linux/macOS:
export GROQ_API_KEY="your_super_secret_groq_api_key_here"
- 🖥️ Windows (Command Prompt):
set GROQ_API_KEY="your_super_secret_groq_api_key_here"
- ⚡️ Windows (PowerShell):
$env:GROQ_API_KEY="your_super_secret_groq_api_key_here"
Remember to replace
"your_super_secret_groq_api_key_here"with your actual API key. - 🐧 Linux/macOS:
-
Navigate to the directory where your main application file resides (e.g.,
app.py). -
Launch the Streamlit app:
streamlit run your_app_file_name.py
(Don't forget to replace
your_app_file_name.pywith the actual name of your Python file containing the Streamlit code!) -
Your web browser should magically pop open to the Streamlit application. If it's playing shy, just open your browser and head to
http://localhost:8501. 🌐
- 🗣️ Start Chatting: Type your brilliant thoughts into the "Say something..." input box at the bottom and hit Enter or click the send button.
- 🌈 Change Theme: Feeling colorful? Use the "Choose Theme" dropdown in the sidebar to effortlessly switch between "Default," "Professional," and "Fun" vibes.
- 🎯 Select Prompt Preset: Instantly transform your AI! Use the "Choose a prompt preset:" dropdown in the sidebar to load a pre-defined system prompt tailored for various tasks.
- ✍️ Custom System Prompt: Want to fine-tune your AI's personality? Adjust the "System prompt:" text area in the sidebar. Your changes take effect immediately!
- ♻️ Reset Chat: Need a clean slate? Click the "🔁 Reset Chat" button in the sidebar to clear the conversation history and begin a brand new dialogue.
Here's how your project files will look: ├── your_app_file_name.py # The heart of your Streamlit chatbot 💖 ├── groq_api.py # The brains of the operation, handling Groq API calls 🧠 └── README.md # You're reading it! Project guide and instructions 📝
Got ideas? Found a bug? We'd love your help! Feel free to fork this repository, propose improvements, or submit pull requests. Let's build something awesome together! 🚀
This project is open-source and available under the MIT License. Freedom to explore and innovate! 🔓