langflow icon indicating copy to clipboard operation
langflow copied to clipboard

issue with langflow 1.0.19

Open michelgirault opened this issue 1 year ago • 11 comments

Bug Description

the node agent: Sequential Crew does not recognize anymore my openai compatible llm (llama 3) in previous version i did not face this issue, i tried a few other agent, same error message, now if i use the node openai with other node, i dont have any problems

Screenshot from 2024-10-15 19-18-52 the error message: Error building Component Sequential Crew: litellm.AuthenticationError: AuthenticationError: OpenAIException - Error code: 401 - {'error': {'message': 'Incorrect API key provided: dummy. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}}

Reproduction

  1. create an empty flow
  2. attach openai and setup the base url and api key
  3. add a node : Sequential Task Agent and Sequential Crew

Expected behavior

error message as provided with an issue about the api key used

Who can help?

No response

Operating System

ubuntu 22.04

Langflow Version

1.19

Python Version

3.10

Screenshot

No response

Flow File

No response

michelgirault avatar Oct 15 '24 17:10 michelgirault

The error message you're encountering indicates that the Sequential Crew node is not recognizing the API key for your OpenAI-compatible LLM, resulting in an authentication error. This issue seems to be specific to the Sequential Crew node, as other nodes like the OpenAI node are working correctly with the same API key.

In Langflow 1.19, the Sequential Crew node retrieves and uses the API key by accepting it as a parameter in the build method of the OpenAIModelComponent class. The API key is passed as the openai_api_key argument and is wrapped in a SecretStr for security purposes. This key is then used to initialize the ChatOpenAI object, which interacts with the OpenAI API [1].

To troubleshoot this issue, you can:

  1. Double-check that the API key is correctly entered and valid.
  2. Ensure that the Sequential Crew node is configured to use the correct API key and base URL.
  3. Verify that there are no typos or formatting issues in the API key field.

If the problem persists, it might be worth checking if there are any recent changes or updates in the Langflow repository that could affect the authentication process for the Sequential Crew node.

To continue talking to Dosu, mention @dosu.

dosubot[bot] avatar Oct 15 '24 17:10 dosubot[bot]

as i said it was working in previous version with the exact setup and in other node i dont have any issue

michelgirault avatar Oct 15 '24 17:10 michelgirault

seems to be related to this fix https://github.com/langflow-ai/langflow/pull/4150

phact avatar Oct 15 '24 19:10 phact

In the short term, adding OPENAI_API_KEY as an env variable (either in your terminal before starting langflow or using the dotenv component) should function as a workaround: image

phact avatar Oct 15 '24 19:10 phact

thanks

michelgirault avatar Oct 15 '24 19:10 michelgirault

By the way I was able to reproduce this same scenario with langflow v1.0.18 and the sequential crew component with memory enabled.

The error message is the same except it says fake instead of dummy

phact avatar Oct 15 '24 21:10 phact

Hi, thanks i think this is an issue with crewai and the memory component enabled, https://github.com/crewAIInc/crewAI/issues/447

michelgirault avatar Oct 16 '24 09:10 michelgirault

Yeah more specifically crewai's memory feature tries to use embeddings from openai and expects the api key to be set via env var.

phact avatar Oct 16 '24 17:10 phact

This should now be addressed in the latest main. Could you confirm @michelgirault ? The credentials of the agents are auto-detected - with the catch being that we don't necessarily have a FULLY general solution to figure out the embedding model credentials and how it is referenced when it is passed to the agent. So this has been tested with OpenAI and other common models, but there may be more to do to better support less commonly use models.

erichare avatar Nov 27 '24 20:11 erichare

i will check and get back to you, thanks for following up

michelgirault avatar Nov 27 '24 21:11 michelgirault

Thanks @michelgirault !

erichare avatar Nov 27 '24 21:11 erichare