Class: OmniAI::OpenAI::Thread::Annotation
- Inherits:
-
Object
- Object
- OmniAI::OpenAI::Thread::Annotation
- Defined in:
- lib/omniai/openai/thread/annotation.rb
Overview
An OpenAI content w/ annotations.
Instance Attribute Summary collapse
Instance Method Summary collapse
- #end_index ⇒ Integer
-
#file! ⇒ OmniAI::OpenAI::File?
Present if type is “file_citation” or “file_path”.
- #file_id ⇒ String
-
#initialize(data:, client: Client.new) ⇒ Annotation
constructor
A new instance of Annotation.
- #range ⇒ Range<Integer>
- #start_index ⇒ Integer
- #text ⇒ String
-
#type ⇒ String
“file_citation” or “file_path”.
Constructor Details
#initialize(data:, client: Client.new) ⇒ Annotation
Returns a new instance of Annotation.
14 15 16 17 |
# File 'lib/omniai/openai/thread/annotation.rb', line 14 def initialize(data:, client: Client.new) @data = data @client = client end |
Instance Attribute Details
#data ⇒ Hash?
10 11 12 |
# File 'lib/omniai/openai/thread/annotation.rb', line 10 def data @data end |
Instance Method Details
#end_index ⇒ Integer
35 36 37 |
# File 'lib/omniai/openai/thread/annotation.rb', line 35 def end_index @data['end_index'] end |
#file! ⇒ OmniAI::OpenAI::File?
Present if type is “file_citation” or “file_path”.
52 53 54 |
# File 'lib/omniai/openai/thread/annotation.rb', line 52 def file! @file ||= @client.files.find(id: file_id) end |
#file_id ⇒ String
45 46 47 |
# File 'lib/omniai/openai/thread/annotation.rb', line 45 def file_id @file_id ||= (@data['file_citation'] || @data['file_path'])['file_id'] end |
#range ⇒ Range<Integer>
40 41 42 |
# File 'lib/omniai/openai/thread/annotation.rb', line 40 def range start_index..end_index end |
#start_index ⇒ Integer
30 31 32 |
# File 'lib/omniai/openai/thread/annotation.rb', line 30 def start_index @data['start_index'] end |
#text ⇒ String
25 26 27 |
# File 'lib/omniai/openai/thread/annotation.rb', line 25 def text @data['text'] end |
#type ⇒ String
Returns “file_citation” or “file_path”.
20 21 22 |
# File 'lib/omniai/openai/thread/annotation.rb', line 20 def type @data['type'] end |