Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

What is the input value for vector store search when running as json flow? #1870

Open
jordanrfrazier opened this issue May 9, 2024 · 4 comments
Labels
question Further information is requested

Comments

@jordanrfrazier
Copy link

jordanrfrazier commented May 9, 2024

Summary

Overall question: How do I know what is a valid input key and valid output component for my flows when exporting them to json to run?

I have a simple flow, with an OpenAIEmbeddings component hooked up to an AstraDBSearch. I have no other values set in my flow when I export it to json.

The given python code is:

from langflow.load import run_flow_from_json
TWEAKS = {
  "OpenAIEmbeddings-sSuTz": {},
  "AstraDBSearch-avH6c": {}
}

result = run_flow_from_json(flow="Untitled document (24).json",
                            input_value="message",
                            tweaks=TWEAKS)

Once I add in my API keys / endpoint, I still have an empty input value. That makes sense to me, as I imagine I can do:

result = run_flow_from_json(flow="Untitled document (24).json",
                            input_value="message", # I would hope that this `input_value` is used as the `input_value` to `AstraDBSearch`. 
                            tweaks=TWEAKS)

However, it fails to build, saying:

ValueError: Error running graph: Error building vertex Astra DB Search: AstraDBSearchComponent.build() missing 1 required positional argument: 'input_value'

Now, just for the sake of the argument, I added it directly to the tweaks instead:

        "AstraDBSearch-avH6c": {
             ...
            "input_value": "<my search query>",
        },

    result = run_flow_from_json(flow=flow, input_value="<does it matter what goes here now>", tweaks=TWEAKS)

Now, I get the error:

AttributeError: 'RunOutputs' object has no attribute 'output'

So questions for that are:

  1. What purpose does the input_value in run_flow_from_json serve in this context?
  2. What is the output error - is it telling me that the vector search component is not a valid output component?

** Version **

  • latest dev branch
  • python 3.11.2

To Reproduce
create flow, export to json, try run as json

Thanks!

Additional context
Screenshot 2024-05-09 at 11 59 03 AM

Copy link

dosubot bot commented May 9, 2024

The input_value in the run_flow_from_json function is meant to be the initial input for the flow, which gets processed by the components in your setup. For your case, this means the input_value would be the text input for the OpenAIEmbeddings component, which then generates embeddings to be used by the AstraDBSearch component for searching within Astra DB.

Regarding the AttributeError: 'RunOutputs' object has no attribute 'output' error, it seems there's an attempt to access a non-existent output attribute on the RunOutputs object. Instead, you should access the outputs attribute, which is a list containing the results. Here's how you can iterate over the outputs to access the results:

for result_data in result.outputs:
    if result_data is not None:
        print(result_data.results)

Ensure that the output_component parameter in your run_flow_from_json call matches the ID of the component you expect to produce the output, such as your AstraDBSearch component. This setup is crucial for correctly retrieving the output from your flow.

result = run_flow_from_json(
    flow='my_flow.json',
    input_value='my_input',
    output_component='AstraDBSearch-avH6c',  # Ensure this matches your component's ID
    tweaks=TWEAKS,
)

Make sure your component IDs and the way you access the output data align with your flow's configuration and the RunOutputs object structure.

Details

Sources


About Dosu
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.

To continue the conversation, mention @dosu.

@dosubot dosubot bot added the question Further information is requested label May 9, 2024
@jordanrfrazier
Copy link
Author

jordanrfrazier commented May 9, 2024

I see -- that's my mistake. The outputs issue was on my end.

However, I did have to add the output_component parameter in order to receive the correct outputs. Leaving it out still built and ran, but the output was empty:

[RunOutputs(inputs={'input_value': '<does this matter?>'}, outputs=[])]

Adding the output_component like:

    result = run_flow_from_json(
        flow=flow,
        input_value="<does this matter?>",
        output_component="AstraDBSearch-avH6c",
        tweaks=TWEAKS,
    )

correctly produced outputs.

@jordanrfrazier
Copy link
Author

@dosu thanks, the issue relating to the output was my mistake.

However, I am still curious about how I can run the flow by using the input_value from the run_flow_from_json function as the input to the my AstraDBSearch component.

Copy link

dosubot bot commented May 9, 2024

To use the input_value from the run_flow_from_json function as the input for your AstraDBSearch component, it's important to understand that this value is intended to be the initial input for the entire flow. This means it should be the text input for the OpenAIEmbeddings component, which then processes this input to generate embeddings. These embeddings are subsequently used by the AstraDBSearch component for searching within Astra DB.

The input_value parameter in the run_flow_from_json function is directly passed to the initial component of your flow, which in your setup is likely the OpenAIEmbeddings component. The flow then automatically manages the passage of data between components, so the output from OpenAIEmbeddings becomes the input for AstraDBSearch.

If you're encountering issues with the input_value not being recognized or used correctly by the AstraDBSearch component, ensure that your flow is correctly set up to pass the output of OpenAIEmbeddings as the input to AstraDBSearch. This typically involves configuring the flow in such a way that the data output from one component is correctly mapped as the input to the next.

Regarding the tweaks and adjustments you've attempted by directly modifying the TWEAKS dictionary, it's crucial to remember that these tweaks should not be used to pass fundamental input values between components. Instead, the TWEAKS dictionary is intended for runtime modifications or adjustments to the flow's execution, such as changing component parameters or settings dynamically.

For your specific case, ensure that:

  • The input_value you provide when calling run_flow_from_json is the text you want to process with OpenAIEmbeddings.
  • Your flow is correctly configured so that the output from OpenAIEmbeddings is automatically used as the input for AstraDBSearch.
  • Any tweaks you apply via the TWEAKS dictionary are appropriate adjustments to component settings, rather than attempts to manually pass data between components.

This approach should allow you to run your flow as intended, with the input_value provided at the start being correctly utilized by both the OpenAIEmbeddings and AstraDBSearch components according to the flow's configuration.

Details

Sources


About Dosu
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.

To continue the conversation, mention @dosu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant