Class: BddOpenai::Mapper::File

Inherits:
Object
  • Object
show all
Defined in:
lib/bdd_openai/mappers/file.rb

Overview

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ File

Returns a new instance of File.



36
37
38
39
40
# File 'lib/bdd_openai/mappers/file.rb', line 36

def initialize(**args)
  args.each do |k, v|
    instance_variable_set("@#{k}", v) unless v.nil?
  end
end

Instance Attribute Details

#bytesInteger

Returns The size of the file, in bytes.

Returns:

  • (Integer)

    The size of the file, in bytes.



13
14
15
# File 'lib/bdd_openai/mappers/file.rb', line 13

def bytes
  @bytes
end

#created_atInteger

Returns The Unix timestamp (in seconds) for when the file was created.

Returns:

  • (Integer)

    The Unix timestamp (in seconds) for when the file was created.



15
16
17
# File 'lib/bdd_openai/mappers/file.rb', line 15

def created_at
  @created_at
end

#filenameString

Returns The name of the file.

Returns:

  • (String)

    The name of the file.



17
18
19
# File 'lib/bdd_openai/mappers/file.rb', line 17

def filename
  @filename
end

#idString

Returns The file identifier, which can be referenced in the API endpoints.

Returns:

  • (String)

    The file identifier, which can be referenced in the API endpoints.



11
12
13
# File 'lib/bdd_openai/mappers/file.rb', line 11

def id
  @id
end

#objectString

Returns The object type, which is always “file”.

Returns:

  • (String)

    The object type, which is always “file”.



19
20
21
# File 'lib/bdd_openai/mappers/file.rb', line 19

def object
  @object
end

#purposeString

Returns The intended purpose of the file. Supported values are \ “fine-tune”, “fine-tune-results”, “assistants”, and “assistants_output”.

Returns:

  • (String)

    The intended purpose of the file. Supported values are \ “fine-tune”, “fine-tune-results”, “assistants”, and “assistants_output”.



22
23
24
# File 'lib/bdd_openai/mappers/file.rb', line 22

def purpose
  @purpose
end

Class Method Details

.from_json(json_string) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/bdd_openai/mappers/file.rb', line 24

def self.from_json(json_string)
  data = JSON.parse(json_string)
  new(
    id: data['id'],
    bytes: data['bytes'],
    created_at: data['created_at'],
    filename: data['filename'],
    object: data['object'],
    purpose: data['purpose']
  )
end