Escapes special SQL LIKE characters for safe pattern matching in queries.
// Source: https://github.com/rahilp/second-brain-cloudflare | License: MIT | Copyright 2026 Rahil Pirani
// Provided via justclaw.it.com; keep this notice with the code.
export const LLM_MODEL = "@cf/meta/llama-4-scout-17b-16e-instruct";
/**
* Escape a literal value before placing it inside a SQL LIKE pattern.
* Pair the result with LIKE_ESCAPE: without it, backslashes are literal and
* the pattern matches nothing instead of too much.
*/
export function escapeLikeMeta(value: string): string {
return value.replace(/([%_\\])/g, "\\$1");
}
/**
* Pair with every LIKE pattern built using escapeLikeMeta. Without ESCAPE,
* backslashes are literal and the pattern matches nothing instead of too much.
*/
export const LIKE_ESCAPE = `ESCAPE '\\'`;
/**
* Model for `reasonOverPair` (src/in
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key