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
33.53k stars 4.07k forks source link

Feature Request: Make `Credentials` field optional in `VertexAI` and `ChatVertexAI`; use ADC if left blank #1222

Closed caiharry closed 7 months ago

caiharry commented 10 months ago

Hey logspace.ai team!

Massive thanks for the great work on LangFlow, I'm currently setting it up in my org and can't wait to see how it develops in future!

I work with Google Cloud a lot and have a feature request, specifically for the VertexAI and ChatVertexAI LLM components.

Current State: image

As in this screenshot (Langflow v0.6.2 running on a VM in Google Cloud), I get an error message if I create a flow using VertexAI or ChatVertexAI where I don't upload a valid service account key to the Credentials field.

It does work if I create a service account which has permissions to call the Vertex LLMs, create a key for the service account and then upload it to the Credentials field.

However, this is not an ideal workflow because:

  1. Extra steps to create the service account and key; most users running LangFlow locally or deploying on a Google Cloud VM would expect it to just use ADC;
  2. Google's docs recommend against using service account keys when possible.

Desired Functionality: Ideally, users could choose to leave the Credentials field blank, with LangFlow defaulting to Google Application Default Credentials when this field is empty.

It would be great if the Project field could be left blank as well, with Langflow using the currently active Google Cloud project if it's left blank.

Additional Information (if applicable):

I saw this discord thread which might be relevant, if I read it right you guys were having issues with google.auth not picking up ADC in tests, and you implemented it using a service account key instead?

Many thanks, Harry

dosubot[bot] commented 10 months ago

πŸ€–

Hello @caiharry! πŸ‘‹

I'm Dosu, your friendly neighborhood bot, here to assist you while our human maintainers are busy. I'll do my best to provide solutions to bugs, answer any questions you have, and guide you through becoming a contributor, all while adding a touch of wit and sarcasm to keep things interesting.

I look forward to helping you navigate through the LangFlow repository. Let's dive into your issue now, shall we?

Thanks for your detailed feature request, Harry. I appreciate your feedback and the time you've taken to explain your use case.

Currently, the Credentials field in the VertexAI and ChatVertexAI components is required and cannot be left blank. The system validates the Credential object and raises an HTTPException with status code 400 if the value attribute of the Credential object is not present or empty. Here is the relevant code snippet from the credential.py file:

db_credential = Credential.model_validate(credential, from_attributes=True)
if not db_credential.value:
    raise HTTPException(status_code=400, detail="Credential value cannot be empty")

As for the Project field, I wasn't able to find specific information on how it's currently used in the VertexAI and ChatVertexAI components or how it's handled when left blank.

I understand your point about the extra steps involved in creating a service account and key, and the recommendation from Google's docs to avoid using service account keys when possible. Making the Credentials field optional and defaulting to Google Application Default Credentials (ADC) when it's left blank would indeed streamline the process for users running LangFlow locally or deploying on a Google Cloud VM.

However, implementing this change would require modifications to the current validation process for the Credentials field, as well as potentially other parts of the codebase. It's also worth noting that any changes would need to be thoroughly tested to ensure they don't introduce new issues or vulnerabilities.

I hope this information helps. If you have any further questions or need more clarification, please don't hesitate to ask.

Best, Dosu

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a πŸ‘ if this is helpful and πŸ‘Ž if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.