patterns-ai-core / langchainrb

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

Rails app fails to start due to Langchain::LLM::Adapter NameError #816

Open quovai opened 2 hours ago

quovai commented 2 hours ago

Describe the bug

When starting the Rails application in the application exits with a NameError stating uninitialized constant Langchain::LLM::Adapter. This error seems to be related to the Langchain gem (0.17.1) or autoloading during the eager loading process.

To Reproduce

  1. Set up a Rails 6.0.6.1 application with the Langchain gem installed (version 0.17.1).
  2. Start the application using Puma as the web server.
  3. The application exits with the error before starting properly.

Expected behavior

The Rails application should start successfully without raising a NameError and remain running in development mode.

Terminal commands & output

Commands used:

rails server -b 0.0.0.0

Output:

=> Booting Puma
=> Rails 6.0.6.1 application starting in development
=> Run `rails server --help` for more startup options
Exiting
/usr/local/bundle/gems/zeitwerk-2.6.18/lib/zeitwerk/cref.rb:91:in `const_get': uninitialized constant Langchain::LLM::Adapter (NameError)
        from /usr/local/bundle/gems/zeitwerk-2.6.18/lib/zeitwerk/cref.rb:91:in `get'
        from /usr/local/bundle/gems/zeitwerk-2.6.18/lib/zeitwerk/loader/eager_load.rb:173:in `block in actual_eager_load_dir'
        ...
        from bin/rails:4:in `<main>'

System:

quovai commented 2 hours ago

This is the commit from which the problem starts (for me): 966eaa80022acca33814a1da8b102d4c64d2e650

courtsimas commented 40 minutes ago

https://github.com/patterns-ai-core/langchainrb/pull/807/files did some serious fubaring.