| # β‘ Groq Chatbot β Streamlit App |
|
|
| A fast, free AI chatbot powered by [Groq](https://console.groq.com) and deployed with [Streamlit](https://streamlit.io). |
|
|
| ## Features |
| - π Free Groq API (no credit card) |
| - β‘ Blazing fast LLaMA / Mixtral inference |
| - π 5 built-in personas + custom system prompt |
| - π Switch models mid-conversation |
| - πΎ Export conversation as JSON |
| - π Dark theme UI |
|
|
| --- |
|
|
| ## Run Locally |
|
|
| ```bash |
| # 1. Clone |
| git clone https://github.com/YOUR_USERNAME/groq-chatbot.git |
| cd groq-chatbot |
| |
| # 2. Install |
| pip install -r requirements.txt |
| |
| # 3. Set API key (get free at console.groq.com) |
| export GROQ_API_KEY="gsk_..." |
| |
| # 4. Run |
| streamlit run app.py |
| ``` |
| App opens at **http://localhost:8501** |
|
|
| --- |
|
|
| ## Deploy to Streamlit Cloud (Free) |
|
|
| 1. Push this repo to GitHub |
| 2. Go to [share.streamlit.io](https://share.streamlit.io) β **New app** |
| 3. Select your repo and set **Main file path** to `app.py` |
| 4. Click **Advanced settings β Secrets** and add: |
| ```toml |
| GROQ_API_KEY = "gsk_your_key_here" |
| ``` |
| 5. Click **Deploy** β live URL in ~2 minutes β
|
|
|
| --- |
|
|
| ## File Structure |
|
|
| ``` |
| groq-chatbot/ |
| βββ app.py β Streamlit UI |
| βββ chatbot.py β Groq API logic |
| βββ requirements.txt β Dependencies |
| βββ .streamlit/ |
| β βββ config.toml β Theme settings |
| β βββ secrets.toml β API key (local only, gitignored) |
| βββ .gitignore |
| βββ README.md |
| ``` |
|
|
| --- |
|
|
| ## Customise |
|
|
| **Add a new persona** β in `app.py`, add to the `personas` dict: |
| ```python |
| "π§ββοΈ Doctor": "You are a medical assistant. Always recommend consulting a real doctor." |
| ``` |
|
|
| **Change default model** β in `chatbot.py`: |
| ```python |
| DEFAULT_MODEL = "llama-3.1-8b-instant" # fastest |
| ``` |
|
|
| **Longer memory** β in `chatbot.py`: |
| ```python |
| MAX_HISTORY_TURNS = 40 |
| ``` |
|
|