searchChunksSemantic method

Future<List<ContentChunkModel>> searchChunksSemantic(
  1. List<double> queryEmbedding, {
  2. String? topicId,
  3. String? domainId,
  4. double threshold = 0.3,
  5. int limit = 8,
})

Semantic search via pgvector cosine similarity (requires embeddings).

Implementation

Future<List<ContentChunkModel>> searchChunksSemantic(
  List<double> queryEmbedding, {
  String? topicId,
  String? domainId,
  double threshold = 0.3,
  int limit = 8,
}) async {
  final response = await _client.rpc(
    'match_chunks',
    params: {
      'query_embedding': queryEmbedding.toString(),
      'match_topic_id': ?topicId,
      'match_domain_id': ?domainId,
      'match_threshold': threshold,
      'match_count': limit,
    },
  );
  return (response as List<dynamic>)
      .map((row) => ContentChunkModel.fromJson(row as Map<String, dynamic>))
      .toList();
}