obscene_gpt 0.1.0 → 0.1.1
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 +4 -4
- data/README.md +11 -0
- data/lib/obscene_gpt/active_model.rb +2 -0
- data/lib/obscene_gpt/detector.rb +1 -1
- data/lib/obscene_gpt/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ef6875fbee1dd1d83f91a84405092e6a7c33bc5fdfcb41d539cb239d9620659
|
4
|
+
data.tar.gz: 92ebe600ec5cda5c9631024246f5b9506388ee5414352d741c1a149605f8d46c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2994590f0880cc27f53100e75fa4f06b237ca0f870de0f7e8ffe165c24684b23670d36c9ace1ad74811b4a2682a695c50b0afa8fcb878e6cf99c62859f63aa6f
|
7
|
+
data.tar.gz: fa5f3e64135529d62b275f85c177db364702f5aa8822a4fd1d40373b6d9b53ed216ea42b1c01091bc3c3d194975a78661ef4ee00e380667e0d7023e1ddc987ec
|
data/README.md
CHANGED
@@ -308,6 +308,7 @@ Therefore, it is recommended to pass all the attributes you want to check to the
|
|
308
308
|
|
309
309
|
- `threshold` (Float): Custom confidence threshold (0.0-1.0) for determining when content is considered inappropriate. Default: Uses `ObsceneGpt.configuration.profanity_threshold`
|
310
310
|
- `message` (String): Custom error message to display when validation fails. Default: Uses AI reasoning if available, otherwise "contains inappropriate content"
|
311
|
+
- `ignore_errors` (Boolean): If true, the validator will not raise an error if the OpenAI API returns an error. Default: false
|
311
312
|
|
312
313
|
### Per-Attribute Options
|
313
314
|
|
@@ -349,6 +350,16 @@ class Post < ActiveRecord::Base
|
|
349
350
|
end
|
350
351
|
```
|
351
352
|
|
353
|
+
**Basic validation with ignore_errors:**
|
354
|
+
|
355
|
+
If there is an error from the OpenAI API, the validator will just skip the validation and not raise an error.
|
356
|
+
|
357
|
+
```ruby
|
358
|
+
class Post < ActiveRecord::Base
|
359
|
+
validates :content, obscene_content: { ignore_errors: true }
|
360
|
+
end
|
361
|
+
```
|
362
|
+
|
352
363
|
**With custom message:**
|
353
364
|
|
354
365
|
```ruby
|
data/lib/obscene_gpt/detector.rb
CHANGED
@@ -43,7 +43,7 @@ module ObsceneGpt
|
|
43
43
|
|
44
44
|
JSON.parse(response.dig("output", 0, "content", 0, "text"))["results"].map { |r| r.transform_keys(&:to_sym) }
|
45
45
|
rescue OpenAI::Error, Faraday::Error => e
|
46
|
-
body = e.respond_to?(:response) ? e.response[:body] : ""
|
46
|
+
body = e.respond_to?(:response) && e.response.is_a?(Hash) ? e.response[:body] : ""
|
47
47
|
raise ObsceneGpt::Error, "OpenAI API error: #{e.message}\n#{body}"
|
48
48
|
end
|
49
49
|
|
data/lib/obscene_gpt/version.rb
CHANGED
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.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Perez
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-07-03 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: ruby-openai
|