Class: RubyLLM::Protocols::Gemini::Files
- Inherits:
-
Protocols::Files
- Object
- Protocols::Files
- RubyLLM::Protocols::Gemini::Files
- Defined in:
- lib/ruby_llm/protocols/gemini/files.rb
Overview
Gemini Files API.
Constant Summary collapse
- PROCESSING_POLL_INTERVAL =
2- PROCESSING_TIMEOUT =
600
Instance Method Summary collapse
- #download(file_id) ⇒ Object
-
#upload(file, filename: nil, purpose: nil, expires_in: nil, uri: nil, content_type: nil, provider_options: {}) ⇒ Object
rubocop:disable-next Lint/UnusedMethodArgument.
Instance Method Details
#download(file_id) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/ruby_llm/protocols/gemini/files.rb', line 21 def download(file_id) file = find(file_id) download_uri = file.['downloadUri'] raise Error, 'gemini file has no download URI' unless download_uri gemini_connection(request_json: false, response_json: false).get(download_uri) do |request| request.headers.merge!(@provider.headers) end.body end |
#upload(file, filename: nil, purpose: nil, expires_in: nil, uri: nil, content_type: nil, provider_options: {}) ⇒ Object
rubocop:disable-next Lint/UnusedMethodArgument
12 13 14 15 16 17 18 19 |
# File 'lib/ruby_llm/protocols/gemini/files.rb', line 12 def upload(file, filename: nil, purpose: nil, expires_in: nil, uri: nil, content_type: nil, provider_options: {}) = (file, filename:) display_name = [:display_name] || .filename upload_url = start_resumable_upload(, display_name:) response = upload_file_bytes(upload_url, ) await_active(parse_file_response(response.body.fetch('file'))) end |