Last active
June 18, 2025 06:42
-
-
Save iregina/894b1524b21194f7e6c79cfa6af95624 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # .roast/initializers/raix.rb | |
| require "raix" | |
| require "faraday" | |
| require "faraday/retry" | |
| Raix.configure do |config| | |
| # Configure the OpenAI client with custom settings | |
| config.openai_client = OpenAI::Client.new( | |
| access_token: ENV.fetch("OPENAI_API_KEY"), | |
| uri_base: ENV.fetch("OPENAI_API_BASE", "https://api.openai.com/v1"), | |
| ) do |f| | |
| # Add automatic retry for failed requests | |
| f.request(:retry, { | |
| max: 2, | |
| interval: 0.05, | |
| interval_randomness: 0.5, | |
| backoff_factor: 2, | |
| }) | |
| # Enable debug logging when needed | |
| if ENV["DEBUG"] | |
| f.response(:logger, Logger.new($stdout), { | |
| headers: false, | |
| bodies: true, | |
| errors: true | |
| }) do |logger| | |
| logger.filter(/(Bearer) (\S+)/, '\1[REDACTED]') | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment