-
Notifications
You must be signed in to change notification settings - Fork 269
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
Silence parser warning and patch version mismatch when loading parser/current #613
Conversation
prev = $VERBOSE | ||
$VERBOSE = nil | ||
require "parser/current" | ||
::Parser::CurrentRuby.new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a much nicer solution to this would be to send a PR to whitequark/parser adding an argument to Parser::CurrentRuby.new
that disables the warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made whitequark/parser#1065 we will see, but yeah you are right fixing it on the parser itself it's better, than hotfixing here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They won't update their parser with Ruby >3.4 so we're stuck
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, interesting to see how this will play out with rubocop and the parsing ecosystem of Ruby.
I do not know why but with my PR
But works with the original repository, do you have an idea ? I did a little bit by editing the OpenAi::Client to: def translator
@translator ||= OpenAI::Client.new(access_token: api_key, log_errors: true) do |f|
f.response :logger, Logger.new($stdout), bodies: true
end
end I got:
|
I found the problem, the prompt has to have the word json in the prompt to be able to use response_format with json_object. |
@navidemad please split out the OpenAI logging to a separate PR 🙂 |
I split the changes into three PR as requested: |
hey @davidwessman do you think this PR is ready to be merged? |
@navidemad can you rebase and fix conflicts? |
…to use 'response_format' of type 'json_object'.
@davidwessman Done |
@navidemad please fix the lint error |
Done |
Description
This pull request adds a factory class
RubyParserFactory
to temporarily disable verbose mode when loading the "parser/current" library. The purpose is to suppress compatibility warnings that are displayed when the library is loaded with a different Ruby version than the one it recognizes.Example warning for the release of Ruby 3.4.1 :
By disabling verbose mode, these warnings are suppressed to provide a cleaner output and avoid confusion. The verbose mode is restored after the parser instance is created to maintain the original behavior.
References
Changes
I18n::Tasks::Scanners
to encapsulate the factory class.RubyParserFactory
class with acreate_parser
method that temporarily disables verbose mode, loads the "parser/current" library, creates a new parser instance, and restores the verbose mode.Benefits
Issues
Please let me know if you have any questions or feedback regarding this pull request.
Thank you for considering this contribution to the gem!