obscene_gpt 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bce283bc9c60f359c7f0775beacc5944fc7527d11c7c43fd17169b1e79d384a4
4
- data.tar.gz: 6973765625142b070eef775fbe95fee391d7072b741331b8499e58153576cb55
3
+ metadata.gz: 1df39bb3a19a26722d13b2921283fc799d805f9fa78552a6d4e8acc006b070a2
4
+ data.tar.gz: 00b6509403f0b9ed1dd548855864880e70263453d29298a80d06169521dc3ece
5
5
  SHA512:
6
- metadata.gz: 1e48c7c143058f428440bb73578aeb2b647c7534a9981987d88aa7a8af4a9b518d309efaa98fcc7a0557ef09a4554c27623711cbc393dd6f4583a791fc137f01
7
- data.tar.gz: 8fee0f4115e16246c24795f40a98f66213c0db539b2b875590068d5781543969903eed25b6d287c7a1c919c52cef987bb032a85e73ba4f3c61984e1a16419e69
6
+ metadata.gz: d12d1181ef378d2ef4efbc127080660f2960e8f292e9ecdfcd5af02a7b1bf05aab5fb6cae7ab592c32e57cf7efcce93bfa4d480aa9499c0941f5785ab5d7d3b7
7
+ data.tar.gz: 1f329abf1c69b9243c291fbf306a756b6c044e18e3a83b419cc327cb88687377c07a2d91c35362cbcbd7bd7361e87e6b9d65541d1e6dde0a924972c41da20926
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.0] - 2026-10-02
4
+
5
+ - Add `reasoning_effort` option (configuration and `Detector.new`), defaulting to `"none"`
6
+ - Change default model to `gpt-6-luna`
7
+ - Update development dependencies and Bundler to 4.0.22
8
+
3
9
  ## [0.1.0] - 2025-06-30
4
10
 
5
11
  - Initial release
data/README.md CHANGED
@@ -37,7 +37,8 @@ export OPENAI_API_KEY="your-openai-api-key-here"
37
37
  ```ruby
38
38
  ObsceneGpt.configure do |config|
39
39
  config.api_key = "your-openai-api-key-here"
40
- config.model = "gpt-4.1-nano"
40
+ config.model = "gpt-6-luna"
41
+ config.reasoning_effort = "low" # Optional, defaults to "none"
41
42
  config.request_timeout = 5 # Optional, defaults to 10 seconds
42
43
  end
43
44
  ```
@@ -60,7 +61,7 @@ require 'obscene_gpt'
60
61
  # Configure once in your app initialization
61
62
  ObsceneGpt.configure do |config|
62
63
  config.api_key = "your-openai-api-key-here"
63
- config.model = "gpt-4.1-nano"
64
+ config.model = "gpt-6-luna"
64
65
  end
65
66
 
66
67
  detector = ObsceneGpt::Detector.new
@@ -131,7 +132,7 @@ Configure the gem globally.
131
132
  ```ruby
132
133
  ObsceneGpt.configure do |config|
133
134
  config.api_key = "your-api-key"
134
- config.model = "gpt-4.1-nano"
135
+ config.model = "gpt-6-luna"
135
136
  config.schema = ObsceneGpt::Prompts::SIMPLE_SCHEMA
136
137
  config.prompt = ObsceneGpt::Prompts::SYSTEM_PROMPT
137
138
  end
@@ -143,9 +144,9 @@ Get the current configuration object.
143
144
 
144
145
  ### ObsceneGpt::Detector
145
146
 
146
- #### ObsceneGpt::Detector.new(api_key: nil, model: nil)
147
+ #### ObsceneGpt::Detector.new(api_key: nil, model: nil, schema: nil, prompt: nil, request_timeout: nil, reasoning_effort: nil)
147
148
 
148
- Creates a new detector instance.
149
+ Creates a new detector instance. Any option left as `nil` falls back to the global configuration.
149
150
 
150
151
  #### ObsceneGpt::Detector#detect(text)
151
152
 
@@ -196,7 +197,9 @@ The default configuration is:
196
197
 
197
198
  ```ruby
198
199
  config.api_key = ENV["OPENAI_API_KEY"]
199
- config.model = "gpt-4.1-nano"
200
+ config.model = "gpt-6-luna"
201
+ config.reasoning_effort = "none"
202
+ config.request_timeout = 10
200
203
  config.schema = ObsceneGpt::Prompts::SIMPLE_SCHEMA
201
204
  config.prompt = ObsceneGpt::Prompts::SYSTEM_PROMPT
202
205
  config.test_mode = false
@@ -262,9 +265,25 @@ See `examples/custom_test_detector.rb` for more examples.
262
265
 
263
266
  ### Model
264
267
 
