Class: OmniAI::OpenAI::Thread::Text
- Inherits:
-
Object
- Object
- OmniAI::OpenAI::Thread::Text
- Defined in:
- lib/omniai/openai/thread/text.rb
Overview
An OpenAI text w/ annotations.
Instance Attribute Summary collapse
Instance Method Summary collapse
- #annotate! ⇒ String
- #annotations ⇒ Array<OmniAI::OpenAI::Thread::Annotation>
-
#initialize(data:, client:) ⇒ Text
constructor
A new instance of Text.
-
#type ⇒ String
E.g.
- #value ⇒ String
Constructor Details
#initialize(data:, client:) ⇒ Text
Returns a new instance of Text.
14 15 16 17 |
# File 'lib/omniai/openai/thread/text.rb', line 14 def initialize(data:, client:) @data = data @client = client end |
Instance Attribute Details
#data ⇒ Hash?
10 11 12 |
# File 'lib/omniai/openai/thread/text.rb', line 10 def data @data end |
Instance Method Details
#annotate! ⇒ String
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/omniai/openai/thread/text.rb', line 20 def annotate! text = value annotations.each do |annotation| file = annotation.file! text = text.gsub(annotation.text, "[#{file.filename}:#{annotation.range}]") end text end |
#annotations ⇒ Array<OmniAI::OpenAI::Thread::Annotation>
42 43 44 |
# File 'lib/omniai/openai/thread/text.rb', line 42 def annotations @annotations ||= @data['annotations'].map { |data| Annotation.new(data:, client: @client) } end |
#type ⇒ String
Returns e.g. “text”.
32 33 34 |
# File 'lib/omniai/openai/thread/text.rb', line 32 def type @data['type'] end |
#value ⇒ String
37 38 39 |
# File 'lib/omniai/openai/thread/text.rb', line 37 def value @data['value'] end |