MCPcopy
hub / github.com/drizzle-team/drizzle-orm / cosineDistance

Function cosineDistance

drizzle-orm/src/sql/functions/vector.ts:125–133  ·  view source on GitHub ↗
(
	column: SQLWrapper | AnyColumn,
	value: number[] | string[] | TypedQueryBuilder<any> | string,
)

Source from the content-addressed store, hash-verified

123 * ```
124 */
125export function cosineDistance(
126 column: SQLWrapper | AnyColumn,
127 value: number[] | string[] | TypedQueryBuilder<any> | string,
128): SQL {
129 if (Array.isArray(value)) {
130 return sql`${column} <=> ${toSql(value)}`;
131 }
132 return sql`${column} <=> ${value}`;
133}
134
135/**
136 * Hamming distance between two strings or vectors of equal length is the number of positions at which the

Callers

nothing calls this directly

Calls 2

sqlFunction · 0.90
toSqlFunction · 0.85

Tested by

no test coverage detected