A streaming AI assistant application integrating Chainlit and RAGFlow with Redis message queuing.
- Email: Please read:[https://alidocs.dingtalk.com/i/nodes/1DKw2zgV2PAo2rA7uLr72orN8B5r9YAn?utm_scene=team_space]
This project provides an interactive AI assistant with streaming responses, document references, and human agent escalation capabilities. The application uses Chainlit for the frontend interface and RAGFlow for backend knowledge retrieval and response generation.
- Real-time streaming responses
- Document reference integration
- Human agent escalation
- Redis-based message queuing
- OAuth authentication
- Structured logging
- Environment-based configuration
- Python 3.12+
- Redis server
- RAGFlow API access
- Rocket.Chat server (for human escalation)
-
Clone this repository
git clone https://github.com/iamtornado/AI-Assistant.git
-
Create and activate a virtual environment: Linux:
python -m venv .venv
Windows:
python -m venv .venv
Activate the virtual environment: Linux:
source .venv/bin/activate
Windows:
.venv\Scripts\activate
-
Install dependencies:
pip install -U fastapi uvicorn chainlit redis rocketchat_API
-
Create a
.env
file with required environment variables (see Configuration section)
Required environment variables:
RAGFLOW_API_KEY
: API key for RAGFlow accessRAGFLOW_BASE_URL
: Base URL for RAGFlow APIRAGFLOW_ASSISTANT_NAME
: Name of the RAGFlow assistantREDIS_HOST
: Redis server hostnameREDIS_PORT
: Redis server portREDIS_PASSWORD
: Redis authentication passwordROCKETCHAT_SERVER_URL
: URL for Rocket.Chat serverROCKETCHAT_WEBHOOK_TOKEN
: Token for Rocket.Chat webhook authenticationLDAP_PASSWORD
: Password for LDAP authenticationWEEKDAY_USERS
: Comma-separated list of Rocket.Chat users for human escalationOAUTH_KEYCLOAK_BASE_URL
: Base URL for Keycloak OAuth serverOAUTH_KEYCLOAK_REALM
: Keycloak realm nameOAUTH_KEYCLOAK_CLIENT_ID
: Keycloak client IDOAUTH_KEYCLOAK_CLIENT_SECRET
: Keycloak client secretOAUTH_KEYCLOAK_NAME
: Keycloak OAuth provider nameCHAINLIT_AUTH_SECRET
: Secret for Chainlit authenticationIT_ENVIRONMENT
: Environment type (dev or test)REDIS_DB_INDEX_DEV
: Redis database index for development environmentREDIS_DB_INDEX_TEST
: Redis database index for test environmentLOG_LEVEL
: Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)PROPAGATE_LOGS
: Whether to propagate logs to parent loggers (True/False)
Start the application with:
uvicorn webhook_server:app --host 0.0.0.0 --port 8000
chainlit_ragflow_streaming.py
: Main application entry pointragflow_client.py
: RAGFlow API clientmessage_queue.py
: Redis queue implementationlogger_config.py
: Logging configurationwebhook_server.py
: Webhook handling serverrequirements.txt
: Project dependencies
- Email: [[email protected]]
- GitHub: [https://github.com/iamtornado]
- website: [https://alidocs.dingtalk.com/i/nodes/Amq4vjg890AlRbA6Td9ZvlpDJ3kdP0wQ?utm_scene=team_space]
This project is licensed under the MIT License. For more information, please see the License
file included in this repository.