@@ -20,7 +20,6 @@ def openai_backend_config():
2020 """Create an OpenAI backend config for testing."""
2121 return OpenaiEmbeddingConfig (
2222 model_name = "text-embedding-3-small" ,
23- api_key = os .getenv ("OPENAI_API_KEY" ),
2423 batch_size = 2 ,
2524 use_cache = False ,
2625 max_retries = 1 ,
@@ -83,11 +82,9 @@ def test_different_models_different_hashes(self):
8382 """Test that different models produce different hashes."""
8483 config1 = OpenaiEmbeddingConfig (
8584 model_name = "text-embedding-3-small" ,
86- api_key = os .getenv ("OPENAI_API_KEY" ),
8785 )
8886 config2 = OpenaiEmbeddingConfig (
8987 model_name = "text-embedding-ada-002" ,
90- api_key = os .getenv ("OPENAI_API_KEY" ),
9188 )
9289
9390 backend1 = OpenaiEmbeddingBackend (config1 )
@@ -100,7 +97,6 @@ def test_dimensions_parameter(self):
10097 # Test with different dimensions (if supported by model)
10198 config_with_dims = OpenaiEmbeddingConfig (
10299 model_name = "text-embedding-3-small" ,
103- api_key = os .getenv ("OPENAI_API_KEY" ),
104100 dimensions = 512 , # Reduced dimensions
105101 use_cache = False ,
106102 )
@@ -126,7 +122,6 @@ def test_async_processing_initialization(self):
126122 """Test async processing initialization."""
127123 config = OpenaiEmbeddingConfig (
128124 model_name = "text-embedding-3-small" ,
129- api_key = os .getenv ("OPENAI_API_KEY" ),
130125 max_concurrent = 2 , # Enable async processing
131126 max_per_second = 1.0 ,
132127 use_cache = False ,
@@ -142,7 +137,6 @@ def test_prompts_application(self):
142137 """Test that prompts are applied correctly."""
143138 config = OpenaiEmbeddingConfig (
144139 model_name = "text-embedding-3-small" ,
145- api_key = os .getenv ("OPENAI_API_KEY" ),
146140 query_prompt = "Query:" ,
147141 passage_prompt = "Passage:" ,
148142 use_cache = False ,
@@ -160,20 +154,6 @@ def test_prompts_application(self):
160154 # Embeddings should be different when prompts are applied
161155 assert not np .allclose (embeddings_no_prompt , embeddings_with_prompt , rtol = 1e-3 )
162156
163- def test_error_handling_invalid_api_key (self ):
164- """Test error handling with invalid API key."""
165- config = OpenaiEmbeddingConfig (
166- model_name = "text-embedding-3-small" ,
167- api_key = "invalid-key" ,
168- max_retries = 0 , # Don't retry
169- timeout = 5.0 ,
170- )
171-
172- backend = OpenaiEmbeddingBackend (config )
173-
174- with pytest .raises (RuntimeError , match = "Error calling OpenAI API" ):
175- backend .embed (["Test sentence" ])
176-
177157 def test_return_tensors_functionality (self , openai_backend : OpenaiEmbeddingBackend ):
178158 """Test return_tensors parameter."""
179159 utterances = ["Hello world" , "Test sentence" ]
0 commit comments