A knowledge base application for EMQX that allows users to ask questions and get answers based on the knowledge base. It also includes a log analysis feature for EMQX logs.
- Ask questions and get answers based on the knowledge base
- Upload files to provide additional context for questions
- Analyze EMQX logs to identify issues and get troubleshooting recommendations
- Slack integration for asking questions and getting answers
- Backend: FastAPI, SQLAlchemy, LlamaIndex
- Frontend: Vue.js, Tailwind CSS
- Database: SQLite (default), PostgreSQL (optional)
- LLM Support: OpenAI, Anthropic, Cohere, Gemini, HuggingFace (via LlamaIndex)
- Clone the repository
- Install uv (if not already installed):
curl -LsSf https://astral.sh/uv/install.sh | sh
- Set up environment variables:
cp .env.example .env
- Edit the
.env
file to set your LLM API key and other configuration options - Run the application:
uv run main.py
LLM_PROVIDER
: The LLM provider to use (default: openai, options: openai, anthropic, cohere, gemini, huggingface)LLM_API_KEY
: Your LLM API key (or useOPENAI_API_KEY
for backward compatibility)LLM_MODEL
: The model to use (depends on the provider, default: gpt-4o)LLM_TEMPERATURE
: The temperature to use for generation (default: 0.7)EMBEDDING_MODEL
: The embedding model to use (default: text-embedding-3-small)EMBEDDING_DIMENSION
: The dimension of the embeddings (default: 1536)
DATABASE_URL
: The database URL (default: sqlite:///knowledge_base.db)
SLACK_BOT_TOKEN
: Your Slack bot token (optional)SLACK_APP_TOKEN
: Your Slack app token (optional)SLACK_SIGNING_SECRET
: Your Slack signing secret (optional)SLACK_TEAM_ID
: Your Slack team ID (optional)
EMQX_BASE_URL
: The base URL for the EMQX API (default: http://localhost:18083/api/v5)EMQX_USR_NAME
: The EMQX username (default: admin)EMQX_PWD
: The EMQX password (default: public)
ENABLE_SLACK
: Whether to enable Slack integration (default: false)ENABLE_LOG_ANALYSIS
: Whether to enable log analysis (default: true)
POST /api/ask
: Ask a question to the knowledge basePOST /api/analyze-log
: Analyze an EMQX logGET /api/health
: Health check endpoint
The web UI is available at http://localhost:8000 and includes:
- A page for asking questions and getting answers
- A page for analyzing EMQX logs
The log analysis feature uses LlamaIndex to analyze EMQX logs and provide troubleshooting recommendations. It can:
- Extract information from EMQX logs
- Identify issues and their potential causes
- Provide step-by-step troubleshooting recommendations
To set up the development environment:
- Install frontend dependencies:
cd web npm install
- Run the backend:
uv run main.py
- Run the frontend:
cd web npm run dev
This project is licensed under the MIT License - see the LICENSE file for details.