Skip to content

Commit 9d55e94

Browse files
committed
updated prompt based on comment
Signed-off-by: Dhrubo Saha <[email protected]>
1 parent 5e43dd5 commit 9d55e94

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

common/src/main/java/org/opensearch/ml/common/memorycontainer/MemoryContainerConstants.java

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -150,30 +150,32 @@ public class MemoryContainerConstants {
150150
public static final String SCORE_FIELD = "score";
151151

152152
// LLM System Prompts
153-
public static final String SEMANTIC_FACTS_EXTRACTION_PROMPT = """
154-
<ROLE>You are a universal semantic fact extraction agent. Write FULL-SENTENCE, self-contained facts suitable for long-term memory.</ROLE>
155-
156-
<SCOPE>
157-
• Include facts from USER messages.
158-
• Also include ASSISTANT-authored statements that are clearly presented as conclusions/results/validated findings (e.g., root cause, quantified impact, confirmed fix).
159-
• Ignore ASSISTANT questions, hypotheses, tentative language, brainstorming, instructions, or tool prompts unless explicitly confirmed as outcomes.
160-
</SCOPE>
161-
162-
<STYLE & RULES>
163-
• One sentence per fact; merge closely related details (metrics, entities, causes, scope) into the same sentence.
164-
• Do NOT start with "User" or pronouns.
165-
• Prefer absolute over relative time; if only relative (e.g., "yesterday"), omit it rather than guessing.
166-
• Preserve terminology, names, numbers, and units; avoid duplicates and chit-chat.
167-
• No speculation or hedging unless those words appear verbatim in the source.
168-
</STYLE & RULES>
169-
170-
<OUTPUT>
171-
Return ONLY a single JSON object on one line, minified exactly as {"facts":["..."]} (array of strings only; no other keys). No code fences, no newlines/tabs, and no spaces after commas or colons. If no meaningful facts, return {"facts":[]}.
172-
</OUTPUT>""";
153+
public static final String SEMANTIC_FACTS_EXTRACTION_PROMPT =
154+
"""
155+
<ROLE>You are a universal semantic fact extraction agent. Write FULL-SENTENCE, self-contained facts suitable for long-term memory.</ROLE>
156+
157+
<SCOPE>
158+
• Include facts from USER messages.
159+
• Also include ASSISTANT-authored statements that are clearly presented as conclusions/results/validated findings (e.g., root cause, quantified impact, confirmed fix).
160+
• Ignore ASSISTANT questions, hypotheses, tentative language, brainstorming, instructions, or tool prompts unless explicitly confirmed as outcomes.
161+
</SCOPE>
162+
163+
<STYLE & RULES>
164+
• One sentence per fact; merge closely related details (metrics, entities, causes, scope) into the same sentence.
165+
• Do NOT start with "User" or pronouns.
166+
• Prefer absolute over relative time; if only relative (e.g., "yesterday"), omit it rather than guessing.
167+
• Preserve terminology, names, numbers, and units; avoid duplicates and chit-chat.
168+
• No speculation or hedging unless those words appear verbatim in the source.
169+
</STYLE & RULES>
170+
171+
<OUTPUT>
172+
Return ONLY a single JSON object on one line, minified exactly as {"facts":["..."]} (array of strings only; no other keys). No code fences, no newlines/tabs, and no spaces after commas or colons. If no meaningful facts, return {"facts":[]}.
173+
</OUTPUT>""";
173174

174175
// JSON enforcement message to append to all fact extraction requests
175-
public static final String JSON_ENFORCEMENT_MESSAGE = """
176-
Respond NOW with ONE LINE of valid JSON ONLY exactly as {"facts":["fact1","fact2",...]}. No extra text, no code fences, no newlines or tabs, no spaces after commas or colons.""";
176+
public static final String JSON_ENFORCEMENT_MESSAGE =
177+
"""
178+
Respond NOW with ONE LINE of valid JSON ONLY exactly as {"facts":["fact1","fact2",...]}. No extra text, no code fences, no newlines or tabs, no spaces after commas or colons.""";
177179

178180
public static final String USER_PREFERENCE_FACTS_EXTRACTION_PROMPT =
179181
"<system_prompt><role>User Preferences Analyzer</role><objective>Extract and organize user preferences, choices, and settings from conversations.</objective><instructions><instruction>Carefully read the conversation.</instruction><instruction>Identify and extract explicit or implicit preferences, likes, dislikes, and choices.</instruction><instruction>Explicit preferences: Directly stated preferences by the user.</instruction><instruction>Implicit preferences: Inferred from patterns, repeated inquiries, or contextual clues. Take a close look at user's request for implicit preferences.</instruction><instruction>For explicit preference, extract only preference that the user has explicitly shared. Do not infer user's preference.</instruction><instruction>For implicit preference, it is allowed to infer user's preference, but only the ones with strong signals, such as requesting something multiple times.</instruction><instruction>Focus specifically on:<preference_categories><item>Product or service preferences (brands, features, styles)</item><item>Communication preferences (frequency, channel, timing)</item><item>Content preferences (topics, formats, sources)</item><item>Interaction preferences (formal/casual, detailed/brief)</item><item>Likes and dislikes explicitly stated</item><item>Preferred methods or approaches</item><item>Quality or attribute preferences</item><item>Time and scheduling preferences</item></preference_categories></instruction><instruction>Each preference should be a specific, actionable fact.</instruction><instruction>Focus on what the user wants, prefers, or chooses, not general information.</instruction><instruction>Never answer user's question or fulfill user's requirement. You are a preference analyzer, not a helpful assistant.</instruction><instruction>Analyze thoroughly and include detected preferences in your response.</instruction><instruction>If no preferences are found, return an empty list.</instruction></instructions><response_format><format>You should always return and only return the extracted preferences as a JSON object with a \"facts\" array. Return ONLY the valid JSON array with no additional text, explanations, or formatting.</format><example>{\"facts\": [\"User prefers dark mode for UI\",\"User likes to receive weekly summary emails\",\"User prefers Python over Java for scripting\",\"User dislikes automatic updates\"]}</example></response_format></system_prompt>";

0 commit comments

Comments
 (0)