Fix import error in ChatVertexAIComponent
This commit is contained in:
parent
203d4f5616
commit
c335bf681a
1 changed files with 9 additions and 3 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from langchain_google_vertexai import ChatVertexAI
|
|
||||||
from langchain_core.messages.base import BaseMessage
|
from langchain_core.messages.base import BaseMessage
|
||||||
|
|
||||||
from langflow import CustomComponent
|
from langflow import CustomComponent
|
||||||
from langflow.field_typing import Text
|
from langflow.field_typing import Text
|
||||||
|
|
||||||
|
|
@ -62,7 +62,7 @@ class ChatVertexAIComponent(CustomComponent):
|
||||||
|
|
||||||
def build(
|
def build(
|
||||||
self,
|
self,
|
||||||
inputs:str,
|
inputs: str,
|
||||||
credentials: Optional[str],
|
credentials: Optional[str],
|
||||||
project: str,
|
project: str,
|
||||||
examples: Optional[List[BaseMessage]] = [],
|
examples: Optional[List[BaseMessage]] = [],
|
||||||
|
|
@ -74,7 +74,13 @@ class ChatVertexAIComponent(CustomComponent):
|
||||||
top_p: float = 0.95,
|
top_p: float = 0.95,
|
||||||
verbose: bool = False,
|
verbose: bool = False,
|
||||||
) -> Text:
|
) -> Text:
|
||||||
output = ChatVertexAI(
|
try:
|
||||||
|
from langchain_google_vertexai import ChatVertexAI
|
||||||
|
except ImportError:
|
||||||
|
raise ImportError(
|
||||||
|
"To use the ChatVertexAI model, you need to install the langchain-google-vertexai package."
|
||||||
|
)
|
||||||
|
output = ChatVertexAI(
|
||||||
credentials=credentials,
|
credentials=credentials,
|
||||||
examples=examples,
|
examples=examples,
|
||||||
location=location,
|
location=location,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue