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

Optionally pass a block to OpenAI::Client.new #504

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

drnic
Copy link
Contributor

@drnic drnic commented Feb 29, 2024

This block is ultimately passed to Faraday.

For example, to enable low-level faraday logging:

llm = Langchain::LLM::OpenAI.new(api_key: ENV[OPENAI_API_KEY]) do |f|
  f.response :logger, Logger.new(), bodies: true
end

See more at https://github.com/alexrudall/ruby-openai?tab=readme-ov-file#verbose-logging

This block is ultimately passed to Faraday.

For example, to enable low-level faraday logging:

llm = Langchain::LLM::OpenAI.new(api_key: ENV[OPENAI_API_KEY]) do |f|
  f.response :logger, Logger.new(), bodies: true
end

https://github.com/alexrudall/ruby-openai?tab=readme-ov-file#verbose-logging
@andreibondarev
Copy link
Collaborator

@drnic Is the logger the only thing that you think you'd need to pass to the Faraday client? We also have this global logging option: https://github.com/andreibondarev/langchainrb?tab=readme-ov-file#logging. I wonder if it's better to have this global flag toggle logging in Faraday here and elsewhere. What's your thoughts?

@sergiobayona
Copy link

I ran into the same issue as @drnic where I could not pass a block to the openai client. Then I saw you mentioned the global logging flag, which I wasn't aware of before. However I still think it would be a nice addition to be able to pass the block.

@sergiobayona
Copy link

yeah so used Langchain.logger.level = :debug and ran some api calls. I was expecting to see the request/response calls logged but that was not the case. A stronger case for merging this.

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

Successfully merging this pull request may close these issues.

None yet

3 participants