MCPcopy Index your code
hub / github.com/simstudioai/sim / localeFilter

Function localeFilter

apps/docs/app/api/chat/route.ts:190–200  ·  view source on GitHub ↗

* SQL predicate selecting only the locale's documents, so the row limit applies * to matching rows: non-English docs are prefixed with their locale segment; * English is everything not prefixed with another locale.

(locale: string)

Source from the content-addressed store, hash-verified

188 * English is everything not prefixed with another locale.
189 */
190function localeFilter(locale: string) {
191 const firstSegment = sql`split_part(${docsEmbeddings.sourceDocument}, '/', 1)`
192 if (locale === DEFAULT_LOCALE) {
193 const others = KNOWN_LOCALES.filter((l) => l !== DEFAULT_LOCALE)
194 return sql`${firstSegment} not in (${sql.join(
195 others.map((l) => sql`${l}`),
196 sql`, `
197 )})`
198 }
199 return sql`${firstSegment} = ${locale}`
200}
201
202type SearchRow = {
203 chunkId: string

Callers 1

searchDocsFunction · 0.85

Calls 1

joinMethod · 0.80

Tested by

no test coverage detected