265
- We recommend using the `gpt-4.1-nano` model for cost efficiency.
268
+ The default model is `gpt-6-luna`.
266
269
  Given the simplicity of the task, it's typically not necessary to use a more expensive model.
267
270
 
271
+ ### Reasoning effort
272
+
273
+ The `reasoning_effort` option is sent to the OpenAI API as `reasoning: { effort: ... }`.
274
+ It defaults to `"none"`, which keeps latency and cost low for this simple classification task.
275
+ Supported values depend on the model (for `gpt-6-luna`: `none`, `low`, `medium`, `high`, `xhigh`, `max`).
276
+ Set it to `nil` to omit the parameter entirely, e.g. when using a model that does not support reasoning.
277
+
278
+ ```ruby
279
+ ObsceneGpt.configure do |config|
280
+ config.reasoning_effort = "low"
281
+ end
282
+
283
+ # Or per detector
284
+ detector = ObsceneGpt::Detector.new(reasoning_effort: "medium")
285
+ ```
286
+
268
287
  See [OpenAI's documentation](https://platform.openai.com/docs/pricing) for more information.
269
288
 
270
289
  ### Prompt
data/examples/usage.rb CHANGED
@@ -3,7 +3,7 @@ require "obscene_gpt"
3
3
  # Configure the gem globally (do this once in your app initialization)
4
4
  ObsceneGpt.configure do |config|
5
5
  # config.api_key = "your-openai-api-key-here"
6
- config.model = "gpt-4.1-nano"
6
+ config.model = "gpt-6-luna"
7
7
  config.schema = ObsceneGpt::Prompts::FULL_SCHEMA
8
8
  end
9
9
 
@@ -11,11 +11,12 @@ module ObsceneGpt
11
11
 
12
12
  class Configuration
13
13
  attr_accessor :api_key, :model, :schema, :prompt, :profanity_threshold, :test_mode,
14
- :test_detector_class, :request_timeout
14
+ :test_detector_class, :request_timeout, :reasoning_effort
15
15
 
16
16
  def initialize
17
17
  @api_key = ENV.fetch("OPENAI_API_KEY", nil)
18
- @model = "gpt-4.1-nano"
18
+ @model = "gpt-6-luna"
19
+ @reasoning_effort = "none"
19
20
  @prompt = Prompts::SYSTEM_PROMPT
20
21
  @schema = Prompts::SIMPLE_SCHEMA
21
22
  @profanity_threshold = 0.8
@@ -3,9 +3,9 @@ require "openai"
3
3
 
4
4
  module ObsceneGpt
5
5
  class Detector
6
- attr_reader :client, :model, :schema, :prompt
6
+ attr_reader :client, :model, :schema, :prompt, :reasoning_effort
7
7
 
8
- def initialize(api_key: nil, model: nil, schema: nil, prompt: nil, request_timeout: nil)
8
+ def initialize(api_key: nil, model: nil, schema: nil, prompt: nil, request_timeout: nil, reasoning_effort: nil) # rubocop:disable Metrics/ParameterLists
9
9
  api_key ||= ObsceneGpt.configuration.api_key
10
10
 
11
11
  @client = OpenAI::Client.new(
@@ -15,6 +15,7 @@ module ObsceneGpt
15
15
  @model = model || ObsceneGpt.configuration.model
16
16
  @schema = schema || ObsceneGpt.configuration.schema
17
17
  @prompt = prompt || ObsceneGpt.configuration.prompt
18
+ @reasoning_effort = reasoning_effort || ObsceneGpt.configuration.reasoning_effort
18
19
  end
19
20
 
20
21
  # Detects whether the given texts contain obscene content
@@ -54,13 +55,13 @@ module ObsceneGpt
54
55
  text_format = { name: "content-moderation", type: "json_schema", schema: make_schema(texts.length), strict: true }
55
56
  {
56
57
  model: @model,
58
+ reasoning: @reasoning_effort && { effort: @reasoning_effort },
57
59
  text: { format: text_format },
58
60
  input: [{
59
61
  role: "user",
60
- content: [{ type: "input_text", text: @prompt },
61
- { type: "input_text", text: JSON.dump(texts) }],
62
+ content: [{ type: "input_text", text: @prompt }, { type: "input_text", text: JSON.dump(texts) }],
62
63
  }],
63
- }
64
+ }.compact
64
65
  end
65
66
 
66
67
  def make_schema(texts_count)
@@ -1,3 +1,3 @@
1
1
  module ObsceneGpt
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: obscene_gpt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Perez
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-07-19 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: ruby-openai
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
71
  requirements: []
72
- rubygems_version: 3.6.2
72
+ rubygems_version: 4.0.18
73
73
  specification_version: 4
74
74
  summary: A Ruby gem that uses OpenAI API to detect obscene content in text
75
75
  test_files: []