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

ValueError: invalid literal for int() with base 10: #3547

Closed
firebird199 opened this issue Aug 26, 2024 · 5 comments
Closed

ValueError: invalid literal for int() with base 10: #3547

firebird199 opened this issue Aug 26, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@firebird199
Copy link

Bug Description

When I execute the command pip install langflow -U, the entire installation process goes smoothly. However, after running langflow run, as expected, a web page automatically opens for the user to design the workflow. After filling in the required settings such as the api_key, when I try to drag any model from the Model section, I encounter the following error: ValueError: invalid literal for int() with base 10:. The specific log includes the following:

                         ValueError: invalid literal for int() with base 10: ''                                                                                                 
                                                                                                                                                                                
                         ╭──────────────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────────────╮                 
                         │ /Users/firebirds-mac/PycharmProjects/pythonProject/15-langflow-ollama/.env/lib/python3.11/site-packages/langflow/api/v1/endpoints. │                 
                         │ py:593 in custom_component_update                                                                                                  │                 
                         │                                                                                                                                    │                 
                         │   590 │   │   )                                                                                                                    │                 
                         │   591 │   │   if hasattr(cc_instance, "set_attributes"):                                                                           │                 
                         │   592 │   │   │   template = code_request.get_template()                                                                           │                 
                         │ ❱ 593 │   │   │   params = {                                                                                                       │                 
                         │   594 │   │   │   │   key: value_dict.get("value")                                                                                 │                 
                         │   595 │   │   │   │   if value_dict.get("_input_type") != "IntInput"                                                               │                 
                         │   596 │   │   │   │   else (                                                                                                       │                 
                         │                                                                                                                                    │                 
                         │ /Users/firebirds-mac/PycharmProjects/pythonProject/15-langflow-ollama/.env/lib/python3.11/site-packages/langflow/api/v1/endpoints. │                 
                         │ py:597 in <dictcomp>                                                                                                               │                 
                         │                                                                                                                                    │                 
                         │   594 │   │   │   │   key: value_dict.get("value")                                                                                 │                 
                         │   595 │   │   │   │   if value_dict.get("_input_type") != "IntInput"                                                               │                 
                         │   596 │   │   │   │   else (                                                                                                       │                 
                         │ ❱ 597 │   │   │   │   │   int(value_dict.get("value"))  # type: ignore                                                             │                 
                         │   598 │   │   │   │   │   if value_dict.get("_input_type") != "FloatInput"                                                         │                 
                         │   599 │   │   │   │   │   else float(value_dict.get("value"))  # type: ignore                                                      │                 
                         │   600 │   │   │   │   )                                                                                                            │                 
                         ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                 
                         ValueError: invalid literal for int() with base 10: ''                                                                                                 

for help!Thanks.

Reproduction

1 pip install langflow -U
2 langflow run
3 in the open website ,an API_KEY is set
4 drag any model from the Model Section

Expected behavior

not error

Who can help?

No response

Operating System

macos m3

Langflow Version

V1.0.16

Python Version

3.11

Screenshot

image

Flow File

No response

@firebird199 firebird199 added the bug Something isn't working label Aug 26, 2024
Copy link

dosubot bot commented Aug 26, 2024

Hey @firebird199! 👋 I'm here to help you with any bugs, questions, or contributions! Let's squash those bugs together while we wait for a human maintainer.

The error you're encountering, ValueError: invalid literal for int() with base 10: '', occurs because the code is attempting to convert an empty string to an integer. This happens in the custom_component_update function when processing the value_dict object.

To resolve this issue, you need to ensure that the value_dict.get("value") is not an empty string before attempting to convert it to an integer. You can add a validation check to handle this case.

Here's a potential fix for the issue in the custom_component_update function:

params = {
    key: value_dict.get("value")
    if value_dict.get("_input_type") != "IntInput"
    else (
        int(value_dict.get("value")) if value_dict.get("value") else None  # Add this check
    )
    if value_dict.get("_input_type") != "FloatInput"
    else float(value_dict.get("value"))  # type: ignore
}

This modification ensures that if value_dict.get("value") is an empty string, it will not attempt to convert it to an integer, thus avoiding the ValueError.

You can apply this change to your local copy of the endpoints.py file and see if it resolves the issue. If the problem persists, please provide additional details or logs for further assistance.

To continue talking to Dosu, mention @dosu.

@italojohnny italojohnny self-assigned this Aug 26, 2024
@italojohnny
Copy link
Member

This issue was fixed in PR #3514

@firebird199
Copy link
Author

i get it. Thanks all of you

@secretgspot
Copy link

This issue was fixed in PR #3514

no it wasn't. same error for me when adding local ollama module and then clicking on Model Name selector

@italojohnny
Copy link
Member

Hi, @secretgspot . I hope you're doing well.

Which version are you using?
The fix I mentioned is currently only available in the main branch. So, if you're using v1.0.16 or earlier, you'll still encounter the error.

You can either wait for the v1.0.17 release or clone the repository directly to get the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants