Refactor user data handling and enhance chat functionality

- Removed deprecated user_info files and paths from configuration.
- Added user soil data integration in chat context to improve response accuracy.
- Updated build_rag_context and chat_rag_stream functions to include sensor_uuid for user-specific data retrieval.
- Enhanced load_sources function to load user data from the database.
- Implemented filtering in search_with_query and QdrantVectorStore to isolate user data based on sensor_uuid.
- Introduced Celery Beat schedule for periodic user data ingestion.
This commit is contained in:
2026-02-27 20:06:46 +03:30
parent 94355af62b
commit 2c42ebe01c
13 changed files with 246 additions and 89 deletions
-1
View File
@@ -26,4 +26,3 @@ llm:
tone_file: "config/tone.txt"
knowledge_base_path: "config/knowledge_base"
user_info_path: "config/user_info"
+8
View File
@@ -107,3 +107,11 @@ CELERY_BROKER_URL = os.environ.get("CELERY_BROKER_URL", "redis://localhost:6379/
CELERY_RESULT_BACKEND = os.environ.get("CELERY_RESULT_BACKEND", "redis://localhost:6379/0")
CELERY_ACCEPT_CONTENT = ["json"]
CELERY_TASK_SERIALIZER = "json"
# Celery Beat — embed دیتای کاربران هر ۶ ساعت
CELERY_BEAT_SCHEDULE = {
"rag-ingest-periodic": {
"task": "rag.tasks.rag_ingest_task",
"schedule": 6 * 60 * 60, # ۶ ساعت
},
}
-3
View File
@@ -1,3 +0,0 @@
# اطلاعات کاربران
فایل‌های `.txt` و `.md` این پوشه به‌عنوان اطلاعات هر کاربر embed و ذخیره می‌شوند.
-44
View File
@@ -1,44 +0,0 @@
{
"farm": {
"name": "مزرعه نمونه گلستان",
"location": {
"latitude": 36.2,
"longitude": 52.5
}
},
"soil_data": {
"0-5cm": {
"phh2o": 7.2,
"clay": 25,
"sand": 45,
"silt": 30,
"soc": 1.4,
"nitrogen": 0.12
},
"5-15cm": {
"phh2o": 7.4,
"clay": 28,
"sand": 42,
"silt": 30,
"soc": 1.1,
"nitrogen": 0.09
},
"15-30cm": {
"phh2o": 7.5,
"clay": 30,
"sand": 40,
"silt": 30,
"soc": 0.8,
"nitrogen": 0.07
}
},
"sensor_readings": {
"soil_moisture": 32,
"soil_temperature": 24.5,
"soil_ph": 7.1,
"electrical_conductivity": 2.1,
"nitrogen": 15,
"phosphorus": 8,
"potassium": 180
}
}