Module: RubyLLM::Providers::OpenAI::Moderation
- Included in:
- RubyLLM::Providers::OpenAI
- Defined in:
- lib/ruby_llm/providers/openai/moderation.rb
Overview
Moderation methods of the OpenAI API integration
Class Method Summary collapse
- .moderation_url ⇒ Object
- .parse_moderation_response(response, model:) ⇒ Object
- .render_moderation_payload(input, model:) ⇒ Object
Class Method Details
.moderation_url ⇒ Object
10 11 12 |
# File 'lib/ruby_llm/providers/openai/moderation.rb', line 10 def moderation_url 'moderations' end |
.parse_moderation_response(response, model:) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ruby_llm/providers/openai/moderation.rb', line 21 def parse_moderation_response(response, model:) data = response.body raise Error.new(response, data.dig('error', 'message')) if data.dig('error', 'message') RubyLLM::Moderation.new( id: data['id'], model: model, results: data['results'] || [] ) end |
.render_moderation_payload(input, model:) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/ruby_llm/providers/openai/moderation.rb', line 14 def render_moderation_payload(input, model:) { model: model, input: input } end |