Class: OmniAI::OpenAI::Thread::Annotation

Inherits:
Object
  • Object
show all
Defined in:
lib/omniai/openai/thread/annotation.rb

Overview

An OpenAI content w/ annotations.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data:, client: Client.new) ⇒ Annotation

Returns a new instance of Annotation.

Parameters:



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

#dataHash?

Returns:

  • (Hash, nil)


10
11
12
# File 'lib/omniai/openai/thread/annotation.rb', line 10

def data
  @data
end

Instance Method Details

#end_indexInteger

Returns:

  • (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”.

Returns:



52
53
54
# File 'lib/omniai/openai/thread/annotation.rb', line 52

def file!
  @file ||= @client.files.find(id: file_id)
end

#file_idString

Returns:

  • (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

#rangeRange<Integer>

Returns:

  • (Range<Integer>)


40
41
42
# File 'lib/omniai/openai/thread/annotation.rb', line 40

def range
  start_index..end_index
end

#start_indexInteger

Returns:

  • (Integer)


30
31
32
# File 'lib/omniai/openai/thread/annotation.rb', line 30

def start_index
  @data['start_index']
end

#textString

Returns:

  • (String)


25
26
27
# File 'lib/omniai/openai/thread/annotation.rb', line 25

def text
  @data['text']
end

#typeString

Returns “file_citation” or “file_path”.

Returns:

  • (String)

    “file_citation” or “file_path”



20
21
22
# File 'lib/omniai/openai/thread/annotation.rb', line 20

def type
  @data['type']
end