Logo Lanfrica

Nils-23/SWAHILI_BOT

Domain:

natural language processing

Record type:

software
Creator:
Nil
Host:
This is a bot I am planning to teach some swahili slangs that are stored locally then fetched and translated by the agent each time a query is made using Llama3 hosted locally in my case # Swahili Slang Bot A chatbot that teaches and translates Swahili slang. Slang terms and their meanings are stored locally and looked up by an LLM agent (Llama3, run locally) each time a query is made. ## How it works 1. Slang terms and definitions live in `slang.json`. 2. `translator.py` handles lookup/translation logic. 3. `llm.py` talks to the language model — either the **Groq API** (hosted, no install) or a **local Ollama** model. 4. `main.py` runs the bot in the terminal; `web.py` runs the same bot with a browser UI. ## Two ways to run the model - **Groq API (recommended, no install):** provide a Groq API key and the bot calls Groq's hosted Llama model. Anyone can use it without installing an LLM. - **Local Ollama (offline):** if no API key is set, the bot falls back to a locally installed Ollama model — the original setup. ## Tech Stack - Python (standard library only — no extra installs required for Groq) - Groq API (hosted Llama) and/or Ollama (local Llama) ## Getting Started Run it in the browser (recommended): \`\`\`bash python web.py \`\`\` Then open localhost (it also opens automatically) and paste your Groq API key into the field at the top. Get a key at console.groq.com. Prefer to set the key server-side (so users don't need their own)? Export it before starting: \`\`\`bash export GROQ_API_KEY=gsk_your_key_here python web.py \`\`\` Or run it in the terminal: \`\`\`bash export GROQ_API_KEY=gsk_your_key_here # optional; omit to use local Ollama python main.py \`\`\` ### Optional: local Ollama fallback If no Groq key is available, install Ollama, pull the model, and install the client: \`\`\`bash ollama pull llama3.2 pip install ollama \`\`\` ### Configuration (environment variables) - `GROQ_API_KEY` — your Groq API key (enables the hosted route). - `GROQ_MODEL` — Groq model id (default `llama-3.1-8b-instant`). - `OLLAMA_MODEL` — local model name (default `llama3.2`). ## Why Swahili slang shifts fast and isn't well r …

Languages