1414 )
1515 end
1616
17-
1817 def create_model_schema ( id_suffix = nil )
1918 model_id = id_suffix ? "test_openai_model_#{ id_suffix } " : "test_openai_model_#{ Time . now . to_i } _#{ rand ( 1000 ) } "
2019 {
2120 'id' => model_id ,
2221 'model_name' => 'openai/gpt-4.1' ,
23- 'api_key' => ENV [ 'OPENAI_API_KEY' ] ,
24- 'max_bytes' => 16000 ,
22+ 'api_key' => ENV . fetch ( 'OPENAI_API_KEY' , nil ) ,
23+ 'max_bytes' => 16_000 ,
2524 'temperature' => 0.0
2625 }
2726 end
@@ -42,12 +41,12 @@ def cleanup_model(model_id)
4241
4342 it 'can create a nl search model' do
4443 model_schema = create_model_schema ( 'create_test' )
45-
44+
4645 begin
4746 response = client . nl_search_models . create ( model_schema )
4847 expect ( response [ 'id' ] ) . to eq ( model_schema [ 'id' ] )
4948 expect ( response [ 'model_name' ] ) . to eq ( 'openai/gpt-4.1' )
50- expect ( response [ 'max_bytes' ] ) . to eq ( 16000 )
49+ expect ( response [ 'max_bytes' ] ) . to eq ( 16_000 )
5150 expect ( response [ 'temperature' ] ) . to eq ( 0.0 )
5251 ensure
5352 cleanup_model ( model_schema [ 'id' ] )
@@ -56,7 +55,7 @@ def cleanup_model(model_id)
5655
5756 it 'can retrieve a specific nl search model' do
5857 model_schema = create_model_schema ( 'retrieve_test' )
59-
58+
6059 begin
6160 client . nl_search_models . create ( model_schema )
6261 response = client . nl_search_models [ model_schema [ 'id' ] ] . retrieve
@@ -69,14 +68,14 @@ def cleanup_model(model_id)
6968
7069 it 'can retrieve all nl search models' do
7170 model_schema = create_model_schema ( 'list_test' )
72-
71+
7372 begin
7473 client . nl_search_models . create ( model_schema )
75-
74+
7675 response = client . nl_search_models . retrieve
7776 expect ( response ) . to be_an ( Array )
7877 expect ( response . length ) . to be >= 1
79-
78+
8079 model_ids = response . map { |model | model [ 'id' ] }
8180 expect ( model_ids ) . to include ( model_schema [ 'id' ] )
8281 ensure
@@ -86,15 +85,15 @@ def cleanup_model(model_id)
8685
8786 it 'can update a nl search model' do
8887 model_schema = create_model_schema ( 'update_test' )
89-
88+
9089 begin
9190 client . nl_search_models . create ( model_schema )
92-
91+
9392 update_schema = {
9493 'temperature' => 0.5 ,
9594 'system_prompt' => 'Updated system prompt for electronics search'
9695 }
97-
96+
9897 response = client . nl_search_models [ model_schema [ 'id' ] ] . update ( update_schema )
9998 expect ( response [ 'temperature' ] ) . to eq ( 0.5 )
10099 expect ( response [ 'system_prompt' ] ) . to eq ( 'Updated system prompt for electronics search' )
@@ -105,14 +104,14 @@ def cleanup_model(model_id)
105104
106105 it 'can delete a nl search model' do
107106 model_schema = create_model_schema ( 'delete_test' )
108-
107+
109108 client . nl_search_models . create ( model_schema )
110-
109+
111110 response = client . nl_search_models [ model_schema [ 'id' ] ] . delete
112111 expect ( response [ 'id' ] ) . to eq ( model_schema [ 'id' ] )
113-
114- expect {
112+
113+ expect do
115114 client . nl_search_models [ model_schema [ 'id' ] ] . retrieve
116- } . to raise_error ( Typesense ::Error ::ObjectNotFound )
115+ end . to raise_error ( Typesense ::Error ::ObjectNotFound )
117116 end
118- end
117+ end
0 commit comments