Update app.py
Browse files
app.py
CHANGED
|
@@ -52,19 +52,27 @@ if uploaded_files:
|
|
| 52 |
|
| 53 |
# --- System prompt with explicit example ---
|
| 54 |
system_message = {
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
)
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
st.session_state.messages = [system_message]
|
| 69 |
else:
|
| 70 |
st.session_state.json_data.clear()
|
|
|
|
| 52 |
|
| 53 |
# --- System prompt with explicit example ---
|
| 54 |
system_message = {
|
| 55 |
+
"role": "system",
|
| 56 |
+
"content": (
|
| 57 |
+
"You are an AI data analyst for uploaded JSON files. "
|
| 58 |
+
"Each file may have different structures and keys, including lists and nested dictionaries. "
|
| 59 |
+
"You have access to a function 'search_all_jsons' that finds all records in all JSON files where a key matches a value, recursively. "
|
| 60 |
+
"If a user asks about groups of people or wants to know counts such as 'How many females are there?', "
|
| 61 |
+
"interpret this as 'search for all records where gender equals female'. "
|
| 62 |
+
"Always use the 'search_all_jsons' function with key='gender' and value='female' for such queries, unless another key/value is clear from context. "
|
| 63 |
+
"If someone asks 'How many males?', search for gender equals male, etc. "
|
| 64 |
+
"EXAMPLES:\n"
|
| 65 |
+
"User: How many females are there?\n"
|
| 66 |
+
"Assistant: (Call search_all_jsons with key='gender', value='female')\n"
|
| 67 |
+
"User: How many males are there?\n"
|
| 68 |
+
"Assistant: (Call search_all_jsons with key='gender', value='male')\n"
|
| 69 |
+
"User: Show all females\n"
|
| 70 |
+
"Assistant: (Call search_all_jsons with key='gender', value='female')\n"
|
| 71 |
+
"User: How many people are named Emily?\n"
|
| 72 |
+
"Assistant: (Call search_all_jsons with key='firstName', value='Emily')"
|
| 73 |
+
)
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
st.session_state.messages = [system_message]
|
| 77 |
else:
|
| 78 |
st.session_state.json_data.clear()
|