Class: RuboCop::Cop::Prompt::MissingStop
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Prompt::MissingStop
- Defined in:
- lib/rubocop/cop/prompt/missing_stop.rb
Overview
Checks for missing stop tokens or max_tokens in OpenAI::Client.chat calls.
This cop identifies OpenAI::Client.chat method calls and ensures they include either stop: or max_tokens: parameters to prevent runaway generation and ensure predictable behavior.
Constant Summary collapse
- MSG =
"OpenAI::Client.chat call should include 'stop:' or 'max_tokens:' parameter to prevent runaway generation"
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/rubocop/cop/prompt/missing_stop.rb', line 61 def on_send(node) return unless openai_chat_call?(node) parameters_hash = extract_parameters_hash(node) return unless parameters_hash return if has_stop_or_max_tokens?(parameters_hash) add_offense(node) end |