mirror of
				https://github.com/deepset-ai/haystack.git
				synced 2025-11-03 19:29:32 +00:00 
			
		
		
		
	fix: Adding api_base_url to OpenAITextEmbeder self assignments (#7004)
				
					
				
			* assigning api_base_url This fix resolves issues with the MistralTextEmbedder integration * adding base url to `to_dict` and the tests * adding release note * Update fix-openai-base-url-assignment-0570a494d88fe365.yaml --------- Co-authored-by: Stefano Fiorucci <stefanofiorucci@gmail.com>
This commit is contained in:
		
							parent
							
								
									6fe1d3b595
								
							
						
					
					
						commit
						e2cee468fc
					
				@ -52,6 +52,7 @@ class OpenAITextEmbedder:
 | 
			
		||||
        """
 | 
			
		||||
        self.model = model
 | 
			
		||||
        self.dimensions = dimensions
 | 
			
		||||
        self.api_base_url = api_base_url
 | 
			
		||||
        self.organization = organization
 | 
			
		||||
        self.prefix = prefix
 | 
			
		||||
        self.suffix = suffix
 | 
			
		||||
@ -69,6 +70,7 @@ class OpenAITextEmbedder:
 | 
			
		||||
        return default_to_dict(
 | 
			
		||||
            self,
 | 
			
		||||
            model=self.model,
 | 
			
		||||
            api_base_url=self.api_base_url,
 | 
			
		||||
            organization=self.organization,
 | 
			
		||||
            prefix=self.prefix,
 | 
			
		||||
            suffix=self.suffix,
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,5 @@
 | 
			
		||||
---
 | 
			
		||||
fixes:
 | 
			
		||||
  - |
 | 
			
		||||
    Adds `api_base_url` attribute to `OpenAITExtEmbedder`.
 | 
			
		||||
    Previously, it was used only for initialization and was not serialized.
 | 
			
		||||
@ -13,6 +13,7 @@ class TestOpenAITextEmbedder:
 | 
			
		||||
 | 
			
		||||
        assert embedder.client.api_key == "fake-api-key"
 | 
			
		||||
        assert embedder.model == "text-embedding-ada-002"
 | 
			
		||||
        assert embedder.api_base_url == None
 | 
			
		||||
        assert embedder.organization is None
 | 
			
		||||
        assert embedder.prefix == ""
 | 
			
		||||
        assert embedder.suffix == ""
 | 
			
		||||
@ -21,12 +22,14 @@ class TestOpenAITextEmbedder:
 | 
			
		||||
        embedder = OpenAITextEmbedder(
 | 
			
		||||
            api_key=Secret.from_token("fake-api-key"),
 | 
			
		||||
            model="model",
 | 
			
		||||
            api_base_url="https://my-custom-base-url.com",
 | 
			
		||||
            organization="fake-organization",
 | 
			
		||||
            prefix="prefix",
 | 
			
		||||
            suffix="suffix",
 | 
			
		||||
        )
 | 
			
		||||
        assert embedder.client.api_key == "fake-api-key"
 | 
			
		||||
        assert embedder.model == "model"
 | 
			
		||||
        assert embedder.api_base_url == "https://my-custom-base-url.com"
 | 
			
		||||
        assert embedder.organization == "fake-organization"
 | 
			
		||||
        assert embedder.prefix == "prefix"
 | 
			
		||||
        assert embedder.suffix == "suffix"
 | 
			
		||||
@ -44,6 +47,7 @@ class TestOpenAITextEmbedder:
 | 
			
		||||
            "type": "haystack.components.embedders.openai_text_embedder.OpenAITextEmbedder",
 | 
			
		||||
            "init_parameters": {
 | 
			
		||||
                "api_key": {"env_vars": ["OPENAI_API_KEY"], "strict": True, "type": "env_var"},
 | 
			
		||||
                "api_base_url": None,
 | 
			
		||||
                "dimensions": None,
 | 
			
		||||
                "model": "text-embedding-ada-002",
 | 
			
		||||
                "organization": None,
 | 
			
		||||
@ -57,6 +61,7 @@ class TestOpenAITextEmbedder:
 | 
			
		||||
        component = OpenAITextEmbedder(
 | 
			
		||||
            api_key=Secret.from_env_var("ENV_VAR", strict=False),
 | 
			
		||||
            model="model",
 | 
			
		||||
            api_base_url="https://my-custom-base-url.com",
 | 
			
		||||
            organization="fake-organization",
 | 
			
		||||
            prefix="prefix",
 | 
			
		||||
            suffix="suffix",
 | 
			
		||||
@ -66,6 +71,7 @@ class TestOpenAITextEmbedder:
 | 
			
		||||
            "type": "haystack.components.embedders.openai_text_embedder.OpenAITextEmbedder",
 | 
			
		||||
            "init_parameters": {
 | 
			
		||||
                "api_key": {"env_vars": ["ENV_VAR"], "strict": False, "type": "env_var"},
 | 
			
		||||
                "api_base_url": "https://my-custom-base-url.com",
 | 
			
		||||
                "model": "model",
 | 
			
		||||
                "dimensions": None,
 | 
			
		||||
                "organization": "fake-organization",
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user