suemo 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,35 +31,30 @@ export async function observe(
31
31
 
32
32
  // 2. Dedup probe: ANN search for cosine similarity > 0.97
33
33
  // For non-surreal providers, we pass the pre-computed vector as $qvec.
34
- if (config.embedding.provider !== 'surreal' && !embeddingParam) {
34
+ const usesSurrealEmbedding = config.embedding.provider === 'surrealml'
35
+ if (!usesSurrealEmbedding && !embeddingParam) {
35
36
  throw new Error(`Missing embedding vector for provider: ${config.embedding.provider}`)
36
37
  }
37
38
 
38
- const dedupVecClause = config.embedding.provider === 'surreal'
39
+ const dedupVecClause = usesSurrealEmbedding
39
40
  ? 'fn::embed($content)'
40
41
  : '$qvec'
41
- const dedupParams = config.embedding.provider === 'surreal'
42
+ const dedupParams = usesSurrealEmbedding
42
43
  ? { content: input.content }
43
44
  : { qvec: embeddingParam }
44
45
  log.debug('observe dedup probe', {
45
46
  provider: config.embedding.provider,
46
- queryMode: config.embedding.provider === 'surreal' ? 'fn::embed($content)' : '$qvec',
47
+ queryMode: usesSurrealEmbedding ? 'fn::embed($content)' : '$qvec',
47
48
  })
48
49
 
49
- const dedupResult = await db.query<[{ id: string; score: number }[]]>(
50
+ const dedupResult = await db.query<unknown[]>(
50
51
  `
51
52
  LET $vec = ${dedupVecClause};
52
- LET $cand = (
53
- SELECT id, embedding
54
- FROM memory
55
- WHERE (valid_until = NONE OR valid_until > time::now())
56
- AND embedding <|1, 20|> $vec
57
- );
58
-
59
53
  SELECT id, score
60
54
  FROM (
61
55
  SELECT id, vector::similarity::cosine(embedding, $vec) AS score
62
- FROM $cand
56
+ FROM memory
57
+ WHERE (valid_until = NONE OR valid_until > time::now())
63
58
  )
64
59
  ORDER BY score DESC
65
60
  LIMIT 1
@@ -67,7 +62,10 @@ export async function observe(
67
62
  dedupParams,
68
63
  )
69
64
 
70
- const topHit = dedupResult[0]?.[0]
65
+ const dedupRows = dedupResult.at(-1)
66
+ const topHit = Array.isArray(dedupRows)
67
+ ? (dedupRows[0] as { id: string; score: number } | undefined)
68
+ : undefined
71
69
  if (topHit && topHit.score > 0.97) {
72
70
  log.debug('Near-duplicate detected — merging tags, updating updated_at', {
73
71
  existingId: topHit.id,
package/src/types.ts CHANGED
@@ -125,7 +125,7 @@ export const QueryInputSchema = z.object({
125
125
  topK: z.number().int().min(1).max(50).default(5).optional(),
126
126
  activeOnly: z.boolean().default(true).optional(),
127
127
  strategies: z
128
- .array(z.enum(['vector', 'bm25', 'graph', 'temporal']))
128
+ .array(z.enum(['vector', 'bm25', 'graph']))
129
129
  .default(['vector', 'bm25', 'graph'])
130
130
  .optional(),
131
131
  })