Module: RubyLLM::Providers::Voyage::Files Private
- Defined in:
- lib/ruby_llm/providers/voyage/files.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Voyage Files API operations.
Instance Method Summary collapse
-
#delete_files(file_ids) ⇒ RubyLLM::Voyage::FileDeletion
private
Atomically deletes one or more files.
-
#file_content(file_id) ⇒ String
private
Downloads raw file content.
-
#list_files(purpose: nil, limit: nil, order: nil, after: nil) ⇒ RubyLLM::Voyage::Page
private
Lists file metadata with cursor pagination.
-
#retrieve_file(file_id) ⇒ RubyLLM::Voyage::VoyageFile
private
Retrieves file metadata.
-
#upload_file(path, purpose: 'batch') ⇒ RubyLLM::Voyage::VoyageFile
private
Uploads one JSONL file.
Instance Method Details
#delete_files(file_ids) ⇒ RubyLLM::Voyage::FileDeletion
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Atomically deletes one or more files. Voyage treats the operation
as all-or-nothing and reports the outcome in a success field,
with error_file_ids available in raw on failure.
64 65 66 67 68 |
# File 'lib/ruby_llm/providers/voyage/files.rb', line 64 def delete_files(file_ids) body = @connection.post('files/delete', { file_ids: file_ids }).body deleted = body.is_a?(Hash) && body.key?('success') ? body['success'] : true RubyLLM::Voyage::FileDeletion.new(file_ids: file_ids, deleted: deleted, raw: body) end |
#file_content(file_id) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Downloads raw file content.
50 51 52 53 54 55 56 57 |
# File 'lib/ruby_llm/providers/voyage/files.rb', line 50 def file_content(file_id) response = @connection.get("files/#{escape_id(file_id)}/content") do |request| request.headers['Accept'] = 'text/plain' end return response.body unless response.status.between?(300, 399) download_redirect(response.headers['location']) end |
#list_files(purpose: nil, limit: nil, order: nil, after: nil) ⇒ RubyLLM::Voyage::Page
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Lists file metadata with cursor pagination.
41 42 43 44 45 |
# File 'lib/ruby_llm/providers/voyage/files.rb', line 41 def list_files(purpose: nil, limit: nil, order: nil, after: nil) query = URI.encode_www_form({ purpose: purpose, limit: limit, order: order, after: after }.compact) path = query.empty? ? 'files' : "files?#{query}" parse_page(@connection.get(path).body) { |item| parse_file(item) } end |
#retrieve_file(file_id) ⇒ RubyLLM::Voyage::VoyageFile
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Retrieves file metadata.
35 36 37 |
# File 'lib/ruby_llm/providers/voyage/files.rb', line 35 def retrieve_file(file_id) parse_file(@connection.get("files/#{escape_id(file_id)}").body) end |
#upload_file(path, purpose: 'batch') ⇒ RubyLLM::Voyage::VoyageFile
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Uploads one JSONL file.
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ruby_llm/providers/voyage/files.rb', line 19 def upload_file(path, purpose: 'batch') = File.(path) unless File.extname().casecmp?('.jsonl') raise ArgumentError, 'Voyage file uploads must use the .jsonl extension' end # RubyLLM's connection stack loads faraday-multipart and uses this # same class for its own uploads; 1.x has no public helper for it. part = Faraday::Multipart::FilePart.new(, 'application/jsonl', File.basename()) response = @connection.post('files', { file: part, purpose: purpose }) parse_file(response.body) end |