refactor: Update VertexAIEmbeddingsComponent to use Embeddings field type
Update the VertexAIEmbeddingsComponent to use the `Embeddings` field type instead of importing it from `langchain_google_vertexai`. This ensures compatibility with the latest version of the langflow library and improves code readability.
This commit is contained in:
parent
5400f61447
commit
c40188f6b6
1 changed files with 9 additions and 3 deletions
|
|
@ -1,8 +1,7 @@
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from langchain_google_vertexai import VertexAIEmbeddings
|
|
||||||
|
|
||||||
from langflow.custom import CustomComponent
|
from langflow.custom import CustomComponent
|
||||||
|
from langflow.field_typing import Embeddings
|
||||||
|
|
||||||
|
|
||||||
class VertexAIEmbeddingsComponent(CustomComponent):
|
class VertexAIEmbeddingsComponent(CustomComponent):
|
||||||
|
|
@ -71,7 +70,14 @@ class VertexAIEmbeddingsComponent(CustomComponent):
|
||||||
temperature: float = 0.0,
|
temperature: float = 0.0,
|
||||||
top_k: int = 40,
|
top_k: int = 40,
|
||||||
top_p: float = 0.95,
|
top_p: float = 0.95,
|
||||||
) -> VertexAIEmbeddings:
|
) -> Embeddings:
|
||||||
|
try:
|
||||||
|
from langchain_google_vertexai import VertexAIEmbeddings
|
||||||
|
except ImportError:
|
||||||
|
raise ImportError(
|
||||||
|
"Please install the langchain-google-vertexai package to use the VertexAIEmbeddings component."
|
||||||
|
)
|
||||||
|
|
||||||
return VertexAIEmbeddings(
|
return VertexAIEmbeddings(
|
||||||
instance=instance,
|
instance=instance,
|
||||||
credentials=credentials,
|
credentials=credentials,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue