patterns-ai-core / langchainrb

Build LLM-powered applications in Ruby
https://rubydoc.info/gems/langchainrb
MIT License
1.44k stars 195 forks source link

Langchain::Vectorsearch::Pgvector connection pooling missing #800

Open pedroresende opened 1 month ago

pedroresende commented 1 month ago

Describe the bug

Currently the Langchain::Vectorsearch::Pgvector each time it's initalized it starts a new db connection, which might be a problem since it doesn't have connection pool

To Reproduce

make 30 requests and the connections will be open

Expected behavior

to re-use the same connection and not start a new one

bborn commented 1 month ago

Pretty sure Sequel does use a connection pool by default (with max_connections = 4): https://sequel.jeremyevans.net/rdoc/files/doc/opening_databases_rdoc.html (https://share.cleanshot.com/fJs4bWqj)

Not actually sure how to test this correctly, but @andreibondarev here's a PR to at least allow setting the max_connections on the instance: https://github.com/patterns-ai-core/langchainrb/pull/842