This project requires three servers to be running:
- Create and activate a virtual environment:
python3 -m venv env
source env/bin/activate- Install dependencies:
pip install -r requirements.txt- Start the vector database server:
python vector_store.py- Start the main server:
source env/bin/activate
python app.py- Create and activate a virtual environment:
cd logging_server
python3 -m venv log_env
source log_env/bin/activate- Install dependencies:
pip install -r requirements.txt- Start the logging server:
python server.py- Access the logging dashboard at: http://localhost:7000
- Vector Database Server: Port 8001
- Main Application Server: Port 5000
- Logging Server: Port 7000
To send logs from your Python code, use the requests library:
import requests
import json
def send_log(message, level="INFO", component=None, question_id=None, track=None):
log_data = {
"message": message,
"level": level, # "INFO", "WARNING", or "ERROR"
"component": component,
"question_id": question_id,
"track": track
}
try:
response = requests.post(
"http://localhost:7000/log",
json=log_data
)
return response.json()
except Exception as e:
print(f"Failed to send log: {str(e)}")
# Examples:
# Basic log
send_log("Processing started")
# Log with component
send_log("Cache miss", component="vector_store")
# Log with question tracking
send_log("Generating answer", question_id="Q123", component="answer_generator")
# Log with track
send_log("Track completed", track="preprocessing", level="INFO")
# Error log
send_log("Database connection failed", level="ERROR", component="db_client")The logs will be automatically grouped in the dashboard based on:
- Question ID (if provided)
- Track (if provided)
- Component (if provided)
- System logs (default)
server_manager.py handles 1 fast indexing server and 2 slow indexing servers. The script is supposed to be kept running alongside the aforementioned 3 servers.
Script has variables related to paths of data directories and cache directories of the 3 servers it manages. It loads values of these variables from config.py. Set the appropriate directory paths for all the servers in config.py for the server manager script to work properly.
python3 server_manager.py
Preferably run this script in a detached terminal session.