Class: Legion::CLI::Image
- Inherits:
-
Thor
- Object
- Thor
- Legion::CLI::Image
- Defined in:
- lib/legion/cli/image_command.rb
Constant Summary collapse
- SUPPORTED_TYPES =
%w[png jpg jpeg gif webp].freeze
- MIME_TYPES =
{ 'png' => 'image/png', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'gif' => 'image/gif', 'webp' => 'image/webp' }.freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.exit_on_failure? ⇒ Boolean
9 10 11 |
# File 'lib/legion/cli/image_command.rb', line 9 def self.exit_on_failure? true end |
Instance Method Details
#analyze(path) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/legion/cli/image_command.rb', line 35 def analyze(path) out = formatter setup_connection(out) image_data = load_image(path, out) return unless image_data = [([image_data], [:prompt])] response = call_llm(, out) return unless response render_response(out, response, { path: path, prompt: [:prompt] }) rescue CLI::Error => e formatter.error(e.) raise SystemExit, 1 ensure Connection.shutdown end |
#compare(path1, path2) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/legion/cli/image_command.rb', line 61 def compare(path1, path2) out = formatter setup_connection(out) image1 = load_image(path1, out) return unless image1 image2 = load_image(path2, out) return unless image2 = [([image1, image2], [:prompt])] response = call_llm(, out) return unless response render_response(out, response, { path1: path1, path2: path2, prompt: [:prompt] }) rescue CLI::Error => e formatter.error(e.) raise SystemExit, 1 ensure Connection.shutdown end |