Spaces:
Sleeping
Sleeping
Update data_planner.py
Browse files- data_planner.py +20 -7
data_planner.py
CHANGED
|
@@ -2,18 +2,31 @@ import json
|
|
| 2 |
from openai_client import ask_gpt
|
| 3 |
from schema_map import schema # 👈 Import the full schema
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
system_msg = {
|
| 9 |
"role": "system",
|
| 10 |
"content": (
|
| 11 |
"You are a planning assistant for a Firestore chatbot.\n"
|
| 12 |
-
"
|
| 13 |
-
"
|
| 14 |
-
"
|
| 15 |
-
"
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
"Use this schema for all reasoning. It includes field names, types, and aliases:\n"
|
| 18 |
f"{json.dumps(schema)}\n\n"
|
| 19 |
"Strictly return only a valid JSON object with keys: collections, filters, instruction. No explanation."
|
|
|
|
| 2 |
from openai_client import ask_gpt
|
| 3 |
from schema_map import schema # 👈 Import the full schema
|
| 4 |
|
| 5 |
+
def determine_data_requirements(
|
| 6 |
+
user_prompt: str,
|
| 7 |
+
company_code: str,
|
| 8 |
+
user_id: str,
|
| 9 |
+
participant_email: str | None,
|
| 10 |
+
participant_id: str | None,
|
| 11 |
+
):
|
| 12 |
+
token_participant = "{{{{participantId}}}}" # renders as {{participantId}} inside f-string
|
| 13 |
|
| 14 |
system_msg = {
|
| 15 |
"role": "system",
|
| 16 |
"content": (
|
| 17 |
"You are a planning assistant for a Firestore chatbot.\n"
|
| 18 |
+
"Return ONLY JSON with keys: collections, filters, instruction.\n"
|
| 19 |
+
"Rules:\n"
|
| 20 |
+
"- Always include filters.companyCode set to the current company.\n"
|
| 21 |
+
"- The 'userId' is an Auth UID (users/{uid}).\n"
|
| 22 |
+
"- 'applications.participantId' is the doc ID of /participants/{participantId}.\n"
|
| 23 |
+
"- To reference the current user's participant-linked data, use this participantId.\n"
|
| 24 |
+
f"- If you need the current participant, use token {token_participant} in filters.\n"
|
| 25 |
+
"- If participantId is unavailable, prefer filtering by email where applicable.\n\n"
|
| 26 |
+
f"Current companyCode: '{company_code}'\n"
|
| 27 |
+
f"Current uid: '{user_id}'\n"
|
| 28 |
+
f"Current user email: '{participant_email or ''}'\n"
|
| 29 |
+
f"Current participantId: '{participant_id or ''}'\n"
|
| 30 |
"Use this schema for all reasoning. It includes field names, types, and aliases:\n"
|
| 31 |
f"{json.dumps(schema)}\n\n"
|
| 32 |
"Strictly return only a valid JSON object with keys: collections, filters, instruction. No explanation."
|