mirror of
https://github.com/langflow-ai/langflow.git
synced 2026-07-23 22:44:41 +08:00
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:
@ -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 |
|
||||
|
||||
@ -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,
|
||||
|
||||
Reference in New Issue
Block a user