langflow-ai / langflow

Langflow is a low-code app builder for RAG and multi-agent AI applications. Itโ€™s Python-based and agnostic to any model, API, or database.
http://www.langflow.org
MIT License
25.81k stars 3.47k forks source link

problems with Vertex AI credentials on windows 11 pro #2735

Closed severfire closed 1 month ago

severfire commented 1 month ago

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

dosubot[bot] commented 1 month ago

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 commented 1 month ago

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

dosubot[bot] commented 1 month ago

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 commented 1 month ago

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.

dosubot[bot] commented 1 month ago

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 commented 1 month ago

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

`

dosubot[bot] commented 1 month ago

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 commented 1 month ago

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?

dosubot[bot] commented 1 month ago

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 commented 1 month ago

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

https://github.com/langflow-ai/langflow/pull/2863

severfire commented 1 month ago

Thanks! I hope to test tomorrow!

severfire commented 1 month ago

Worked out, thanks!

rodgermoore commented 1 month ago

@severfire @nicoloboschi I created a custom component to use the Anthropic models on VertexAI: https://github.com/langflow-ai/langflow/pull/2863#issuecomment-2251972612