|
6 | 6 | include_context 'with configured RubyLLM' |
7 | 7 |
|
8 | 8 | let(:image_path) { File.expand_path('../fixtures/ruby.png', __dir__) } |
| 9 | + let(:video_path) { File.expand_path('../fixtures/ruby.mp4', __dir__) } |
9 | 10 | let(:audio_path) { File.expand_path('../fixtures/ruby.wav', __dir__) } |
10 | 11 | let(:mp3_path) { File.expand_path('../fixtures/ruby.mp3', __dir__) } |
11 | 12 | let(:pdf_path) { File.expand_path('../fixtures/sample.pdf', __dir__) } |
12 | 13 | let(:text_path) { File.expand_path('../fixtures/ruby.txt', __dir__) } |
13 | 14 | let(:xml_path) { File.expand_path('../fixtures/ruby.xml', __dir__) } |
14 | 15 | let(:image_url) { 'https://upload.wikimedia.org/wikipedia/commons/f/f1/Ruby_logo.png' } |
| 16 | + let(:video_url) { 'https://filesamples.com/samples/video/mp4/sample_640x360.mp4' } |
15 | 17 | let(:audio_url) { 'https://commons.wikimedia.org/wiki/File:LL-Q1860_(eng)-AcpoKrane-ruby.wav' } |
16 | 18 | let(:pdf_url) { 'https://pdfobject.com/pdf/sample.pdf' } |
17 | 19 | let(:text_url) { 'https://www.ruby-lang.org/en/about/license.txt' } |
|
96 | 98 | end |
97 | 99 | end |
98 | 100 |
|
| 101 | + describe 'video models' do # rubocop:disable RSpec/MultipleMemoizedHelpers |
| 102 | + VIDEO_MODELS.each do |model_info| |
| 103 | + provider = model_info[:provider] |
| 104 | + model = model_info[:model] |
| 105 | + |
| 106 | + it "#{provider}/#{model} can understand local videos" do # rubocop:disable RSpec/MultipleExpectations,RSpec/ExampleLength |
| 107 | + chat = RubyLLM.chat(model: model, provider: provider) |
| 108 | + response = chat.ask('What do you see in this video?', with: { video: video_path }) |
| 109 | + |
| 110 | + expect(response.content).to be_present |
| 111 | + expect(response.content).not_to include('RubyLLM::Content') |
| 112 | + expect(chat.messages.first.content).to be_a(RubyLLM::Content) |
| 113 | + expect(chat.messages.first.content.attachments.first.filename).to eq('ruby.mp4') |
| 114 | + expect(chat.messages.first.content.attachments.first.mime_type).to eq('video/mp4') |
| 115 | + end |
| 116 | + |
| 117 | + it "#{provider}/#{model} can understand remote videos without extension" do # rubocop:disable RSpec/MultipleExpectations,RSpec/ExampleLength |
| 118 | + chat = RubyLLM.chat(model: model, provider: provider) |
| 119 | + response = chat.ask('What do you see in this video?', with: video_url) |
| 120 | + |
| 121 | + expect(response.content).to be_present |
| 122 | + expect(response.content).not_to include('RubyLLM::Content') |
| 123 | + expect(chat.messages.first.content).to be_a(RubyLLM::Content) |
| 124 | + expect(chat.messages.first.content.attachments.first.filename).to eq('sample_640x360.mp4') |
| 125 | + expect(chat.messages.first.content.attachments.first.mime_type).to eq('video/mp4') |
| 126 | + end |
| 127 | + end |
| 128 | + end |
| 129 | + |
99 | 130 | describe 'audio models' do # rubocop:disable RSpec/MultipleMemoizedHelpers |
100 | 131 | AUDIO_MODELS.each do |model_info| |
101 | 132 | model = model_info[:model] |
|
0 commit comments