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:
parent
106a34d2ff
commit
7a01cf7e5b
2 changed files with 10 additions and 0 deletions
|
|
@ -83,6 +83,7 @@ This component generates embeddings using Azure OpenAI models.
|
||||||
|
|
||||||
| Name | Type | Description |
|
| 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/` |
|
| Azure Endpoint | String | Your Azure endpoint, including the resource. Example: `https://example-resource.azure.openai.com/` |
|
||||||
| Deployment Name | String | The name of the deployment |
|
| Deployment Name | String | The name of the deployment |
|
||||||
| API Version | String | The API version to use, options include various dates |
|
| API Version | String | The API version to use, options include various dates |
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
from langchain_openai import AzureOpenAIEmbeddings
|
from langchain_openai import AzureOpenAIEmbeddings
|
||||||
|
|
||||||
from langflow.base.models.model import LCModelComponent
|
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.field_typing import Embeddings
|
||||||
from langflow.io import DropdownInput, IntInput, MessageTextInput, Output, SecretStrInput
|
from langflow.io import DropdownInput, IntInput, MessageTextInput, Output, SecretStrInput
|
||||||
|
|
||||||
|
|
@ -22,6 +23,13 @@ class AzureOpenAIEmbeddingsComponent(LCModelComponent):
|
||||||
]
|
]
|
||||||
|
|
||||||
inputs = [
|
inputs = [
|
||||||
|
DropdownInput(
|
||||||
|
name="model",
|
||||||
|
display_name="Model",
|
||||||
|
advanced=False,
|
||||||
|
options=OPENAI_EMBEDDING_MODEL_NAMES,
|
||||||
|
value=OPENAI_EMBEDDING_MODEL_NAMES[0],
|
||||||
|
),
|
||||||
MessageTextInput(
|
MessageTextInput(
|
||||||
name="azure_endpoint",
|
name="azure_endpoint",
|
||||||
display_name="Azure Endpoint",
|
display_name="Azure Endpoint",
|
||||||
|
|
@ -60,6 +68,7 @@ class AzureOpenAIEmbeddingsComponent(LCModelComponent):
|
||||||
def build_embeddings(self) -> Embeddings:
|
def build_embeddings(self) -> Embeddings:
|
||||||
try:
|
try:
|
||||||
embeddings = AzureOpenAIEmbeddings(
|
embeddings = AzureOpenAIEmbeddings(
|
||||||
|
model=self.model,
|
||||||
azure_endpoint=self.azure_endpoint,
|
azure_endpoint=self.azure_endpoint,
|
||||||
azure_deployment=self.azure_deployment,
|
azure_deployment=self.azure_deployment,
|
||||||
api_version=self.api_version,
|
api_version=self.api_version,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue