Class: OmniAI::OpenAI::Thread::Content
- Inherits:
-
Object
- Object
- OmniAI::OpenAI::Thread::Content
- Defined in:
- lib/omniai/openai/thread/content.rb
Overview
An OpenAI content w/ annotations.
Defined Under Namespace
Modules: Type
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data:, client:) ⇒ Content
constructor
A new instance of Content.
- #text ⇒ OmniAI::OpenAI::Thread::Text
- #text? ⇒ Boolean
-
#type ⇒ String
E.g.
Constructor Details
#initialize(data:, client:) ⇒ Content
Returns a new instance of Content.
27 28 29 30 |
# File 'lib/omniai/openai/thread/content.rb', line 27 def initialize(data:, client:) @data = data @client = client end |
Instance Attribute Details
#data ⇒ Hash?
24 25 26 |
# File 'lib/omniai/openai/thread/content.rb', line 24 def data @data end |
Class Method Details
.for(data:, client: Client.new) ⇒ Array<OmniAI::OpenAI::Thread::Content>, ...
16 17 18 19 20 |
# File 'lib/omniai/openai/thread/content.rb', line 16 def self.for(data:, client: Client.new) return data unless data.is_a?(Enumerable) data.map { || new(data: , client:) } end |
Instance Method Details
#text ⇒ OmniAI::OpenAI::Thread::Text
43 44 45 |
# File 'lib/omniai/openai/thread/content.rb', line 43 def text @text ||= Text.new(data: @data['text'], client: @client) if @data['text'] end |
#text? ⇒ Boolean
38 39 40 |
# File 'lib/omniai/openai/thread/content.rb', line 38 def text? type.eql?(Type::TEXT) end |
#type ⇒ String
Returns e.g. “text”.
33 34 35 |
# File 'lib/omniai/openai/thread/content.rb', line 33 def type @type ||= @data['type'] end |