Add VertexAI import and update file_types in VertexAIComponent
This commit is contained in:
parent
69c6ede614
commit
ffb0dc0012
1 changed files with 2 additions and 10 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
from langflow import CustomComponent
|
from langflow import CustomComponent
|
||||||
from langchain.llms import BaseLLM
|
from langchain.llms import BaseLLM
|
||||||
from typing import Optional, Union, Callable, Dict
|
from typing import Optional, Union, Callable, Dict
|
||||||
|
from langchain_community.llms.vertexai import VertexAI
|
||||||
|
|
||||||
class VertexAIComponent(CustomComponent):
|
class VertexAIComponent(CustomComponent):
|
||||||
display_name = "VertexAI"
|
display_name = "VertexAI"
|
||||||
|
|
@ -12,7 +13,7 @@ class VertexAIComponent(CustomComponent):
|
||||||
"credentials": {
|
"credentials": {
|
||||||
"display_name": "Credentials",
|
"display_name": "Credentials",
|
||||||
"field_type": "file",
|
"field_type": "file",
|
||||||
"file_types": ["json"],
|
"file_types": [".json"],
|
||||||
"required": False,
|
"required": False,
|
||||||
"value": None,
|
"value": None,
|
||||||
},
|
},
|
||||||
|
|
@ -114,15 +115,11 @@ class VertexAIComponent(CustomComponent):
|
||||||
"display_name":"Name",
|
"display_name":"Name",
|
||||||
"field_type":"str"
|
"field_type":"str"
|
||||||
},
|
},
|
||||||
"client_preview":{
|
|
||||||
"display_name":"client_preview"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def build(
|
def build(
|
||||||
self,
|
self,
|
||||||
credentials: Optional[str] = None,
|
credentials: Optional[str] = None,
|
||||||
client_preview: Optional[any]= None,
|
|
||||||
location: str = "us-central1",
|
location: str = "us-central1",
|
||||||
max_output_tokens: int = 128,
|
max_output_tokens: int = 128,
|
||||||
max_retries: int = 6,
|
max_retries: int = 6,
|
||||||
|
|
@ -141,12 +138,7 @@ class VertexAIComponent(CustomComponent):
|
||||||
) -> Union[BaseLLM, Callable]:
|
) -> Union[BaseLLM, Callable]:
|
||||||
if metadata is None:
|
if metadata is None:
|
||||||
metadata = {}
|
metadata = {}
|
||||||
|
|
||||||
# Import the appropriate VertexAI class from the langchain.llms module
|
|
||||||
from langchain.llms import VertexAI
|
|
||||||
|
|
||||||
return VertexAI(
|
return VertexAI(
|
||||||
client_preview=client_preview,
|
|
||||||
credentials=credentials,
|
credentials=credentials,
|
||||||
location=location,
|
location=location,
|
||||||
max_output_tokens=max_output_tokens,
|
max_output_tokens=max_output_tokens,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue