langflow 在Windows 11专业版上使用Vertex AI凭据的问题

q9rjltbz  于 6个月前  发布在  Windows
关注(0)|答案(9)|浏览(83)

Bug描述

你好,
我遇到了一个奇怪的错误。我正在使用Windows 11 Pro,
当我尝试在VertexAI上使用凭据文件时,我总是收到以下错误信息:
'Error Building Component
Error building Component Vertex AI: Your default credentials were not found. To set up Application Default Credentials, see https://cloud.google.com/docs/authentication/external/set-up-adc for more information.'
凭据已经在Flowise和其他应用程序中进行了测试,它们可以正常工作。也许Windows和这个应用程序以及路径有问题?也许应该有一个类似于Flowise中的凭据存储系统?
感谢帮助!
a.

复现步骤

使用基本提示模板。将OpenAI替换为Vertex AI模型。将包含凭据的文件放入其中。

预期行为

Error Building Component
Error building Component Vertex AI: Your default credentials were not found. To set up Application Default Credentials, see https://cloud.google.com/docs/authentication/external/set-up-adc for more information.

谁可以帮助?

  • 无响应*

操作系统

Windows 11 pro

Langflow版本

1.0.9

Python版本

  • 3.12
  • 3.11
  • 3.10
ugmeyewa

ugmeyewa1#

嘿,@severfire!👋 我来帮助你解决bug问题,回答你的问题,引导你成为贡献者。让我们一起解决这些bug吧!
要解决在Windows 11 Pro上使用Vertex AI凭据时出现的"default credentials not found"错误,请确保在params字典中正确设置了credentials参数。initialize_vertexai函数需要一个指向服务帐户凭据文件的路径。
以下是如何设置credentials参数的示例:

params = {
    "credentials": "path/to/your/service_account.json",
    # other parameters
}

class_object = YourVertexAIClass  # Replace with your actual class
initialized_object = initialize_vertexai(class_object, params)

请确保您的服务帐户JSON文件的路径是正确的,并且可以从您的Windows 11 Pro环境中访问。此外,请确保在VertexAIComponent类的build_config方法中正确设置了credentials参数,如下所示:

class ChatVertexAIComponent(LCModelComponent):
    display_name = "Vertex AI"
    description = "Generate text using Vertex AI LLMs."
    icon = "VertexAI"

    def build_config(self):
        return {
            "credentials": {
                "display_name": "Credentials",
                "field_type": "file",
                "file_types": [".json"],
                "file_path": None,
            },
            # other parameters
        }

    def build(
        self,
        input_value: Text,
        credentials: Optional[str],
        project: str,
        examples: Optional[List[BaseMessage]] = [],
        location: str = "us-central1",
        max_output_tokens: int = 128,
        model_name: str = "chat-bison",
        temperature: float = 0.0,
        top_k: int = 40,
        top_p: float = 0.95,
        verbose: bool = False,
        stream: bool = False,
        system_message: Optional[str] = None,
    ) -> Text:
        try:
            from langchain_google_vertexai import ChatVertexAI  # type: ignore
        except ImportError:
            raise ImportError(
                "To use the ChatVertexAI model, you need to install the langchain-google-vertexai package."
            )
        output = ChatVertexAI(
            credentials=credentials,
            examples=examples,
            location=location,
            max_output_tokens=max_output_tokens,
            model_name=model_name,
            project=project,
            temperature=temperature,
            top_k=top_k,
            top_p=top_p,
            verbose=verbose,
        )

        return self.get_chat_result(output, stream, input_value, system_message)

请确保在params字典和build_config方法中都正确设置了credentials参数。这应该可以解决"default credentials not found"错误。

  • 要继续与我交流,请提及@dosu。*
xzabzqsa

xzabzqsa2#

@dosu Where should I edit this code you gave? Where are those files or where the code resides in app?

h22fl7wq

h22fl7wq3#

