Sha256: d6562075c6af7bcfb8bbb53a6470a74b80fe59fc3954ee092edf6ff8e2075641
Contents?: true
Size: 1 KB
Versions: 1
Compression:
Stored size: 1 KB
Contents
# frozen_string_literal: true require_relative 'base' module BddOpenai module Services module Files class Upload < Base # @param purpose [String] The intended purpose of the file. One of: "fine-tune", "assistants". # @param file_path [String] The path of the file to upload.rb # @return [BddOpenai::Mapper::File, BddOpenai::ErrorResponse] def upload_files(purpose, file_path) uri = URI.parse("#{@openai_api_domain}/files") body, boundary = @http_client.create_multipart_body({ purpose: purpose }, { file: file_path }) headers = default_headers .merge({ "Content-Type": "multipart/form-data; boundary=#{boundary}" }) response = @http_client.call_post(uri, body, headers) return BddOpenai::ErrorResponse.from_json(response.body) unless response.code == '200' BddOpenai::Mapper::File.from_json(response.body) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bdd_openai-1.1.0 | lib/bdd_openai/services/files/upload.rb |