Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problems with Vertex AI credentials on windows 11 pro #2735

Closed
1 of 3 tasks
severfire opened this issue Jul 16, 2024 · 13 comments
Closed
1 of 3 tasks

problems with Vertex AI credentials on windows 11 pro #2735

severfire opened this issue Jul 16, 2024 · 13 comments
Assignees
Labels
bug Something isn't working

Comments

@severfire
Copy link

Bug Description

Hello,

I do have strange error, I am using Windows 11 Pro,
And while trying to use Credentials file on VertexAI, I am always getting

'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.'

Credentials are tested with flowise and other apps. They work. Maybe something is up with windows and this app and paths? Maybe there should be something like Credentials storage system for Credentials like in Flowise?

Thanks for help!
a.

Reproduction

Use Basic prompt template. Replace OpenAI with Vertex AI model. Put in file with credentials.

Expected behavior

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.

Who can help?

No response

Operating System

Windows 11 pro

Langflow Version

1.0.9

Python Version

  • 3.12
  • 3.11
  • 3.10
@severfire severfire added the bug Something isn't working label Jul 16, 2024
Copy link

dosubot bot commented Jul 16, 2024

Hey @severfire! 👋 I'm here to help you with bug fixes, answer your questions, and guide you to become a contributor. Let's squash those bugs together!

To resolve the "default credentials not found" error when using Vertex AI credentials on Windows 11 Pro with Langflow version 1.0.9 and Python 3.12, ensure that the credentials parameter is correctly set in the params dictionary. The initialize_vertexai function expects a path to the service account credentials file.

Here is an example of how you can set the credentials parameter:

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)

Make sure that the path to your service account JSON file is correct and accessible from your Windows 11 Pro environment. Additionally, ensure that the credentials parameter is set correctly in the build_config method of the VertexAIComponent class, as shown below:

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)

Ensure that the credentials parameter is correctly set in both the params dictionary and the build_config method. This should resolve the "default credentials not found" error [1][2][3].

To continue talking to Dosu, mention @dosu.

@severfire
Copy link
Author

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

Copy link

dosubot bot commented Jul 17, 2024

You should edit the code in the file located at src/frontend/src/modals/codeAreaModal/index.tsx in the Langflow application [1].

To continue talking to Dosu, mention @dosu.

@severfire
Copy link
Author

dear @dosu, I think you're wrong, file looks like it should not be edited in this manner - also I am not looking for hack but more elegant solution.

Copy link

dosubot bot commented Jul 17, 2024

To resolve the issue with Vertex AI credentials in Langflow, you should set the GOOGLE_APPLICATION_CREDENTIALS environment variable to point to your credentials JSON file. This is a standard approach for setting up Application Default Credentials (ADC) for Google Cloud services.

Here is how you can set the GOOGLE_APPLICATION_CREDENTIALS environment variable on Windows 11 Pro:

  1. Locate your credentials JSON file: Ensure you have the path to your Google Cloud service account key file (e.g., path\to\your\service-account-file.json).

  2. Set the environment variable:

    • Open the Start Menu and search for "Environment Variables".
    • Click on "Edit the system environment variables".
    • In the System Properties window, click on the "Environment Variables" button.
    • In the Environment Variables window, under the "System variables" section, click "New".
    • Set the "Variable name" to GOOGLE_APPLICATION_CREDENTIALS.
    • Set the "Variable value" to the full path of your service account key file (e.g., C:\path\to\your\service-account-file.json).
    • Click "OK" to close all the windows.
  3. Restart your application: Ensure that any command prompt or application that needs these credentials is restarted so that it picks up the new environment variable.

By setting the GOOGLE_APPLICATION_CREDENTIALS environment variable, the Vertex AI component in Langflow should be able to locate and use the credentials without requiring any code changes.

Additionally, Langflow provides a way to configure credentials directly within the application. You can set the credentials parameter in the initialize_vertexai function in src/backend/langflow/interface/initialize/llm.py. Here is an example of how you might configure it:

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)

You can use this function to initialize your Vertex AI component with the credentials directly:

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)

This approach allows you to specify the credentials directly in your code, providing an alternative to setting the environment variable [1][2].

To continue talking to Dosu, mention @dosu.

@severfire
Copy link
Author

dear @dosu.

got error 'Error Building Component
Error building Component Vertex AI: 503 Getting metadata from plugin failed with error: 'str' object has no attribute 'before_request''

the fix with variable did not work.

full error
`
"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'"

`

Copy link

dosubot bot commented Jul 17, 2024

To resolve the error "503 Getting metadata from plugin failed with error: 'str' object has no attribute 'before_request'" when using Vertex AI credentials on Windows 11 Pro with Langflow version 1.0.9 and Python 3.12, you need to ensure that the credentials parameter is correctly passed as a Credentials object rather than a string containing the path to the credentials JSON file.

Here is the relevant part of the initialize_vertexai function in the llm.py file:

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)

Make sure that the credentials parameter is correctly set to the path of your credentials JSON file, and it will be converted to a Credentials object within the initialize_vertexai function. For example:

vertex_ai_component = VertexAIComponent()
llm = vertex_ai_component.build(
    credentials="path/to/your/credentials.json",
    location="us-central1",
    max_output_tokens=128,
    max_retries=6,
    metadata={},
    model_name="text-bison",
    n=1,
    name=None,
    project="your-project-id",
    request_parallelism=5,
    streaming=False,
    temperature=0.0,
    top_k=40,
    top_p=0.95,
    tuned_model_name=None,
    verbose=False
)

Ensure that the path to the credentials file is correct and accessible from your environment. The initialize_vertexai function will handle converting the path to a Credentials object, which should resolve the error related to the 'str' object not having the 'before_request' attribute [1][2].

To continue talking to Dosu, mention @dosu.

@severfire
Copy link
Author

regarding earlier post

Additionally, Langflow provides a way to configure credentials directly within the application. You can set the credentials parameter in the initialize_vertexai function in src/backend/langflow/interface/initialize/llm.py. Here is an example of how you might configure it:

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)

You can use this function to initialize your Vertex AI component with the credentials directly:

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)

where I should put it? how can i use it in python code snippet of a VertexAI node?

Copy link

dosubot bot commented Jul 18, 2024

To use the provided code snippet in the Langflow application, you should place it in the src/backend/base/langflow/components/models/VertexAiModel.py file. This file defines a custom component for Google Vertex AI large language models.

Here is the complete code snippet for the ChatVertexAIComponent class:

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)

To use this component in the Python code snippet of a VertexAI node, you can instantiate and configure the ChatVertexAIComponent class as needed. For example:

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"
)

This code snippet demonstrates how to configure and instantiate the ChatVertexAIComponent within your application [1][2][3].

To continue talking to Dosu, mention @dosu.

@nicoloboschi
Copy link
Contributor

Could you try 1.0.12?
There's a fix for it

#2863

@severfire
Copy link
Author

Thanks! I hope to test tomorrow!

@severfire
Copy link
Author

Worked out, thanks!

@rodgermoore
Copy link

@severfire @nicoloboschi I created a custom component to use the Anthropic models on VertexAI: #2863 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants