Class: OmniAI::OpenAI::Thread::Attachment
- Inherits:
-
Object
- Object
- OmniAI::OpenAI::Thread::Attachment
- Defined in:
- lib/omniai/openai/thread/attachment.rb
Overview
An OpenAI attachment.
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
- #file! ⇒ OmniAI::OpenAI::File
-
#file_id ⇒ String
E.g.
-
#initialize(data:, client: Client.new) ⇒ Attachment
constructor
A new instance of Attachment.
- #tools ⇒ Array<Hash>
Constructor Details
#initialize(data:, client: Client.new) ⇒ Attachment
Returns a new instance of Attachment.
24 25 26 27 |
# File 'lib/omniai/openai/thread/attachment.rb', line 24 def initialize(data:, client: Client.new) @data = data @client = client end |
Instance Attribute Details
#data ⇒ Hash?
10 11 12 |
# File 'lib/omniai/openai/thread/attachment.rb', line 10 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/attachment.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
#file! ⇒ OmniAI::OpenAI::File
40 41 42 |
# File 'lib/omniai/openai/thread/attachment.rb', line 40 def file! @file ||= @client.files.find(id: file_id) end |
#file_id ⇒ String
Returns e.g. “text”.
30 31 32 |
# File 'lib/omniai/openai/thread/attachment.rb', line 30 def file_id @file_id ||= @data['file_id'] end |
#tools ⇒ Array<Hash>
35 36 37 |
# File 'lib/omniai/openai/thread/attachment.rb', line 35 def tools @tools ||= @data['tools'] end |