feat: adds model selection to Azure OpenAI Embeddings component (#3882)

Right now the Azure OpenAI Embeddings component doesn't allow you to pick the embedding model to use. The same models are available that OpenAI make available, so I used the constant that lists them to pull from.
This commit is contained in:
Phil Nash 2024-09-26 12:29:04 +01:00 committed by GitHub
commit 7a01cf7e5b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View file

@ -83,6 +83,7 @@ This component generates embeddings using Azure OpenAI models.
| Name | Type | Description |
|------|------|-------------|
| Model | String | Name of the model to use (default: `text-embedding-3-small`) |
| Azure Endpoint | String | Your Azure endpoint, including the resource. Example: `https://example-resource.azure.openai.com/` |
| Deployment Name | String | The name of the deployment |
| API Version | String | The API version to use, options include various dates |

View file

@ -1,6 +1,7 @@
from langchain_openai import AzureOpenAIEmbeddings
from langflow.base.models.model import LCModelComponent
from langflow.base.models.openai_constants import OPENAI_EMBEDDING_MODEL_NAMES
from langflow.field_typing import Embeddings
from langflow.io import DropdownInput, IntInput, MessageTextInput, Output, SecretStrInput
@ -22,6 +23,13 @@ class AzureOpenAIEmbeddingsComponent(LCModelComponent):
]
inputs = [
DropdownInput(
name="model",
display_name="Model",
advanced=False,
options=OPENAI_EMBEDDING_MODEL_NAMES,
value=OPENAI_EMBEDDING_MODEL_NAMES[0],
),
MessageTextInput(
name="azure_endpoint",
display_name="Azure Endpoint",
@ -60,6 +68,7 @@ class AzureOpenAIEmbeddingsComponent(LCModelComponent):
def build_embeddings(self) -> Embeddings:
try:
embeddings = AzureOpenAIEmbeddings(
model=self.model,
azure_endpoint=self.azure_endpoint,
azure_deployment=self.azure_deployment,
api_version=self.api_version,