From reports the time spent per visitor per SL, article and page, let's recommend other articles to users (=visitors)
There is a minimal streamlit app (app.py) and fastapi server (server.py) that can be queried from a smartlink (see script.js that should be set as script in argo editor)
Some inconsistencies with durations => like 2 days
For articles, we have time spent per page that contain an article title. It means that if 3 articles have their titles on the same page, they will have same ratings. And if an article is on 7 pages, only the first page will be taken into account.
Between 0 and 5 rating is just a clamped ratio (per page)= nb_sec/6 (so above 30s =>5)
=> Sum of time per page capped at 30 min ? =>
This is a test to check what an article is and how we could detect it and maybe enhance the recommendations
It's really a first test. See extract.py
https://grfrecommendations-skrkcd5tqmykmjawehmyr6.streamlit.app/
python3.9 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
- app :
streamlit run app.py
-
example data : * https://nemato-data.fr/public/output.csv (full) * https://nemato-data.fr/public/small.csv (extract)
-
server: uvicorn server:app --reload
- for the demo, I used ngrok as a tunnel : then no https is needed, it's provided by ngrok
- 2 routes:
- /generate_test is there to build the model out of https://nemato-data.fr/public/output.csv. Needs to be called only once
- /recommendations/{visitor_id} to get recommations for this vistor
uvicorn server:app --reload
NOTE: for the demo, I used ngrok as a tunnel : then no https is needed, it's provided by ngrok. Same in case if you use CloudFlare in front of your server.
- create keys:
openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365
- create https server
uvicorn server:app --ssl-keyfile key.pem --ssl-certfile cert.pem --reload
Create grf_recommendation.service in /etc/systemd/system:
[Unit]
Description=GRF Recommendation
After=network.target
[Service]
WorkingDirectory=/argo/grf_recommendation
ExecStart=/home/admin/.local/bin/uvicorn server:app --reload
Type=simple
PIDFile=/var/run/grf_recommendation.pid
Restart=always
User=admin
Group=admin
[Install]
WantedBy=default.target
Enable and start service:
sudo systemctl daemon-reload
sudo systemctl enable grf_recommendation.service
sudo systemctl start grf_recommendation.service
sudo systemctl status grf_recommendation.service
See logs:
sudo journalctl -u grf_recommendation.service
I created an example :
- Editor : https://ui-dev.argoflow.io/home/projects/659579887e5bd900128038bd
- link and vistor Id:https://dev-org-argo.argoflow.io/test.sl?sl=ff8d9e38d19a6c65ae95123fb344a6da&q=174810-51961
If no visitor Id or not found, then Recommendation (top right) appears
Script is script.js to be inserted as script in editor