你应该编辑位于Langflow应用1(https://github.com/langflow-ai/langflow/blob/dev/src/frontend/src/modals/codeAreaModal/index.tsx)中的文件src/frontend/src/modals/codeAreaModal/index.tsx中的代码。

  • 要继续与Dosu交谈,请提及@dosu。*
ee7vknir

ee7vknir4#

亲爱的@dosu,我认为你是错的,文件看起来不应该以这种方式编辑——我也不想寻找黑客,而是寻求更优雅的解决方案。

klh5stk1

klh5stk15#

要解决Langflow中Vertex AI凭据的问题,您应该将GOOGLE_APPLICATION_CREDENTIALS环境变量设置为指向您的凭据JSON文件。这是为Google Cloud服务设置Application Default Credentials (ADC)的标准方法。
以下是在Windows 11 Pro上设置GOOGLE_APPLICATION_CREDENTIALS环境变量的方法:

  1. 定位您的凭据JSON文件:确保您有Google Cloud服务帐户密钥文件的路径(例如,path\to\your\service-account-file.json)。
  • 设置环境变量:
  • 打开开始菜单并搜索“环境变量”。
  • 点击“编辑系统环境变量”。
  • 在系统属性窗口中,点击“环境变量”按钮。
  • 在环境变量窗口中,在“系统变量”部分下,点击“新建”。
  • 将“变量名”设置为GOOGLE_APPLICATION_CREDENTIALS
  • 将“变量值”设置为您的服务帐户密钥文件的完整路径(例如,C:\path\to\your\service-account-file.json)。
  • 点击“确定”关闭所有窗口。
  • 重启应用程序:确保需要这些凭据的任何命令提示符或应用程序都已重启,以便它能获取新的环境变量。

通过设置GOOGLE_APPLICATION_CREDENTIALS环境变量,Langflow中的Vertex AI组件应该能够找到并使用凭据,而无需进行任何代码更改。
此外,Langflow还提供了一种直接在应用程序中配置凭据的方法。您可以在initialize_vertexai函数中设置src/backend/langflow/interface/initialize/llm.py参数。以下是如何配置它的示例:

def initialize_vertexai(class_object, params):
    if credentials_path := params.get("credentials"):
        from google.oauth2 import service_account  # type: ignore

        credentials_object = service_account.Credentials.from_service_account_file(filename=credentials_path)
        params["credentials"] = credentials_object
    return class_object(**params)

您可以使用此函数直接初始化您的Vertex AI组件:

from langflow.interface.initialize.llm import initialize_vertexai
from langflow.components.models.VertexAiModel import ChatVertexAIComponent

params = {
    "input_value": "Your input text here",
    "credentials": "C:\\path\\to\\your\\service-account-file.json",
    "project": "your-project-id",
    "location": "us-central1",
    "max_output_tokens": 128,
    "model_name": "chat-bison",
    "temperature": 0.0,
    "top_k": 40,
    "top_p": 0.95,
    "verbose": False,
    "stream": False,
    "system_message": None,
}

vertex_ai_component = initialize_vertexai(ChatVertexAIComponent, params)

这种方法允许您在代码中直接指定凭据,从而提供了设置环境变量1(https://github.com/logspace-ai/langflow/blob/dev/src/backend/langflow/interface/initialize/llm.py)2(https://github.com/logspace-ai/langflow/blob/dev/src/backend/base/langflow/components/models/VertexAiModel.py)的替代方法。

  • 要继续与Dosu交谈,请提及@dosu。*
gev0vcfq

gev0vcfq6#

亲爱的@dosu,
收到错误信息:'Error Building Component
构建组件顶点AI时出错:503 从插件获取元数据失败,错误信息:'str'对象没有'before_request'属性'。
使用变量修复的方法无效。
完整的错误信息如下:

"ERROR 2024-07-17 07:59:15 - ERROR - base - 503 Getting metadata from plugin failed with error: 'str' object has no attribute 'before_request'Traceback (most recent base.py:649
 call last):

File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\google\api_core\grpc_helpers.py", line 76, in error_remapped_callable
return callable_(*args, **kwargs)
| | -> {'metadata': [('x-goog-request-params', 'model=projects//locations/us-central1/publishers/google/models/gemini-1.5-pro'), ('x...
| -> (model: "projects//locations/us-central1/publishers/google/models/gemini-1.5-pro"
| contents {
| role: "user"
| parts {
| tex...
-> <grpc._channel._UnaryUnaryMultiCallable object at 0x000001B9FEEA3C40>
File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\grpc_channel.py", line 1181, in call
return _end_unary_response_blocking(state, call, False, None)
| | -> <grpc._cython.cygrpc.SegregatedCall object at 0x000001B9FEE288C0>
| -> <grpc._channel._RPCState object at 0x000001B9FED51B80>
-> <function _end_unary_response_blocking at 0x000001B9FAF6CA40>
File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\grpc_channel.py", line 1006, in _end_unary_response_blocking
raise _InactiveRpcError(state) # pytype: disable=not-instantiable
| -> <grpc._channel._RPCState object at 0x000001B9FED51B80>
-> <class 'grpc._channel._InactiveRpcError'>

                     grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
                             status = StatusCode.UNAVAILABLE
                             details = "Getting metadata from plugin failed with error: 'str' object has no attribute 'before_request'"
                             debug_error_string = "UNKNOWN:Error received from peer  {created_time:"2024-07-17T05:59:14.9480728+00:00", grpc_status:14, grpc_message:"Getting metadata
                     from plugin failed with error: \'str\' object has no attribute \'before_request\'"}"
                     >

                     The above exception was the direct cause of the following exception:

                     Traceback (most recent call last):

                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\base\models\model.py", line 153, in get_chat_result
                         message = runnable.invoke(inputs)  # type: ignore
                                   |        |      -> {}
                                   |        -> <function RunnableBindingBase.invoke at 0x000001B9BEAA2700>
                                   -> RunnableBinding(bound=ChatPromptTemplate(input_variables=[], messages=[HumanMessage(content='Answer the user as if you were a...
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langchain_core\runnables\base.py", line 5006, in invoke
                         return self.bound.invoke(
                                |    |     -> <function RunnableSequence.invoke at 0x000001B9BEA86160>
                                |    -> ChatPromptTemplate(input_variables=[], messages=[HumanMessage(content='Answer the user as if you were a pirate.\n\nUser: appl...
                                -> RunnableBinding(bound=ChatPromptTemplate(input_variables=[], messages=[HumanMessage(content='Answer the user as if you were a...
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langchain_core\runnables\base.py", line 2824, in invoke
                         input = step.invoke(input, config)
                                 |    |      |      -> {'tags': [], 'metadata': {}, 'callbacks': <langchain_core.callbacks.manager.CallbackManager object at 0x000001B9FEDB49E0>, 'r...
                                 |    |      -> ChatPromptValue(messages=[HumanMessage(content='Answer the user as if you were a pirate.\n\nUser: apple is sweet\n\nAnswer: ')])
                                 |    -> <function BaseChatModel.invoke at 0x000001B9BEBBBBA0>
                                 -> ChatVertexAI(client=<google.cloud.aiplatform_v1beta1.services.prediction_service.client.PredictionServiceClient object at 0x0...
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langchain_core\language_models\chat_models.py", line 265, in invoke
                         self.generate_prompt(
                         |    -> <function BaseChatModel.generate_prompt at 0x000001B9BEBDC2C0>
                         -> ChatVertexAI(client=<google.cloud.aiplatform_v1beta1.services.prediction_service.client.PredictionServiceClient object at 0x0...
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langchain_core\language_models\chat_models.py", line 698, in generate_prompt
                         return self.generate(prompt_messages, stop=stop, callbacks=callbacks, **kwargs)
                                |    |        |                     |               |            -> {'tags': [], 'metadata': {}, 'run_name': None, 'run_id': None}
                                |    |        |                     |               -> <langchain_core.callbacks.manager.CallbackManager object at 0x000001B9FEDB49E0>
                                |    |        |                     -> None
                                |    |        -> [[HumanMessage(content='Answer the user as if you were a pirate.\n\nUser: apple is sweet\n\nAnswer: ')]]
                                |    -> <function BaseChatModel.generate at 0x000001B9BEBDC180>
                                -> ChatVertexAI(client=<google.cloud.aiplatform_v1beta1.services.prediction_service.client.PredictionServiceClient object at 0x0...
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langchain_core\language_models\chat_models.py", line 555, in generate
                         raise e
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langchain_core\language_models\chat_models.py", line 545, in generate
                         self._generate_with_cache(
                         |    -> <function BaseChatModel._generate_with_cache at 0x000001B9BEBDC400>
                         -> ChatVertexAI(client=<google.cloud.aiplatform_v1beta1.services.prediction_service.client.PredictionServiceClient object at 0x0...
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langchain_core\language_models\chat_models.py", line 770, in _generate_with_cache
                         result = self._generate(
                                  |    -> <function ChatVertexAI._generate at 0x000001B9FC887420>
                                  -> ChatVertexAI(client=<google.cloud.aiplatform_v1beta1.services.prediction_service.client.PredictionServiceClient object at 0x0...
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langchain_google_vertexai\chat_models.py", line 1100, in _generate
                         return self._generate_gemini(
                                |    -> <function ChatVertexAI._generate_gemini at 0x000001B9FC8876A0>
                                -> ChatVertexAI(client=<google.cloud.aiplatform_v1beta1.services.prediction_service.client.PredictionServiceClient object at 0x0...
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langchain_google_vertexai\chat_models.py", line 1190, in _generate_gemini
                         response = _completion_with_retry(
                                    -> <function _completion_with_retry at 0x000001B9FC886DE0>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langchain_google_vertexai\chat_models.py", line 577, in _completion_with_retry
                         return _completion_with_retry_inner(
                                -> <function _completion_with_retry.<locals>._completion_with_retry_inner at 0x000001B9FEE5D1C0>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\tenacity\__init__.py", line 336, in wrapped_f
                         return copy(f, *args, **kw)
                                |    |   |       -> {'request': model: "projects//locations/us-central1/publishers/google/models/gemini-1.5-pro"
                                |    |   |          contents {
                                |    |   |            role: "user"
                                |    |   |            part...
                                |    |   -> (<bound method PredictionServiceClient.generate_content of <google.cloud.aiplatform_v1beta1.services.prediction_service.clien...
                                |    -> <function _completion_with_retry.<locals>._completion_with_retry_inner at 0x000001B9FEE5C860>
                                -> <Retrying object at 0x1b9fed52b40 (stop=<tenacity.stop.stop_after_attempt object at 0x000001B9FD34A540>, wait=<tenacity.wait....
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\tenacity\__init__.py", line 475, in __call__
                         do = self.iter(retry_state=retry_state)
                              |    |                -> <RetryCallState 1898355961600: attempt #6; slept for 30.0; last result: failed (ServiceUnavailable 503 Getting metadata from ...
                              |    -> <function BaseRetrying.iter at 0x000001B9BD2D16C0>
                              -> <Retrying object at 0x1b9fed52b40 (stop=<tenacity.stop.stop_after_attempt object at 0x000001B9FD34A540>, wait=<tenacity.wait....
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\tenacity\__init__.py", line 376, in iter
                         result = action(retry_state)
                                  |      -> <RetryCallState 1898355961600: attempt #6; slept for 30.0; last result: failed (ServiceUnavailable 503 Getting metadata from ...
                                  -> <function BaseRetrying._post_stop_check_actions.<locals>.exc_check at 0x000001B9FEE15800>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\tenacity\__init__.py", line 418, in exc_check
                         raise retry_exc.reraise()
                               |         -> <function RetryError.reraise at 0x000001B9BD2D0C20>
                               -> RetryError(<Future at 0x1b9fed52b10 state=finished raised ServiceUnavailable>)
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\tenacity\__init__.py", line 185, in reraise
                         raise self.last_attempt.result()
                               |    |            -> <function Future.result at 0x000001B9B98AEC00>
                               |    -> <Future at 0x1b9fed52b10 state=finished raised ServiceUnavailable>
                               -> RetryError(<Future at 0x1b9fed52b10 state=finished raised ServiceUnavailable>)
                       File "C:\Python312\Lib\concurrent\futures\_base.py", line 449, in result
                         return self.__get_result()
                                -> None
                       File "C:\Python312\Lib\concurrent\futures\_base.py", line 401, in __get_result
                         raise self._exception
                               -> None
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\tenacity\__init__.py", line 478, in __call__
                         result = fn(*args, **kwargs)
                                  |   |       -> {'request': model: "projects//locations/us-central1/publishers/google/models/gemini-1.5-pro"
                                  |   |          contents {
                                  |   |            role: "user"
                                  |   |            part...
                                  |   -> (<bound method PredictionServiceClient.generate_content of <google.cloud.aiplatform_v1beta1.services.prediction_service.clien...
                                  -> <function _completion_with_retry.<locals>._completion_with_retry_inner at 0x000001B9FEE5C860>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langchain_google_vertexai\chat_models.py", line 570, in _completion_with_retry_inner
                         return generation_method(**kwargs)
                                |                   -> {'request': model: "projects//locations/us-central1/publishers/google/models/gemini-1.5-pro"
                                |                      contents {
                                |                        role: "user"
                                |                        part...
                                -> <bound method PredictionServiceClient.generate_content of <google.cloud.aiplatform_v1beta1.services.prediction_service.client...
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\google\cloud\aiplatform_v1beta1\services\prediction_service\client.py", line 2287, in
                     generate_content
                         response = rpc(
                                    -> <google.api_core.gapic_v1.method._GapicCallable object at 0x000001B98016A960>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\google\api_core\gapic_v1\method.py", line 131, in __call__
                         return wrapped_func(*args, **kwargs)
                                |             |       -> {'metadata': [('x-goog-request-params', 'model=projects//locations/us-central1/publishers/google/models/gemini-1.5-pro'), ('x...
                                |             -> (model: "projects//locations/us-central1/publishers/google/models/gemini-1.5-pro"
                                |                contents {
                                |                  role: "user"
                                |                  parts {
                                |                    tex...
                                -> <function _wrap_unary_errors.<locals>.error_remapped_callable at 0x000001B980174900>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\google\api_core\grpc_helpers.py", line 78, in error_remapped_callable
                         raise exceptions.from_grpc_error(exc) from exc
                               |          -> <function from_grpc_error at 0x000001B9F5B66D40>
                               -> <module 'google.api_core.exceptions' from 'C:\\Users\\arek\\AppData\\Roaming\\Python\\Python312\\site-packages\\google\\api_c...

                     google.api_core.exceptions.ServiceUnavailable: 503 Getting metadata from plugin failed with error: 'str' object has no attribute 'before_request'

                     The above exception was the direct cause of the following exception:


                     Traceback (most recent call last):

                       File "<frozen runpy>", line 198, in _run_module_as_main
                       File "<frozen runpy>", line 88, in _run_code
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\__main__.py", line 609, in <module>
                         main()
                         -> <function main at 0x000001B9F07D7A60>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\__main__.py", line 605, in main
                         app()
                         -> <typer.main.Typer object at 0x000001B9B7296120>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\typer\main.py", line 309, in __call__
                         return get_command(self)(*args, **kwargs)
                                |           |      |       -> {}
                                |           |      -> ()
                                |           -> <typer.main.Typer object at 0x000001B9B7296120>
                                -> <function get_command at 0x000001B9BA9042C0>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\click\core.py", line 1157, in __call__
                         return self.main(*args, **kwargs)
                                |    |     |       -> {}
                                |    |     -> ()
                                |    -> <function TyperGroup.main at 0x000001B9BA8F5120>
                                -> <TyperGroup >
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\typer\core.py", line 723, in main
                         return _main(
                                -> <function _main at 0x000001B9BA8F4180>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\typer\core.py", line 193, in _main
                         rv = self.invoke(ctx)
                              |    |      -> <click.core.Context object at 0x000001B9BCD2F0B0>
                              |    -> <function MultiCommand.invoke at 0x000001B9B783F560>
                              -> <TyperGroup >
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\click\core.py", line 1688, in invoke
                         return _process_result(sub_ctx.command.invoke(sub_ctx))
                                |               |       |       |      -> <click.core.Context object at 0x000001B9F02F8530>
                                |               |       |       -> <function Command.invoke at 0x000001B9B783EF20>
                                |               |       -> <TyperCommand run>
                                |               -> <click.core.Context object at 0x000001B9F02F8530>
                                -> <function MultiCommand.invoke.<locals>._process_result at 0x000001B9F08340E0>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\click\core.py", line 1434, in invoke
                         return ctx.invoke(self.callback, **ctx.params)
                                |   |      |    |           |   -> {'host': '127.0.0.1', 'workers': 1, 'timeout': 300, 'port': 7860, 'components_path':
                     WindowsPath('C:/Users/arek/AppData/Roami...
                                |   |      |    |           -> <click.core.Context object at 0x000001B9F02F8530>
                                |   |      |    -> <function run at 0x000001B9F07D7BA0>
                                |   |      -> <TyperCommand run>
                                |   -> <function Context.invoke at 0x000001B9B783D8A0>
                                -> <click.core.Context object at 0x000001B9F02F8530>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\click\core.py", line 783, in invoke
                         return __callback(*args, **kwargs)
                                            |       -> {'host': '127.0.0.1', 'workers': 1, 'timeout': 300, 'port': 7860, 'components_path': WindowsPath('C:/Users/arek/AppData/Roami...
                                            -> ()
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\typer\main.py", line 692, in wrapper
                         return callback(**use_params)
                                |          -> {'host': '127.0.0.1', 'workers': 1, 'timeout': 300, 'port': 7860, 'components_path': WindowsPath('C:/Users/arek/AppData/Roami...
                                -> <function run at 0x000001B9F07D6DE0>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\__main__.py", line 191, in run
                         process = run_on_windows(host, port, log_level, options, app)
                                   |              |     |     |          |        -> <fastapi.applications.FastAPI object at 0x000001B9F08155E0>
                                   |              |     |     |          -> {'bind': '127.0.0.1:7860', 'workers': 1, 'timeout': 300}
                                   |              |     |     -> 'critical'
                                   |              |     -> 7860
                                   |              -> '127.0.0.1'
                                   -> <function run_on_windows at 0x000001B9F07D6F20>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\__main__.py", line 234, in run_on_windows
                         run_langflow(host, port, log_level, options, app)
                         |            |     |     |          |        -> <fastapi.applications.FastAPI object at 0x000001B9F08155E0>
                         |            |     |     |          -> {'bind': '127.0.0.1:7860', 'workers': 1, 'timeout': 300}
                         |            |     |     -> 'critical'
                         |            |     -> 7860
                         |            -> '127.0.0.1'
                         -> <function run_langflow at 0x000001B9F07D76A0>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\__main__.py", line 434, in run_langflow
                         uvicorn.run(
                         |       -> <function run at 0x000001B9F22327A0>
                         -> <module 'uvicorn' from 'C:\\Users\\arek\\AppData\\Roaming\\Python\\Python312\\site-packages\\uvicorn\\__init__.py'>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\uvicorn\main.py", line 577, in run
                         server.run()
                         |      -> <function Server.run at 0x000001B9F2232C00>
                         -> <uvicorn.server.Server object at 0x000001B9F21F7A40>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\uvicorn\server.py", line 65, in run
                         return asyncio.run(self.serve(sockets=sockets))
                                |       |   |    |             -> None
                                |       |   |    -> <function Server.serve at 0x000001B9F2232CA0>
                                |       |   -> <uvicorn.server.Server object at 0x000001B9F21F7A40>
                                |       -> <function _patch_asyncio.<locals>.run at 0x000001B9F224E480>
                                -> <module 'asyncio' from 'C:\\Python312\\Lib\\asyncio\\__init__.py'>
                       File "C:\Python312\Lib\asyncio\runners.py", line 194, in run
                         return runner.run(main)
                                |      |   -> <coroutine object Server.serve at 0x000001B9F2211EE0>
                                |      -> <function Runner.run at 0x000001B9BAC20400>
                                -> <asyncio.runners.Runner object at 0x000001B9F0831D30>
                       File "C:\Python312\Lib\asyncio\runners.py", line 118, in run
                         return self._loop.run_until_complete(task)
                                |    |     |                  -> <Task pending name='Task-1' coro=<Server.serve() running at
                     C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\uvic...
                                |    |     -> <function _patch_loop.<locals>.run_until_complete at 0x000001B9F2300680>
                                |    -> <ProactorEventLoop running=True closed=False debug=False>
                                -> <asyncio.runners.Runner object at 0x000001B9F0831D30>
                       File "C:\Python312\Lib\asyncio\base_events.py", line 674, in run_until_complete
                         self.run_forever()
                         |    -> <function _patch_loop.<locals>.run_forever at 0x000001B9F23005E0>
                         -> <ProactorEventLoop running=True closed=False debug=False>
                       File "C:\Python312\Lib\asyncio\windows_events.py", line 322, in run_forever
                         super().run_forever()
                       File "C:\Python312\Lib\asyncio\base_events.py", line 641, in run_forever
                         self._run_once()
                         |    -> <function _patch_loop.<locals>._run_once at 0x000001B9F2300720>
                         -> <ProactorEventLoop running=True closed=False debug=False>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\nest_asyncio.py", line 133, in _run_once
                         handle._run()
                         |      -> <function Handle._run at 0x000001B9BABC42C0>
                         -> <Handle Task.__wakeup(<Future finis...01B9FEDB8350>>)>
                       File "C:\Python312\Lib\asyncio\events.py", line 88, in _run
                         self._context.run(self._callback, *self._args)
                         |    |            |    |           |    -> <member '_args' of 'Handle' objects>
                         |    |            |    |           -> <Handle Task.__wakeup(<Future finis...01B9FEDB8350>>)>
                         |    |            |    -> <member '_callback' of 'Handle' objects>
                         |    |            -> <Handle Task.__wakeup(<Future finis...01B9FEDB8350>>)>
                         |    -> <member '_context' of 'Handle' objects>
                         -> <Handle Task.__wakeup(<Future finis...01B9FEDB8350>>)>
                       File "C:\Python312\Lib\asyncio\tasks.py", line 396, in __wakeup
                         self.__step()
                         -> <Task pending name='starlette.middleware.base.BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.coro' coro=<BaseHTTPMid...
                       File "C:\Python312\Lib\asyncio\tasks.py", line 303, in __step
                         self.__step_run_and_handle_result(exc)
                         |                                 -> None
                         -> <Task pending name='starlette.middleware.base.BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.coro' coro=<BaseHTTPMid...
                       File "C:\Python312\Lib\asyncio\tasks.py", line 314, in __step_run_and_handle_result
                         result = coro.send(None)
                                  |    -> <method 'send' of 'coroutine' objects>
                                  -> <coroutine object BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.coro at 0x000001B9FEDB3560>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\starlette\middleware\base.py", line 151, in coro
                         await self.app(scope, receive_or_disconnect, send_no_error)
                               |    |   |      |                      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.send_no_error at 0x000001B9FEE15940>
                               |    |   |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x000001B9FEE17C40>
                               |    |   -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('127.0.0.1', 7860), 'cl...
                               |    -> <starlette.middleware.cors.CORSMiddleware object at 0x000001B9F22CE9F0>
                               -> <langflow.main.JavaScriptMIMETypeMiddleware object at 0x000001B9F216EB40>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\starlette\middleware\cors.py", line 93, in __call__
                         await self.simple_response(scope, receive, send, request_headers=headers)
                               |    |               |      |        |                     -> Headers({'host': '127.0.0.1:7860', 'connection': 'keep-alive', 'content-length': '2',
                     'sec-ch-ua': '"Not/A)Brand";v="8", "Chr...
                               |    |               |      |        -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.send_no_error at 0x000001B9FEE15940>
                               |    |               |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x000001B9FEE17C40>
                               |    |               -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('127.0.0.1', 7860), 'cl...
                               |    -> <function CORSMiddleware.simple_response at 0x000001B9BCDB1760>
                               -> <starlette.middleware.cors.CORSMiddleware object at 0x000001B9F22CE9F0>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\starlette\middleware\cors.py", line 148, in simple_response
                         await self.app(scope, receive, send)
                               |    |   |      |        -> functools.partial(<bound method CORSMiddleware.send of <starlette.middleware.cors.CORSMiddleware object at
                     0x000001B9F22CE9F0...
                               |    |   |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x000001B9FEE17C40>
                               |    |   -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('127.0.0.1', 7860), 'cl...
                               |    -> <starlette.middleware.exceptions.ExceptionMiddleware object at 0x000001B9F22CE9C0>
                               -> <starlette.middleware.cors.CORSMiddleware object at 0x000001B9F22CE9F0>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\starlette\middleware\exceptions.py", line 65, in __call__
                         await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
                               |                            |    |    |     |      |        -> functools.partial(<bound method CORSMiddleware.send of
                     <starlette.middleware.cors.CORSMiddleware object at 0x000001B9F22CE9F0...
                               |                            |    |    |     |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at
                     0x000001B9FEE17C40>
                               |                            |    |    |     -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server':
                     ('127.0.0.1', 7860), 'cl...
                               |                            |    |    -> <starlette.requests.Request object at 0x000001B9FEDB4770>
                               |                            |    -> <fastapi.routing.APIRouter object at 0x000001B9F08167E0>
                               |                            -> <starlette.middleware.exceptions.ExceptionMiddleware object at 0x000001B9F22CE9C0>
                               -> <function wrap_app_handling_exceptions at 0x000001B9BCD4EE80>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app
                         await app(scope, receive, sender)
                               |   |      |        -> <function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at 0x000001B9FEEA63E0>
                               |   |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x000001B9FEE17C40>
                               |   -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('127.0.0.1', 7860), 'cl...
                               -> <fastapi.routing.APIRouter object at 0x000001B9F08167E0>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\starlette\routing.py", line 756, in __call__
                         await self.middleware_stack(scope, receive, send)
                               |    |                |      |        -> <function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at 0x000001B9FEEA63E0>
                               |    |                |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x000001B9FEE17C40>
                               |    |                -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('127.0.0.1', 7860), 'cl...
                               |    -> <bound method Router.app of <fastapi.routing.APIRouter object at 0x000001B9F08167E0>>
                               -> <fastapi.routing.APIRouter object at 0x000001B9F08167E0>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\starlette\routing.py", line 776, in app
                         await route.handle(scope, receive, send)
                               |     |      |      |        -> <function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at 0x000001B9FEEA63E0>
                               |     |      |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x000001B9FEE17C40>
                               |     |      -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('127.0.0.1', 7860), 'cl...
                               |     -> <function Route.handle at 0x000001B9BCD6C400>
                               -> APIRoute(path='/api/v1/build/{flow_id}/vertices/{vertex_id}', name='build_vertex', methods=['POST'])
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\starlette\routing.py", line 297, in handle
                         await self.app(scope, receive, send)
                               |    |   |      |        -> <function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at 0x000001B9FEEA63E0>
                               |    |   |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x000001B9FEE17C40>
                               |    |   -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('127.0.0.1', 7860), 'cl...
                               |    -> <function request_response.<locals>.app at 0x000001B9F08365C0>
                               -> APIRoute(path='/api/v1/build/{flow_id}/vertices/{vertex_id}', name='build_vertex', methods=['POST'])
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\starlette\routing.py", line 77, in app
                         await wrap_app_handling_exceptions(app, request)(scope, receive, send)
                               |                            |    |        |      |        -> <function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at
                     0x000001B9FEEA63E0>
                               |                            |    |        |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at
                     0x000001B9FEE17C40>
                               |                            |    |        -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server':
                     ('127.0.0.1', 7860), 'cl...
                               |                            |    -> <starlette.requests.Request object at 0x000001B9FEE2FD70>
                               |                            -> <function request_response.<locals>.app.<locals>.app at 0x000001B9FEEA6340>
                               -> <function wrap_app_handling_exceptions at 0x000001B9BCD4EE80>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app
                         await app(scope, receive, sender)
                               |   |      |        -> <function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at 0x000001B9FEEA6660>
                               |   |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x000001B9FEE17C40>
                               |   -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('127.0.0.1', 7860), 'cl...
                               -> <function request_response.<locals>.app.<locals>.app at 0x000001B9FEEA6340>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\starlette\routing.py", line 72, in app
                         response = await func(request)
                                          |    -> <starlette.requests.Request object at 0x000001B9FEE2FD70>
                                          -> <function get_request_handler.<locals>.app at 0x000001B9F08363E0>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\fastapi\routing.py", line 278, in app
                         raw_response = await run_endpoint_function(
                                              -> <function run_endpoint_function at 0x000001B9BCD4E520>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\fastapi\routing.py", line 191, in run_endpoint_function
                         return await dependant.call(**values)
                                      |         |      -> {'chat_service': <langflow.services.chat.service.ChatService object at 0x000001B9FEE2E8D0>, 'current_user':
                     User(is_active=Tr...
                                      |         -> <function build_vertex at 0x000001B9F03AD8A0>
                                      -> <fastapi.dependencies.models.Dependant object at 0x000001B9F0832ED0>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\api\v1\chat.py", line 198, in build_vertex
                         ) = await graph.build_vertex(
                                   |     -> <function Graph.build_vertex at 0x000001B9F0310A40>
                                   -> Graph:
                                      Nodes: ['ChatInput-eUQi7', 'Prompt-OChYh', 'ChatOutput-LqOgS', 'VertexAiModel-m6OGS']
                                      Connections:
                                      VertexAiModel-m6OGS...
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\graph\graph\base.py", line 893, in build_vertex
                         await vertex.build(
                               |      -> <function Vertex.build at 0x000001B9F0300220>
                               -> Vertex(display_name=Vertex AI, id=VertexAiModel-m6OGS, data={'type': 'VertexAiModel', 'node': {'template': {'_type': 'Compone...
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\graph\vertex\base.py", line 735, in build
                         await step(user_id=user_id, **kwargs)
                               |            |          -> {'fallback_to_env_vars': False}
                               |            -> UUID('2206f11d-5f07-47c8-bd33-981ab23727c0')
                               -> <bound method Vertex._build of Vertex(display_name=Vertex AI, id=VertexAiModel-m6OGS, data={'type': 'VertexAiModel', 'node': ...
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\graph\vertex\base.py", line 424, in _build
                         await self._get_and_instantiate_class(user_id, fallback_to_env_vars)
                               |    |                          |        -> False
                               |    |                          -> UUID('2206f11d-5f07-47c8-bd33-981ab23727c0')
                               |    -> <function Vertex._get_and_instantiate_class at 0x000001B9F02F7E20>
                               -> Vertex(display_name=Vertex AI, id=VertexAiModel-m6OGS, data={'type': 'VertexAiModel', 'node': {'template': {'_type': 'Compone...
                     > File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\graph\vertex\base.py", line 640, in _get_and_instantiate_class
                         result = await loading.instantiate_class(
                                        |       -> <function instantiate_class at 0x000001B9EF9EDDA0>
                                        -> <module 'langflow.interface.initialize.loading' from 'C:\\Users\\arek\\AppData\\Roaming\\Python\\Python312\\site-packages\\la...
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\interface\initialize\loading.py", line 38, in instantiate_class
                         custom_component, build_results, artifacts = await build_component_and_get_results(
                                                                            -> <function build_component_and_get_results at 0x000001B9EF9EC4A0>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\interface\initialize\loading.py", line 74, in build_component_and_get_results
                         return await build_component(params=params_copy, custom_component=custom_component)
                                      |                      |                             -> <langflow.utils.validate.ChatVertexAIComponent object at 0x000001B9FEAC74A0>
                                      |                      -> {'input_value': Message(text_key='text', data={'template': 'Answer the user as if you were a pirate.\n\nUser:
                     {user_input}\n\...
                                      -> <function build_component at 0x000001B9F02E51C0>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\interface\initialize\loading.py", line 154, in build_component
                         build_results, artifacts = await custom_component.build_results()
                                                          |                -> <function Component.build_results at 0x000001B9F02E4D60>
                                                          -> <langflow.utils.validate.ChatVertexAIComponent object at 0x000001B9FEAC74A0>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\custom\custom_component\component.py", line 136, in build_results
                         return await self._build_with_tracing()
                                      |    -> <function Component._build_with_tracing at 0x000001B9F02E4C20>
                                      -> <langflow.utils.validate.ChatVertexAIComponent object at 0x000001B9FEAC74A0>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\custom\custom_component\component.py", line 125, in _build_with_tracing
                         _results, _artifacts = await self._build_results()
                                                      |    -> <function Component._build_results at 0x000001B9F02E4E00>
                                                      -> <langflow.utils.validate.ChatVertexAIComponent object at 0x000001B9FEAC74A0>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\custom\custom_component\component.py", line 154, in _build_results
                         result = method()
                                  -> <bound method LCModelComponent.text_response of <langflow.utils.validate.ChatVertexAIComponent object at 0x000001B9FEAC74A0>>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\base\models\model.py", line 43, in text_response
                         result = self.get_chat_result(output, stream, input_value, system_message)
                                  |    |               |       |       |            -> ''
                                  |    |               |       |       -> Message(text_key='text', data={'template': 'Answer the user as if you were a pirate.\n\nUser:
                     {user_input}\n\nAnswer: ', 'var...
                                  |    |               |       -> False
                                  |    |               -> ChatVertexAI(client=<google.cloud.aiplatform_v1beta1.services.prediction_service.client.PredictionServiceClient object at
                     0x0...
                                  |    -> <function LCModelComponent.get_chat_result at 0x000001B9F46D7060>
                                  -> <langflow.utils.validate.ChatVertexAIComponent object at 0x000001B9FEAC74A0>
                       File "C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\base\models\model.py", line 166, in get_chat_result
                         raise ValueError(message) from e
                                          -> "503 Getting metadata from plugin failed with error: 'str' object has no attribute 'before_request'"

                     ValueError: 503 Getting metadata from plugin failed with error: 'str' object has no attribute 'before_request'

                     ╭─────────────────────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────────────────────╮
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\google\api_core\grpc_helpers.py:76 in error_remapped_callable                                       │
                     │                                                                                                                                                                  │
                     │    73 │   @functools.wraps(callable_)                                                                                                                            │
                     │    74 │   def error_remapped_callable(*args, **kwargs):                                                                                                          │
                     │    75 │   │   try:                                                                                                                                               │
                     │ ❱  76 │   │   │   return callable_(*args, **kwargs)                                                                                                              │
                     │    77 │   │   except grpc.RpcError as exc:                                                                                                                       │
                     │    78 │   │   │   raise exceptions.from_grpc_error(exc) from exc                                                                                                 │
                     │    79                                                                                                                                                            │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\grpc\_channel.py:1181 in __call__                                                                   │
                     │                                                                                                                                                                  │
                     │   1178 │   │   ) = self._blocking(                                                                                                                               │
                     │   1179 │   │   │   request, timeout, metadata, credentials, wait_for_ready, compression                                                                          │
                     │   1180 │   │   )                                                                                                                                                 │
                     │ ❱ 1181 │   │   return _end_unary_response_blocking(state, call, False, None)                                                                                     │
                     │   1182 │                                                                                                                                                         │
                     │   1183 │   def with_call(                                                                                                                                        │
                     │   1184 │   │   self,                                                                                                                                             │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\grpc\_channel.py:1006 in _end_unary_response_blocking                                               │
                     │                                                                                                                                                                  │
                     │   1003 │   │   else:                                                                                                                                             │
                     │   1004 │   │   │   return state.response                                                                                                                         │
                     │   1005 │   else:                                                                                                                                                 │
                     │ ❱ 1006 │   │   raise _InactiveRpcError(state)  # pytype: disable=not-instantiable                                                                                │
                     │   1007                                                                                                                                                           │
                     │   1008                                                                                                                                                           │
                     │   1009 def _stream_unary_invocation_operations(                                                                                                                  │
                     ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
                     _InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
                             status = StatusCode.UNAVAILABLE
                             details = "Getting metadata from plugin failed with error: 'str' object has no attribute 'before_request'"
                             debug_error_string = "UNKNOWN:Error received from peer  {created_time:"2024-07-17T05:59:14.9480728+00:00", grpc_status:14, grpc_message:"Getting metadata
                     from plugin failed with error: \'str\' object has no attribute \'before_request\'"}"
                     >

                     The above exception was the direct cause of the following exception:

                     ╭─────────────────────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────────────────────╮
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\base\models\model.py:153 in get_chat_result                                                │
                     │                                                                                                                                                                  │
                     │   150 │   │   │   if stream:                                                                                                                                     │
                     │   151 │   │   │   │   return runnable.stream(inputs)  # type: ignore                                                                                             │
                     │   152 │   │   │   else:                                                                                                                                          │
                     │ ❱ 153 │   │   │   │   message = runnable.invoke(inputs)  # type: ignore                                                                                          │
                     │   154 │   │   │   │   result = message.content if hasattr(message, "content") else message                                                                       │
                     │   155 │   │   │   │   if isinstance(message, AIMessage):                                                                                                         │
                     │   156 │   │   │   │   │   status_message = self.build_status_message(message)                                                                                    │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langchain_core\runnables\base.py:5006 in invoke                                                     │
                     │                                                                                                                                                                  │
                     │   5003 │   │   config: Optional[RunnableConfig] = None,                                                                                                          │
                     │   5004 │   │   **kwargs: Optional[Any],                                                                                                                          │
                     │   5005 │   ) -> Output:                                                                                                                                          │
                     │ ❱ 5006 │   │   return self.bound.invoke(                                                                                                                         │
                     │   5007 │   │   │   input,                                                                                                                                        │
                     │   5008 │   │   │   self._merge_configs(config),                                                                                                                  │
                     │   5009 │   │   │   **{**self.kwargs, **kwargs},                                                                                                                  │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langchain_core\runnables\base.py:2824 in invoke                                                     │
                     │                                                                                                                                                                  │
                     │   2821 │   │   │   │   if i == 0:                                                                                                                                │
                     │   2822 │   │   │   │   │   input = step.invoke(input, config, **kwargs)                                                                                          │
                     │   2823 │   │   │   │   else:                                                                                                                                     │
                     │ ❱ 2824 │   │   │   │   │   input = step.invoke(input, config)                                                                                                    │
                     │   2825 │   │   # finish the root run                                                                                                                             │
                     │   2826 │   │   except BaseException as e:                                                                                                                        │
                     │   2827 │   │   │   run_manager.on_chain_error(e)                                                                                                                 │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langchain_core\language_models\chat_models.py:265 in invoke                                         │
                     │                                                                                                                                                                  │
                     │    262 │   │   config = ensure_config(config)                                                                                                                    │
                     │    263 │   │   return cast(                                                                                                                                      │
                     │    264 │   │   │   ChatGeneration,                                                                                                                               │
                     │ ❱  265 │   │   │   self.generate_prompt(                                                                                                                         │
                     │    266 │   │   │   │   [self._convert_input(input)],                                                                                                             │
                     │    267 │   │   │   │   stop=stop,                                                                                                                                │
                     │    268 │   │   │   │   callbacks=config.get("callbacks"),                                                                                                        │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langchain_core\language_models\chat_models.py:698 in generate_prompt                                │
                     │                                                                                                                                                                  │
                     │    695 │   │   **kwargs: Any,                                                                                                                                    │
                     │    696 │   ) -> LLMResult:                                                                                                                                       │
                     │    697 │   │   prompt_messages = [p.to_messages() for p in prompts]                                                                                              │
                     │ ❱  698 │   │   return self.generate(prompt_messages, stop=stop, callbacks=callbacks, **kwargs)                                                                   │
                     │    699 │                                                                                                                                                         │
                     │    700 │   async def agenerate_prompt(                                                                                                                           │
                     │    701 │   │   self,                                                                                                                                             │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langchain_core\language_models\chat_models.py:555 in generate                                       │
                     │                                                                                                                                                                  │
                     │    552 │   │   │   except BaseException as e:                                                                                                                    │
                     │    553 │   │   │   │   if run_managers:                                                                                                                          │
                     │    554 │   │   │   │   │   run_managers[i].on_llm_error(e, response=LLMResult(generations=[]))                                                                   │
                     │ ❱  555 │   │   │   │   raise e                                                                                                                                   │
                     │    556 │   │   flattened_outputs = [                                                                                                                             │
                     │    557 │   │   │   LLMResult(generations=[res.generations], llm_output=res.llm_output)  # type:                                                                  │
                     │        ignore[list-item]                                                                                                                                         │
                     │    558 │   │   │   for res in results                                                                                                                            │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langchain_core\language_models\chat_models.py:545 in generate                                       │
                     │                                                                                                                                                                  │
                     │    542 │   │   for i, m in enumerate(messages):                                                                                                                  │
                     │    543 │   │   │   try:                                                                                                                                          │
                     │    544 │   │   │   │   results.append(                                                                                                                           │
                     │ ❱  545 │   │   │   │   │   self._generate_with_cache(                                                                                                            │
                     │    546 │   │   │   │   │   │   m,                                                                                                                                │
                     │    547 │   │   │   │   │   │   stop=stop,                                                                                                                        │
                     │    548 │   │   │   │   │   │   run_manager=run_managers[i] if run_managers else None,                                                                            │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langchain_core\language_models\chat_models.py:770 in _generate_with_cache                           │
                     │                                                                                                                                                                  │
                     │    767 │   │   │   result = generate_from_stream(iter(chunks))                                                                                                   │
                     │    768 │   │   else:                                                                                                                                             │
                     │    769 │   │   │   if inspect.signature(self._generate).parameters.get("run_manager"):                                                                           │
                     │ ❱  770 │   │   │   │   result = self._generate(                                                                                                                  │
                     │    771 │   │   │   │   │   messages, stop=stop, run_manager=run_manager, **kwargs                                                                                │
                     │    772 │   │   │   │   )                                                                                                                                         │
                     │    773 │   │   │   else:                                                                                                                                         │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langchain_google_vertexai\chat_models.py:1100 in _generate                                          │
                     │                                                                                                                                                                  │
                     │   1097 │   │   │   return generate_from_stream(stream_iter)                                                                                                      │
                     │   1098 │   │   if not self._is_gemini_model:                                                                                                                     │
                     │   1099 │   │   │   return self._generate_non_gemini(messages, stop=stop, **kwargs)                                                                               │
                     │ ❱ 1100 │   │   return self._generate_gemini(                                                                                                                     │
                     │   1101 │   │   │   messages=messages,                                                                                                                            │
                     │   1102 │   │   │   stop=stop,                                                                                                                                    │
                     │   1103 │   │   │   run_manager=run_manager,                                                                                                                      │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langchain_google_vertexai\chat_models.py:1190 in _generate_gemini                                   │
                     │                                                                                                                                                                  │
                     │   1187 │   │   **kwargs: Any,                                                                                                                                    │
                     │   1188 │   ) -> ChatResult:                                                                                                                                      │
                     │   1189 │   │   request = self._prepare_request_gemini(messages=messages, stop=stop, **kwargs)                                                                    │
                     │ ❱ 1190 │   │   response = _completion_with_retry(                                                                                                                │
                     │   1191 │   │   │   self.prediction_client.generate_content,                                                                                                      │
                     │   1192 │   │   │   max_retries=self.max_retries,                                                                                                                 │
                     │   1193 │   │   │   request=request,                                                                                                                              │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langchain_google_vertexai\chat_models.py:577 in _completion_with_retry                              │
                     │                                                                                                                                                                  │
                     │    574 │   │   if kwargs.get("is_gemini")                                                                                                                        │
                     │    575 │   │   else kwargs                                                                                                                                       │
                     │    576 │   )                                                                                                                                                     │
                     │ ❱  577 │   return _completion_with_retry_inner(                                                                                                                  │
                     │    578 │   │   generation_method,                                                                                                                                │
                     │    579 │   │   **params,                                                                                                                                         │
                     │    580 │   )                                                                                                                                                     │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\tenacity\__init__.py:336 in wrapped_f                                                               │
                     │                                                                                                                                                                  │
                     │   333 │   │   │   # calling the same wrapped functions multiple times in the same stack                                                                          │
                     │   334 │   │   │   copy = self.copy()                                                                                                                             │
                     │   335 │   │   │   wrapped_f.statistics = copy.statistics  # type: ignore[attr-defined]                                                                           │
                     │ ❱ 336 │   │   │   return copy(f, *args, **kw)                                                                                                                    │
                     │   337 │   │                                                                                                                                                      │
                     │   338 │   │   def retry_with(*args: t.Any, **kwargs: t.Any) -> WrappedFn:                                                                                        │
                     │   339 │   │   │   return self.copy(*args, **kwargs).wraps(f)                                                                                                     │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\tenacity\__init__.py:475 in __call__                                                                │
                     │                                                                                                                                                                  │
                     │   472 │   │                                                                                                                                                      │
                     │   473 │   │   retry_state = RetryCallState(retry_object=self, fn=fn, args=args, kwargs=kwargs)                                                                   │
                     │   474 │   │   while True:                                                                                                                                        │
                     │ ❱ 475 │   │   │   do = self.iter(retry_state=retry_state)                                                                                                        │
                     │   476 │   │   │   if isinstance(do, DoAttempt):                                                                                                                  │
                     │   477 │   │   │   │   try:                                                                                                                                       │
                     │   478 │   │   │   │   │   result = fn(*args, **kwargs)                                                                                                           │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\tenacity\__init__.py:376 in iter                                                                    │
                     │                                                                                                                                                                  │
                     │   373 │   │   self._begin_iter(retry_state)                                                                                                                      │
                     │   374 │   │   result = None                                                                                                                                      │
                     │   375 │   │   for action in self.iter_state.actions:                                                                                                             │
                     │ ❱ 376 │   │   │   result = action(retry_state)                                                                                                                   │
                     │   377 │   │   return result                                                                                                                                      │
                     │   378 │                                                                                                                                                          │
                     │   379 │   def _begin_iter(self, retry_state: "RetryCallState") -> None:  # noqa                                                                                  │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\tenacity\__init__.py:418 in exc_check                                                               │
                     │                                                                                                                                                                  │
                     │   415 │   │   │   │   fut = t.cast(Future, rs.outcome)                                                                                                           │
                     │   416 │   │   │   │   retry_exc = self.retry_error_cls(fut)                                                                                                      │
                     │   417 │   │   │   │   if self.reraise:                                                                                                                           │
                     │ ❱ 418 │   │   │   │   │   raise retry_exc.reraise()                                                                                                              │
                     │   419 │   │   │   │   raise retry_exc from fut.exception()                                                                                                       │
                     │   420 │   │   │                                                                                                                                                  │
                     │   421 │   │   │   self._add_action_func(exc_check)                                                                                                               │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\tenacity\__init__.py:185 in reraise                                                                 │
                     │                                                                                                                                                                  │
                     │   182 │                                                                                                                                                          │
                     │   183 │   def reraise(self) -> t.NoReturn:                                                                                                                       │
                     │   184 │   │   if self.last_attempt.failed:                                                                                                                       │
                     │ ❱ 185 │   │   │   raise self.last_attempt.result()                                                                                                               │
                     │   186 │   │   raise self                                                                                                                                         │
                     │   187 │                                                                                                                                                          │
                     │   188 │   def __str__(self) -> str:                                                                                                                              │
                     │                                                                                                                                                                  │
                     │ C:\Python312\Lib\concurrent\futures\_base.py:449 in result                                                                                                       │
                     │                                                                                                                                                                  │
                     │   446 │   │   │   │   if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:                                                                                     │
                     │   447 │   │   │   │   │   raise CancelledError()                                                                                                                 │
                     │   448 │   │   │   │   elif self._state == FINISHED:                                                                                                              │
                     │ ❱ 449 │   │   │   │   │   return self.__get_result()                                                                                                             │
                     │   450 │   │   │   │                                                                                                                                              │
                     │   451 │   │   │   │   self._condition.wait(timeout)                                                                                                              │
                     │   452                                                                                                                                                            │
                     │                                                                                                                                                                  │
                     │ C:\Python312\Lib\concurrent\futures\_base.py:401 in __get_result                                                                                                 │
                     │                                                                                                                                                                  │
                     │   398 │   def __get_result(self):                                                                                                                                │
                     │   399 │   │   if self._exception:                                                                                                                                │
                     │   400 │   │   │   try:                                                                                                                                           │
                     │ ❱ 401 │   │   │   │   raise self._exception                                                                                                                      │
                     │   402 │   │   │   finally:                                                                                                                                       │
                     │   403 │   │   │   │   # Break a reference cycle with the exception in self._exception                                                                            │
                     │   404 │   │   │   │   self = None                                                                                                                                │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\tenacity\__init__.py:478 in __call__                                                                │
                     │                                                                                                                                                                  │
                     │   475 │   │   │   do = self.iter(retry_state=retry_state)                                                                                                        │
                     │   476 │   │   │   if isinstance(do, DoAttempt):                                                                                                                  │
                     │   477 │   │   │   │   try:                                                                                                                                       │
                     │ ❱ 478 │   │   │   │   │   result = fn(*args, **kwargs)                                                                                                           │
                     │   479 │   │   │   │   except BaseException:  # noqa: B902                                                                                                        │
                     │   480 │   │   │   │   │   retry_state.set_exception(sys.exc_info())  # type: ignore[arg-type]                                                                    │
                     │   481 │   │   │   │   else:                                                                                                                                      │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langchain_google_vertexai\chat_models.py:570 in _completion_with_retry_inner                        │
                     │                                                                                                                                                                  │
                     │    567 │                                                                                                                                                         │
                     │    568 │   @retry_decorator                                                                                                                                      │
                     │    569 │   def _completion_with_retry_inner(generation_method: Callable, **kwargs: Any) -> Any:                                                                  │
                     │ ❱  570 │   │   return generation_method(**kwargs)                                                                                                                │
                     │    571 │                                                                                                                                                         │
                     │    572 │   params = (                                                                                                                                            │
                     │    573 │   │   {k: v for k, v in kwargs.items() if k in _allowed_params_prediction_service}                                                                      │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\google\cloud\aiplatform_v1beta1\services\prediction_service\client.py:2287 in generate_content      │
                     │                                                                                                                                                                  │
                     │   2284 │   │   self._validate_universe_domain()                                                                                                                  │
                     │   2285 │   │                                                                                                                                                     │
                     │   2286 │   │   # Send the request.                                                                                                                               │
                     │ ❱ 2287 │   │   response = rpc(                                                                                                                                   │
                     │   2288 │   │   │   request,                                                                                                                                      │
                     │   2289 │   │   │   retry=retry,                                                                                                                                  │
                     │   2290 │   │   │   timeout=timeout,                                                                                                                              │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\google\api_core\gapic_v1\method.py:131 in __call__                                                  │
                     │                                                                                                                                                                  │
                     │   128 │   │   if self._compression is not None:                                                                                                                  │
                     │   129 │   │   │   kwargs["compression"] = compression                                                                                                            │
                     │   130 │   │                                                                                                                                                      │
                     │ ❱ 131 │   │   return wrapped_func(*args, **kwargs)                                                                                                               │
                     │   132                                                                                                                                                            │
                     │   133                                                                                                                                                            │
                     │   134 def wrap_method(                                                                                                                                           │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\google\api_core\grpc_helpers.py:78 in error_remapped_callable                                       │
                     │                                                                                                                                                                  │
                     │    75 │   │   try:                                                                                                                                               │
                     │    76 │   │   │   return callable_(*args, **kwargs)                                                                                                              │
                     │    77 │   │   except grpc.RpcError as exc:                                                                                                                       │
                     │ ❱  78 │   │   │   raise exceptions.from_grpc_error(exc) from exc                                                                                                 │
                     │    79 │                                                                                                                                                          │
                     │    80 │   return error_remapped_callable                                                                                                                         │
                     │    81                                                                                                                                                            │
                     ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
                     ServiceUnavailable: 503 Getting metadata from plugin failed with error: 'str' object has no attribute 'before_request'

                     The above exception was the direct cause of the following exception:

                     ╭─────────────────────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────────────────────╮
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\graph\vertex\base.py:640 in _get_and_instantiate_class                                     │
                     │                                                                                                                                                                  │
                     │   637 │   │   if self.base_type is None:                                                                                                                         │
                     │   638 │   │   │   raise ValueError(f"Base type for vertex {self.display_name} not found")                                                                        │
                     │   639 │   │   try:                                                                                                                                               │
                     │ ❱ 640 │   │   │   result = await loading.instantiate_class(                                                                                                      │
                     │   641 │   │   │   │   user_id=user_id,                                                                                                                           │
                     │   642 │   │   │   │   fallback_to_env_vars=fallback_to_env_vars,                                                                                                 │
                     │   643 │   │   │   │   vertex=self,                                                                                                                               │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\interface\initialize\loading.py:38 in instantiate_class                                    │
                     │                                                                                                                                                                  │
                     │    35 │   if not base_type:                                                                                                                                      │
                     │    36 │   │   raise ValueError("No base type provided for vertex")                                                                                               │
                     │    37 │                                                                                                                                                          │
                     │ ❱  38 │   custom_component, build_results, artifacts = await build_component_and_get_results(                                                                    │
                     │    39 │   │   params=params,                                                                                                                                     │
                     │    40 │   │   vertex=vertex,                                                                                                                                     │
                     │    41 │   │   user_id=user_id,                                                                                                                                   │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\interface\initialize\loading.py:74 in build_component_and_get_results                      │
                     │                                                                                                                                                                  │
                     │    71 │   │   if base_type == "custom_components" and isinstance(custom_component,                                                                               │
                     │       CustomComponent):                                                                                                                                          │
                     │    72 │   │   │   return await build_custom_component(params=params_copy,                                                                                        │
                     │       custom_component=custom_component)                                                                                                                         │
                     │    73 │   │   elif base_type == "component" and isinstance(custom_component, Component):                                                                         │
                     │ ❱  74 │   │   │   return await build_component(params=params_copy,                                                                                               │
                     │       custom_component=custom_component)                                                                                                                         │
                     │    75 │   │   else:                                                                                                                                              │
                     │    76 │   │   │   raise ValueError(f"Base type {base_type} not found.")                                                                                          │
                     │    77                                                                                                                                                            │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\interface\initialize\loading.py:154 in build_component                                     │
                     │                                                                                                                                                                  │
                     │   151 ):                                                                                                                                                         │
                     │   152 │   # Now set the params as attributes of the custom_component                                                                                             │
                     │   153 │   custom_component.set_attributes(params)                                                                                                                │
                     │ ❱ 154 │   build_results, artifacts = await custom_component.build_results()                                                                                      │
                     │   155 │                                                                                                                                                          │
                     │   156 │   return custom_component, build_results, artifacts                                                                                                      │
                     │   157                                                                                                                                                            │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\custom\custom_component\component.py:136 in build_results                                  │
                     │                                                                                                                                                                  │
                     │   133 │                                                                                                                                                          │
                     │   134 │   async def build_results(self):                                                                                                                         │
                     │   135 │   │   if self.tracing_service:                                                                                                                           │
                     │ ❱ 136 │   │   │   return await self._build_with_tracing()                                                                                                        │
                     │   137 │   │   return await self._build_without_tracing()                                                                                                         │
                     │   138 │                                                                                                                                                          │
                     │   139 │   async def _build_results(self):                                                                                                                        │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\custom\custom_component\component.py:125 in _build_with_tracing                            │
                     │                                                                                                                                                                  │
                     │   122 │   │   inputs = self.get_trace_as_inputs()                                                                                                                │
                     │   123 │   │   metadata = self.get_trace_as_metadata()                                                                                                            │
                     │   124 │   │   async with self.tracing_service.trace_context(self.trace_name, self.trace_type,                                                                    │
                     │       inputs, metadata):                                                                                                                                         │
                     │ ❱ 125 │   │   │   _results, _artifacts = await self._build_results()                                                                                             │
                     │   126 │   │   │   trace_name = self.tracing_service.run_name                                                                                                     │
                     │   127 │   │   │   self.tracing_service.set_outputs(trace_name, _results)                                                                                         │
                     │   128                                                                                                                                                            │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\custom\custom_component\component.py:154 in _build_results                                 │
                     │                                                                                                                                                                  │
                     │   151 │   │   │   │   │   if output.cache and output.value != UNDEFINED:                                                                                         │
                     │   152 │   │   │   │   │   │   _results[output.name] = output.value                                                                                               │
                     │   153 │   │   │   │   │   else:                                                                                                                                  │
                     │ ❱ 154 │   │   │   │   │   │   result = method()                                                                                                                  │
                     │   155 │   │   │   │   │   │   # If the method is asynchronous, we need to await it                                                                               │
                     │   156 │   │   │   │   │   │   if inspect.iscoroutinefunction(method):                                                                                            │
                     │   157 │   │   │   │   │   │   │   result = await result                                                                                                          │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\base\models\model.py:43 in text_response                                                   │
                     │                                                                                                                                                                  │
                     │    40 │   │   stream = self.stream                                                                                                                               │
                     │    41 │   │   system_message = self.system_message                                                                                                               │
                     │    42 │   │   output = self.build_model()                                                                                                                        │
                     │ ❱  43 │   │   result = self.get_chat_result(output, stream, input_value, system_message)                                                                         │
                     │    44 │   │   self.status = result                                                                                                                               │
                     │    45 │   │   return result                                                                                                                                      │
                     │    46                                                                                                                                                            │
                     │                                                                                                                                                                  │
                     │ C:\Users\arek\AppData\Roaming\Python\Python312\site-packages\langflow\base\models\model.py:166 in get_chat_result                                                │
                     │                                                                                                                                                                  │
                     │   163 │   │   │   │   return result                                                                                                                              │
                     │   164 │   │   except Exception as e:                                                                                                                             │
                     │   165 │   │   │   if message := self._get_exception_message(e):                                                                                                  │
                     │ ❱ 166 │   │   │   │   raise ValueError(message) from e                                                                                                           │
                     │   167 │   │   │   raise e                                                                                                                                        │
                     │   168 │                                                                                                                                                          │
                     │   169 │   @abstractmethod                                                                                                                                        │
                     ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
                     ValueError: 503 Getting metadata from plugin failed with error: 'str' object has no attribute 'before_request'"
qlzsbp2j

qlzsbp2j7#

要解决在Windows 11 Pro上使用Vertex AI凭据时出现的错误 "503 从插件获取元数据失败,错误:'str' 对象没有 'before_request' 属性",您需要确保将 credentials 参数正确地作为 Credentials 对象传递,而不是包含凭据JSON文件路径的字符串。
以下是 llm.py 文件中 initialize_vertexai 函数的相关部分:
确保 credentials 参数正确设置为您凭据JSON文件的路径,它将在 initialize_vertexai 函数内转换为 Credentials 对象。例如:
确保凭据文件的路径正确且可以从您的环境中访问。 initialize_vertexai 函数将处理将路径转换为 Credentials 对象,这应该解决与 'str' 对象没有 'before_request' 属性相关的错误 1(https://github.com/logspace-ai/langflow/blob/dev/src/backend/langflow/components/llms/VertexAI.py)2(https://github.com/logspace-ai/langflow/blob/dev/src/backend/langflow/interface/initialize/llm.py)。

  • 要继续与 Dosu 对话,请提及 @dosu.*
aydmsdu9

aydmsdu98#

关于之前的帖子
此外,Langflow提供了一种直接在应用程序中配置凭据的方法。您可以在src/backend/langflow/interface/initialize/llm.py中的initialize_vertexai函数中设置credentials参数。以下是如何配置它的示例:

def initialize_vertexai(class_object, params):
    if credentials_path := params.get("credentials"):
        from google.oauth2 import service_account  # type: ignore

        credentials_object = service_account.Credentials.from_service_account_file(filename=credentials_path)
        params["credentials"] = credentials_object
    return class_object(**params)

您可以使用此功能直接使用凭据初始化您的Vertex AI组件:

from langflow.interface.initialize.llm import initialize_vertexai
from langflow.components.models.VertexAiModel import ChatVertexAIComponent

params = {
    "input_value": "Your input text here",
    "credentials": "C:\\path\\to\\your\\service-account-file.json",
    "project": "your-project-id",
    "location": "us-central1",
    "max_output_tokens": 128,
    "model_name": "chat-bison",
    "temperature": 0.0,
    "top_k": 40,
    "top_p": 0.95,
    "verbose": False,
    "stream": False,
    "system_message": None,
}

vertex_ai_component = initialize_vertexai(ChatVertexAIComponent, params)

我应该把它放在哪里?如何在Python代码片段中使用它?

vuv7lop3

vuv7lop39#

要在Langflow应用中使用提供的代码片段,你应该将其放在 src/backend/base/langflow/components/models/VertexAiModel.py 文件中。这个文件为Google Vertex AI大型语言模型定义了一个自定义组件。
以下是 ChatVertexAIComponent 类的完整代码片段:

from typing import List, Optional

from langchain_core.messages.base import BaseMessage

from langflow.base.constants import STREAM_INFO_TEXT
from langflow.base.models.model import LCModelComponent
from langflow.field_typing import Text

class ChatVertexAIComponent(LCModelComponent):
    display_name = "Vertex AI"
    description = "Generate text using Vertex AI LLMs."
    icon = "VertexAI"

    field_order = [
        "credentials",
        "project",
        "examples",
        "location",
        "max_output_tokens",
        "model_name",
        "temperature",
        "top_k",
        "top_p",
        "verbose",
        "input_value",
        "system_message",
        "stream",
    ]

    def build_config(self):
        return {
            "credentials": {
                "display_name": "Credentials",
                "field_type": "file",
                "file_types": [".json"],
                "file_path": None,
            },
            "examples": {
                "display_name": "Examples",
                "multiline": True,
            },
            "location": {
                "display_name": "Location",
                "value": "us-central1",
            },
            "max_output_tokens": {
                "display_name": "Max Output Tokens",
                "value": 128,
                "advanced": True,
            },
            "model_name": {
                "display_name": "Model Name",
                "value": "chat-bison",
            },
            "project": {
                "display_name": "Project",
            },
            "temperature": {
                "display_name": "Temperature",
                "value": 0.0,
            },
            "top_k": {
                "display_name": "Top K",
                "value": 40,
                "advanced": True,
            },
            "top_p": {
                "display_name": "Top P",
                "value": 0.95,
                "advanced": True,
            },
            "verbose": {
                "display_name": "Verbose",
                "value": False,
                "advanced": True,
            },
            "input_value": {"display_name": "Input"},
            "stream": {
                "display_name": "Stream",
                "info": STREAM_INFO_TEXT,
                "advanced": True,
            },
            "system_message": {
                "display_name": "System Message",
                "info": "System message to pass to the model.",
                "advanced": True,
            },
        }

    def build(
        self,
        input_value: Text,
        credentials: Optional[str],
        project: str,
        examples: Optional[List[BaseMessage]] = [],
        location: str = "us-central1",
        max_output_tokens: int = 128,
        model_name: str = "chat-bison",
        temperature: float = 0.0,
        top_k: int = 40,
        top_p: float = 0.95,
        verbose: bool = False,
        stream: bool = False,
        system_message: Optional[str] = None,
    ) -> Text:
        try:
            from langchain_google_vertexai import ChatVertexAI  # type: ignore
        except ImportError:
            raise ImportError(
                "To use the ChatVertexAI model, you need to install the langchain-google-vertexai package."
            )
        output = ChatVertexAI(
            credentials=credentials,
            examples=examples,
            location=location,
            max_output_tokens=max_output_tokens,
            model_name=model_name,
            project=project,
            temperature=temperature,
            top_k=top_k,
            top_p=top_p,
            verbose=verbose,
        )

        return self.get_chat_result(output, stream, input_value, system_message)

要在VertexAI节点的Python代码片段中使用此组件,可以根据需要示例化和配置 ChatVertexAIComponent 类。例如:

vertex_ai_component = ChatVertexAIComponent()
config = vertex_ai_component.build_config()
vertex_ai_instance = vertex_ai_component.build(
    input_value="Your input text here",
    credentials="C:\\path\\to\\your\\service-account-file.json",
    project="your-project-id",
    location="us-central1",
    max_output_tokens=128,
    model_name="chat-bison",
    temperature=0.0,
    top_k=40,
    top_p=0.95,
    verbose=False,
    stream=False,
    system_message="Your system message here"
)

这段代码片段演示了如何在您的应用程序 1(https://github.com/logspace-ai/langflow/blob/dev/src/backend/langflow/components/llms/VertexAI.py)2(https://github.com/langflow-ai/langflow/blob/dev/src/backend/base/langflow/components/models/VertexAiModel.py)3(https://github.com/logspace-ai/langflow/blob/dev/src/backend/base/langflow/components/models/VertexAiModel.py) 中配置和示例化 ChatVertexAIComponent

  • 要继续与 Dosu 对话,请提及 @dosu。*

相关问题