Module: Ollama::Utils::FileArgument

Defined in:
lib/ollama/utils/file_argument.rb

Class Method Summary collapse

Class Method Details

.get_file_argument(path_or_content, default: nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/ollama/utils/file_argument.rb', line 4

def get_file_argument(path_or_content, default: nil)
  if path_or_content.present? && path_or_content.size < 2 ** 15 &&
      File.basename(path_or_content).size < 2 ** 8 &&
      File.exist?(path_or_content)
    then
    File.read(path_or_content)
  elsif path_or_content.present?
    path_or_content
  else
    default
  end
end