@@ -535,6 +535,31 @@ def test_embedding_batch(self):
535535 self .assertTrue (len (response .data [0 ].embedding ) > 0 )
536536 self .assertTrue (len (response .data [1 ].embedding ) > 0 )
537537
538+ def test_embedding_single_batch_str (self ):
539+ """Test embedding with a List[str] and length equals to 1"""
540+ client = openai .Client (api_key = self .api_key , base_url = self .base_url )
541+ response = client .embeddings .create (model = self .model , input = ["Hello world" ])
542+ self .assertEqual (len (response .data ), 1 )
543+ self .assertTrue (len (response .data [0 ].embedding ) > 0 )
544+
545+ def test_embedding_single_int_list (self ):
546+ """Test embedding with a List[int] or List[List[int]]]"""
547+ client = openai .Client (api_key = self .api_key , base_url = self .base_url )
548+ response = client .embeddings .create (
549+ model = self .model ,
550+ input = [[15339 , 314 , 703 , 284 , 612 , 262 , 10658 , 10188 , 286 , 2061 ]],
551+ )
552+ self .assertEqual (len (response .data ), 1 )
553+ self .assertTrue (len (response .data [0 ].embedding ) > 0 )
554+
555+ client = openai .Client (api_key = self .api_key , base_url = self .base_url )
556+ response = client .embeddings .create (
557+ model = self .model ,
558+ input = [15339 , 314 , 703 , 284 , 612 , 262 , 10658 , 10188 , 286 , 2061 ],
559+ )
560+ self .assertEqual (len (response .data ), 1 )
561+ self .assertTrue (len (response .data [0 ].embedding ) > 0 )
562+
538563 def test_empty_string_embedding (self ):
539564 """Test embedding an empty string."""
540565
0 commit comments