Welcome to the GamerMajlis Chatbot repository! This project is a mini-RAG-based chatbot system designed for the gaming platform GamerMajlis, aimed at enhancing user experience and answering platform-related questions efficiently.
GamerMajlis is a gaming platform that allows users to connect with other gamers, buy gaming gear, participate in events and tournaments, communicate seamlessly and access all gaming-related services in one place
The chatbot was designed to simplify user interactions and provide immediate answers to both static and dynamic questions.
Here’s a breakdown of the files and their purpose:
| File / Folder | Description |
|---|---|
chatbot.py |
Main chatbot script that initializes without the Gradio UI and connects the system. |
chatbot_gradio.py |
Chatbot script that with the Gradio UI. |
db_connection.py |
Database connection logic for dynamic queries. |
queries.py |
Maps intents to SQL queries for dynamic platform questions. |
static_intents.py |
Dictionary of static intents and their responses. |
system_prompt.txt |
LLM prompt that sets its role and rules, including “no fake data.” |
The system relies on a built-in LLM called meta-llama/llama-4-scout-17b-16e-instruct, which is responsible for understanding queries and generating responses.
The chatbot can handle three main types of user questions:
-
General Questions
- Not related to the platform.
- Directly answered by the LLM.
-
Dynamic Platform Questions
- Questions about events, tournaments, or products (dynamic data that changes).
- The chatbot first identifies an intent from the question.
- Each intent is mapped to a specific database query.
- The result is formatted and sent back to the LLM for a user-friendly response.
-
Static Platform Questions
- Questions that don’t change, e.g., “How do I change my password?”
- Handled via a predefined dictionary called
static_intents.py. - LLM provides natural responses based on these static intents.
- Intent Extraction – Each question generates an intent key to map queries securely.
- Dynamic Queries – Queries only run when needed, minimizing unnecessary database access.
- Static Intents – Common, unchanging questions are answered efficiently without querying the database.
- Safety Prompting – The LLM never generates fake data. If information is missing, it explicitly says so.
- Customizable UI – Built using Gradio, fully styled with CSS for a smooth user experience.
Note: The
.envfile contains sensitive keys and is ignored in Git.
Follow these steps to get the project running on your machine:
# Clone the repository
git clone https://github.com/GamerMajlis-platform/AI.git
cd AI- Create a
.envfile with the following structure:
GROQ_API_KEY=<your_groq_api_key>
DATABASE_NAME=<your_db_name>
DATABASE_USER=<your_db_user>
DATABASE_PASSWORD=<your_db_password>
-
Ensure your database matches the queries in
queries.py, or customize it. -
Create a Gradio API key if required.
-
Run the chatbot:
python chatbot.pyYour Gradio UI will launch locally, ready for testing.
- Dynamic Tables / Queries: Adjust
queries.pyto match your database structure. - Static Intents: Modify
static_intents.pyfor additional FAQs. - LLM Prompt: Update
system_prompt.txtto guide the chatbot behavior. - UI Customization: Update CSS in
chatbot.pyto adjust colors, sizes, or layout.
- Dynamic question → intent from queries → query → LLM formatting → response
- Static question → intent from ststic → query → LLM formatting → response
- Other question → LLM response