patterns-ai-core / langchainrb_rails

MIT License
204 stars 21 forks source link

Annotations from the neighbor gem are lost when using similarity_search with pgvector #32

Closed swerner closed 10 months ago

swerner commented 10 months ago

The Neighbor gem (used when using pgvector) adds some methods to the returned records - in particular, neighbor_distance which gives you some additional data on how close of a match the record is to your query.

It looks like re-querying the records for weaviate here https://github.com/andreibondarev/langchainrb_rails/blob/d71d722153f7d0205c85cfb926bdf043888020c0/lib/langchainrb_rails/active_record/hooks.rb#L103-L104 is blowing away those annotations.

image