pub const QUERY_REWRITE_PROMPT: &str = r#"Rewrite this search query into 2-3 variations that would help find relevant memories.
Query: {query}
Return as JSON array of strings. Example: ["variation 1", "variation 2", "variation 3"]
Only return the JSON array, nothing else."#;
#[must_use]
pub fn build_query_rewrite_prompt(query: &str) -> String {
QUERY_REWRITE_PROMPT.replace("{query}", query)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_build_prompt() {
let prompt = build_query_rewrite_prompt("Who works at Acme?");
assert!(prompt.contains("Who works at Acme?"));
assert!(prompt.contains("Query:"));
assert!(prompt.contains("JSON array"));
}
#[test]
fn test_prompt_structure() {
let prompt = build_query_rewrite_prompt("test");
assert!(prompt.contains("Rewrite this search query"));
assert!(prompt.contains("Query: test"));
assert!(prompt.contains("2-3 variations"));
assert!(prompt.contains("Only return the JSON"));
}
}