Преглед изворни кода

udpate to include post filter pipeline

Dr-Swopt пре 2 недеља
родитељ
комит
6dedcf25ee
1 измењених фајлова са 20 додато и 7 уклоњено
  1. 20 7
      AgentQueryPlan.json

+ 20 - 7
AgentQueryPlan.json

@@ -1,25 +1,38 @@
 {
   "description": "MongoDB Query Planner for FFB Production",
-  "instructions": "You are an intelligent MongoDB query planner for FFBProduction.\n\nYour job is to:\n1. Understand the user's question and extract intent (AGGREGATE or SEARCH).\n2. Generate a minimal preFilter ($match) for efficiency.\n3. Output **only the preFilter object** for MongoDB. Do not include postPipeline or fields.\n4. Parse natural language dates into ISO format (YYYY-MM-DD).\n5. Use only allowed fields: [\"site\",\"phase\",\"block\",\"productionDate\",\"weight\",\"quantity\"].\n6. Use only allowed operators: [\"$eq\",\"$in\",\"$gte\",\"$lte\"].\n7. Output valid JSON only, no extra text.",
+  "instructions": "You are an intelligent MongoDB query planner for FFBProduction.\n\nYour job is to:\n1. Understand the user's question and extract intent (AGGREGATE or SEARCH).\n2. Generate a minimal preFilter ($match or $vectorSearch.filter) for efficiency.\n3. Decide whether a vector search or pure aggregation is needed and output vectorQuery accordingly.\n4. Build a postPipeline array (aggregation stages after the search or match) to compute summaries, projections, or other transformations.\n5. Parse natural language dates into ISO format (YYYY-MM-DD).\n6. Use only allowed fields: [\"site\",\"phase\",\"block\",\"productionDate\",\"weight\",\"quantity\"].\n7. Use only allowed operators: [\"$eq\",\"$in\",\"$gte\",\"$lte\"].\n8. Output valid JSON only, no extra text.",
   "examples": [
     {
-      "question": "Total output in Site A for Nov-Dec",
+      "question": "Total output of FFB production in Site A during November and December",
       "plan": {
+        "intent": "AGGREGATE",
         "preFilter": {
           "site": "Site A",
           "productionDate": {
             "$gte": "2025-11-01",
             "$lte": "2025-12-31"
           }
-        }
+        },
+        "vectorQuery": null,
+        "vectorOptions": { "limit": 5, "numCandidates": 50 },
+        "postPipeline": [
+          { "$group": { "_id": "$site", "totalWeight": { "$sum": "$weight" } } },
+          { "$project": { "site": "$_id", "totalWeight": 1, "_id": 0 } }
+        ],
+        "fields": ["site", "weight", "productionDate"]
       }
     },
     {
-      "question": "FFB data for Site B",
+      "question": "Top 5 most similar records to 'highest producing block in Site B'",
       "plan": {
-        "preFilter": {
-          "site": "Site B"
-        }
+        "intent": "SEARCH",
+        "preFilter": { "site": "Site B" },
+        "vectorQuery": "highest producing block in Site B",
+        "vectorOptions": { "limit": 5, "numCandidates": 50 },
+        "postPipeline": [
+          { "$project": { "site": 1, "phase": 1, "block": 1, "weight": 1, "quantity": 1, "_id": 0 } }
+        ],
+        "fields": ["site", "phase", "block", "weight", "quantity"]
       }
     }
   ]