@@ -26,7 +26,7 @@ class VoyageAIEmbeddingConfig(EmbeddingConfig):
2626 le = 128 ,
2727 description = "Batch size for embedding requests. VoyageAI has a limit of 128." ,
2828 )
29- api_key : SecretStr = Field (description = "API key for VoyageAI" )
29+ api_key : Optional [ SecretStr ] = Field (description = "API key for VoyageAI" , default = None )
3030 embedder_model_name : str = Field (
3131 default = "voyage-3" , alias = "model_name" , description = "VoyageAI model name"
3232 )
@@ -65,8 +65,9 @@ def get_client(self) -> "VoyageAIClient":
6565 """Creates a VoyageAI python client to embed elements."""
6666 from voyageai import Client as VoyageAIClient
6767
68+ api_key = self .api_key .get_secret_value () if self .api_key else None
6869 client = VoyageAIClient (
69- api_key = self . api_key . get_secret_value () ,
70+ api_key = api_key ,
7071 max_retries = self .max_retries ,
7172 timeout = self .timeout_in_seconds ,
7273 )
@@ -80,8 +81,9 @@ def get_async_client(self) -> "AsyncVoyageAIClient":
8081 """Creates a VoyageAI python client to embed elements."""
8182 from voyageai import AsyncClient as AsyncVoyageAIClient
8283
84+ api_key = self .api_key .get_secret_value () if self .api_key else None
8385 client = AsyncVoyageAIClient (
84- api_key = self . api_key . get_secret_value () ,
86+ api_key = api_key ,
8587 max_retries = self .max_retries ,
8688 timeout = self .timeout_in_seconds ,
8789 )
0 commit comments