File: finetunes.rb

package info (click to toggle)
ruby-ruby-openai 3.7.0-2.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 200 kB
  • sloc: ruby: 243; makefile: 4; sh: 4
file content (36 lines) | stat: -rw-r--r-- 966 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
module OpenAI
  class Finetunes
    def initialize(access_token: nil, organization_id: nil)
      OpenAI.configuration.access_token = access_token if access_token
      OpenAI.configuration.organization_id = organization_id if organization_id
    end

    def list
      OpenAI::Client.get(path: "/fine-tunes")
    end

    def create(parameters: {})
      OpenAI::Client.json_post(path: "/fine-tunes", parameters: parameters)
    end

    def retrieve(id:)
      OpenAI::Client.get(path: "/fine-tunes/#{id}")
    end

    def cancel(id:)
      OpenAI::Client.multipart_post(path: "/fine-tunes/#{id}/cancel")
    end

    def events(id:)
      OpenAI::Client.get(path: "/fine-tunes/#{id}/events")
    end

    def delete(fine_tuned_model:)
      if fine_tuned_model.start_with?("ft-")
        raise ArgumentError, "Please give a fine_tuned_model name, not a fine-tune ID"
      end

      OpenAI::Client.delete(path: "/models/#{fine_tuned_model}")
    end
  end
end