@@ -325,6 +325,7 @@ class UserTest < ActiveSupport::TestCase
325
325
end
326
326
327
327
describe 'User is AI Judge' do
328
+ let ( :joey ) { users ( :joey ) }
328
329
it 'uses the existence of the key to decide ai_judge' do
329
330
user = User . new
330
331
assert_not user . ai_judge?
@@ -333,13 +334,50 @@ class UserTest < ActiveSupport::TestCase
333
334
assert_not user . valid?
334
335
end
335
336
336
- it 'does not require an email address to be valid when is a judge' do
337
+ it 'does not require an email or password address to be valid when is a judge' do
337
338
user = User . new ( openai_key : '1234' )
338
339
assert user . ai_judge?
339
-
340
- user . password = 'fakeme'
341
340
assert user . valid?
342
341
end
342
+
343
+ describe 'options to configure the llm server' do
344
+ it 'provides an empty hash' do
345
+ user = User . new ( openai_key : '1234' )
346
+ opts_hash = user . judge_options
347
+ assert_equal ( { } , opts_hash )
348
+ end
349
+
350
+ it 'lets you update the options hash' do
351
+ user = User . new ( openai_key : '1234' )
352
+ opts_hash = user . judge_options
353
+
354
+ opts_hash [ :model ] = 'gpt-3.5-turbo'
355
+ assert_equal ( 'gpt-3.5-turbo' , opts_hash [ :model ] )
356
+ user . save!
357
+ user . reload
358
+ assert_equal ( 'gpt-3.5-turbo' , user . judge_options [ :model ] )
359
+ end
360
+
361
+ it 'works with other prexisting options' do
362
+ joey . options = { special_options : { key1 : 'opt1' , key2 : 2 , key3 : true } }
363
+ assert joey . save
364
+ # joey.judge_options[:model] = 'gpt-3.5-turbo'
365
+ # Do not do this, it won't work. You need to work with the full hash
366
+ # joey.judge_options = 'gpt-3.5-turbo'
367
+ judge_options = joey . judge_options
368
+ judge_options [ :model ] = 'gpt-3.5-turbo'
369
+ joey . judge_options = judge_options
370
+ assert joey . save!
371
+ joey . reload
372
+
373
+ puts 'optons'
374
+ puts joey . options
375
+
376
+ judge_options = joey . judge_options
377
+ pp judge_options
378
+ assert_equal ( 'gpt-3.5-turbo' , judge_options [ :model ] )
379
+ end
380
+ end
343
381
end
344
382
345
383
describe 'The full name of the user' do
0 commit comments