Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundler inline is broken because of dependency loader #517

Open
ipepe opened this issue Mar 12, 2024 · 2 comments
Open

Bundler inline is broken because of dependency loader #517

ipepe opened this issue Mar 12, 2024 · 2 comments

Comments

@ipepe
Copy link

ipepe commented Mar 12, 2024

When I try to use langchain in inline bundler it breaks:

require 'bundler/inline'

gemfile(true) do
  source 'https://rubygems.org'

  ruby '3.1.4'

  gem 'langchainrb', '~> 0.9.4'
  gem 'pdf-reader', '~> 1.4'
  gem 'pg'
  gem 'pgvector'
  gem 'faraday'
  gem 'sequel'
end

require 'langchain'
require 'forwardable'

llm = Langchain::LLM::Ollama.new(
  url: OLLAMA_URL,
  default_options: {
    completion_model_name: 'llama2',
    embeddings_model_name: 'llama2'
  }
)

I managed to get it temporarily fixed with:

Langchain::DependencyHelper.class_eval do # fix for bundler/inline
  def depends_on(gem_name, req: true)
    require gem_name
  end
end

But the initial error message looks like this:

/Users/pptasinski/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.6/lib/bundler/shared_helpers.rb:21:in `default_gemfile': Could not locate Gemfile (Bundler::GemfileNotFound)
        from /Users/pptasinski/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.6/lib/bundler/shared_helpers.rb:26:in `default_lockfile'
        from /Users/pptasinski/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.6/lib/bundler.rb:461:in `default_lockfile'
        from /Users/pptasinski/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.6/lib/bundler.rb:205:in `definition'
        from /Users/pptasinski/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.6/lib/bundler.rb:191:in `load'
        from /Users/pptasinski/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/langchainrb-0.9.4/lib/langchain/dependency_helper.rb:23:in `depends_on'
        from /Users/pptasinski/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/langchainrb-0.9.4/lib/langchain/llm/ollama.rb:37:in `initialize'
        from app.rb:55:in `new'
        from app.rb:55:in `<main>'
@andreibondarev
Copy link
Collaborator

@ipepe Do you have any good ideas for a fix here?

@ipepe
Copy link
Author

ipepe commented Mar 13, 2024

Not really. Maybe it would be possible to detect that bundler/inline is loaded and depends_on shouldn't use that part of bundler that depends on Gemfile?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants