Repository: meta-llama/llama-stack
File: llama_stack/providers/inline/vector_io/sqlite_vec/sqlite_vec.py (Python)

Code before:
        else:
            # Default to RRF for None, RRF, or any unknown types
            impact_factor = reranker_params.get("impact_factor", 60.0)
            combined_scores = _rrf_rerank(vector_scores, keyword_scores, impact_factor)

        # Sort by combined score and get top k results
        sorted_items = sorted(combined_scores.items(), key=lambda x: x[1], reverse=True)
        top_k_items = sorted_items[:k]

        # Filter by score threshold
        filtered_items = [(doc_id, score) for doc_id, score in top_k_items if score >= score_threshold]

        # Create a map of chunk_id to chunk for both responses
        chunk_map = {c.chunk_id: c for c in vector_response.chunks + keyword_response.chunks}

        # Use the map to look up chunks by their IDs
        chunks = []
        scores = []
        for doc_id, score in filtered_items:
            if doc_id in chunk_map:
                chunks.append(chunk_map[doc_id])
                scores.append(score)

        return QueryChunksResponse(chunks=chunks, scores=scores)

    async def remove_chunk(self, chunk_id: str) -> None:
        """Remove a chunk from the SQLite vector store."""

        def _delete_chunk():
            connection = _create_sqlite_connection(self.db_path)
            cur = connection.cursor()
            try:
                cur.execute("BEGIN TRANSACTION")

                # Delete from metadata table
                cur.execute(f"DELETE FROM {self.metadata_table} WHERE id = ?", (chunk_id,))

                # Delete from vector table
                cur.execute(f"DELETE FROM {self.vector_table} WHERE id = ?", (chunk_id,))

                # Delete from FTS table
                cur.execute(f"DELETE FROM {self.fts_table} WHERE id = ?", (chunk_id,))

                connection.commit()
            except Exception as e:
                connection.rollback()
                logger.error(f"Error deleting chunk {chunk_id}: {e}")
                raise
            finally:
                cur.close()
                connection.close()

Review comment (suggestion):
```suggestion
    async def delete_chunk(self, chunk_id: str) -> None:
```

Code after:
            # Default to RRF for None, RRF, or any unknown types
            impact_factor = reranker_params.get("impact_factor", 60.0)
            combined_scores = _rrf_rerank(vector_scores, keyword_scores, impact_factor)

        # Sort by combined score and get top k results
        sorted_items = sorted(combined_scores.items(), key=lambda x: x[1], reverse=True)
        top_k_items = sorted_items[:k]

        # Filter by score threshold
        filtered_items = [(doc_id, score) for doc_id, score in top_k_items if score >= score_threshold]

        # Create a map of chunk_id to chunk for both responses
        chunk_map = {c.chunk_id: c for c in vector_response.chunks + keyword_response.chunks}

        # Use the map to look up chunks by their IDs
        chunks = []
        scores = []
        for doc_id, score in filtered_items:
            if doc_id in chunk_map:
                chunks.append(chunk_map[doc_id])
                scores.append(score)

        return QueryChunksResponse(chunks=chunks, scores=scores)

    async def delete_chunk(self, chunk_id: str) -> None:
        """Remove a chunk from the SQLite vector store."""

        def _delete_chunk():
            connection = _create_sqlite_connection(self.db_path)
            cur = connection.cursor()
            try:
                cur.execute("BEGIN TRANSACTION")

                # Delete from metadata table
                cur.execute(f"DELETE FROM {self.metadata_table} WHERE id = ?", (chunk_id,))

                # Delete from vector table
                cur.execute(f"DELETE FROM {self.vector_table} WHERE id = ?", (chunk_id,))

                # Delete from FTS table
                cur.execute(f"DELETE FROM {self.fts_table} WHERE id = ?", (chunk_id,))

                connection.commit()
            except Exception as e:
                connection.rollback()
                logger.error(f"Error deleting chunk {chunk_id}: {e}")
                raise
            finally:
                cur.close()
                connection.close()