Skip to content

Commit 1e9c94c

Browse files
committed
Address openai_ask review polish
1 parent fd139b1 commit 1e9c94c

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ _None_
1414

1515
### Bug Fixes
1616

17-
- `openai_ask`: improve tool-use handling by requiring named function tools, using `max_completion_tokens`, opting out of OpenAI request storage, omitting sensitive tool diagnostics from logs, and refusing to execute additional tool calls after `max_tool_iterations`. [#719]
17+
- `openai_ask`: avoid logging sensitive tool diagnostics and refuse to execute additional tool calls after `max_tool_iterations`. [#719]
1818

1919
### Internal Changes
2020

21-
_None_
21+
- `openai_ask`: validate named function tools, use `max_completion_tokens`, and opt out of OpenAI request storage. [#719]
2222

2323
## 14.5.0
2424

lib/fastlane/plugin/wpmreleasetoolkit/actions/common/openai_ask_action.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module Fastlane
88
module Actions
99
class OpenaiAskAction < Action
1010
OPENAI_API_ENDPOINT = URI('https://api.openai.com/v1/chat/completions').freeze
11+
# Preserve the previous `max_tokens` ceiling while using the current API field.
1112
DEFAULT_MAX_COMPLETION_TOKENS = 2048
1213
DEFAULT_MAX_TOOL_ITERATIONS = 5
1314
DEFAULT_MODEL = 'gpt-4o'
@@ -49,6 +50,7 @@ def self.run(params)
4950
validate_tools_array!(tools)
5051
validate_max_tool_iterations!(max_tool_iterations)
5152
validate_tools!(tools)
53+
5254
run_with_tools(
5355
prompt: prompt,
5456
question: question,
@@ -164,7 +166,7 @@ def self.validate_tools_array!(tools)
164166
def self.validate_tools!(tools)
165167
invalid_tools = tools.each_with_index.filter_map do |tool, index|
166168
type = tool_type(tool)
167-
next "tools[#{index}] type #{type.empty? ? '<missing>' : type.inspect}" unless type == 'function'
169+
next "tools[#{index}] type #{type.nil? ? '<missing>' : type.inspect}" unless type == 'function'
168170

169171
function = tool[:function] || tool['function']
170172
name = function[:name] || function['name'] if function.is_a?(Hash)
@@ -182,9 +184,9 @@ def self.validate_tools!(tools)
182184
end
183185

184186
def self.tool_type(tool)
185-
return '' unless tool.is_a?(Hash)
187+
return nil unless tool.is_a?(Hash)
186188

187-
(tool[:type] || tool['type']).to_s
189+
(tool[:type] || tool['type'])&.to_s
188190
end
189191

190192
def self.valid_tool_name?(name)

0 commit comments

Comments
 (0)