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
34.6k stars 4.16k forks source link

AstraDB tweak not working using API #4034

Closed alejandroacho closed 1 month ago

alejandroacho commented 1 month ago

Bug Description

When I pass the collection name through tweaks, it doesn't change it.

Reproduction

  1. Create flow with AstraDB component
  2. Using API with tweaks to set the collection name
  api_url = f"{LANGFLOW_API_URL}/api/v1/run/{ENDPOINT}"
  payload = {
      "AstraDB-COMPONENT-ID": {"collection_name": COLLECTION-NAME-STR},
  }
  response = requests.post(api_url, json=payload)

response.json() = {'detail': '{"message":"Error running graph: Error building Component Astra DB: \\n\\nError initializing AstraDBVectorStore: Must provide a collection name","traceback":null,"description":null,"code":null,"suggestion":null}'}

Expected behavior

AstraDB component should get collection_name tweak in order to initialize

Who can help?

No response

Operating System

Mac OS Sequoia 15.0 (using docker image)

Langflow Version

1.0.18

Python Version

None

Screenshot

CleanShot 2024-10-06 at 22 00 47

Flow File

No response

dosubot[bot] commented 1 month ago

Hey @alejandroacho! I'm here to help you with any bugs, questions, or contributions. Let's tackle this together!

The error message you're encountering indicates that the AstraDB component is not receiving the collection_name parameter correctly. Here are a few things to check and try:

  1. Component ID: Ensure that the AstraDB-COMPONENT-ID in your payload matches the actual component ID used in your flow. The component ID should be the exact identifier assigned to the AstraDB component in your Langflow setup.

  2. Payload Structure: Verify that the payload structure is correct. It should be a dictionary where the key is the component ID and the value is another dictionary containing the parameters you want to tweak. For example:

    {
     "AstraDB-COMPONENT-ID": {
       "collection_name": "your_collection_name"
     }
    }
  3. API Endpoint: Double-check that the api_url is correctly pointing to the Langflow API endpoint for running the flow.

  4. Langflow Version: Ensure that you are using the correct version of Langflow (1.0.18) and that there are no known issues with this version related to the AstraDB component. If there are any updates or patches available, consider applying them.

If these steps do not resolve the issue, it might be helpful to review the logs for any additional error messages or details that could provide more insight into why the collection_name is not being set. Langflow uses the loguru logger, which can help trace the initialization process of the AstraDB component [1].

To continue talking to Dosu, mention @dosu.

edwinjosechittilappilly commented 1 month ago

Hi @alejandroacho

Happy to help! Could you please share the details of the flow as well as the complete payload (excluding any sensitive information)? This would allow me to debug the issue more effectively.

Looking forward to your response!

alejandroacho commented 1 month ago

Solved. I had to put the tweaks dict in a tweak json attribute:

payload = {
    "input_value": message,
    "tweaks": {
        "TextInput-ID": {"input_value": "Hello world"},
    },
}
headers = {"Content-Type": "application/json"}
response = requests.post(f"{LANGFLOW_API_URL}/api/v1/run/{ENDPOINT}", json=payload, headers=headers)