File tree 2 files changed +24
-0
lines changed
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 32
32
end
33
33
end
34
34
end
35
+
36
+ describe 'embedding with per-request key' do
37
+ let ( :override_openai_key ) { ENV . fetch ( 'OTHER_OPENAI_API_KEY' , nil ) }
38
+
39
+ it 'embeds text using an overridden key' do # rubocop:disable RSpec/MultipleExpectations
40
+ embedding = RubyLLM . embed ( "What's your favorite algorithm?" ,
41
+ api_key : override_openai_key )
42
+
43
+ expect ( embedding ) . to be_a ( RubyLLM ::Embedding )
44
+ expect ( embedding . vectors ) . to be_an ( Array )
45
+ end
46
+ end
35
47
end
Original file line number Diff line number Diff line change @@ -65,4 +65,16 @@ def save_and_verify_image(image) # rubocop:disable Metrics/MethodLength
65
65
end . to raise_error ( RubyLLM ::ModelNotFoundError )
66
66
end
67
67
end
68
+
69
+ describe 'painting with per-request key' do
70
+ let ( :override_openai_key ) { ENV . fetch ( 'OTHER_OPENAI_API_KEY' , nil ) }
71
+
72
+ it 'generates an image using an overridden key' do # rubocop:disable RSpec/MultipleExpectations
73
+ image = RubyLLM . paint ( 'A sunset in watercolor style' , api_key : override_openai_key )
74
+ expect ( image ) . to be_a ( RubyLLM ::Image )
75
+ expect ( image . url ) . to match ( %r{^https?://} )
76
+
77
+ save_and_verify_image image
78
+ end
79
+ end
68
80
end
You can’t perform that action at this time.
0 commit comments