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

TypeError: 'NoneType' object is not iterable #3219

Closed
fireflywwj opened this issue Mar 7, 2024 · 4 comments
Closed

TypeError: 'NoneType' object is not iterable #3219

fireflywwj opened this issue Mar 7, 2024 · 4 comments
Labels
bug Something isn't working stale

Comments

@fireflywwj
Copy link

Traceback (most recent call last):
File "D:\ProgramData\Anaconda\envs\LangChainChatChat\Lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 535, in _run_script
exec(code, module.dict)
File "E:\01_Code\GitCode\Langchain-Chatchat\webui.py", line 64, in
pages[selected_page]["func"](api=api, is_lite=is_lite)
File "E:\01_Code\GitCode\Langchain-Chatchat\webui_pages\dialogue\dialogue.py", line 163, in dialogue_page
running_models = list(api.list_running_models())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not iterable

@fireflywwj fireflywwj added the bug Something isn't working label Mar 7, 2024
Copy link

dosubot bot commented Mar 7, 2024

Hey there, @fireflywwj! 👋 I'm Dosu, a friendly bot here to help you squash bugs, answer your questions, and guide you on your way to becoming a contributor. While we wait for a human maintainer to join us, know that I'm here to assist. I see you've run into a bit of a snag with a TypeError. Let me take a closer look and I'll get back to you with a full answer shortly! Stay tuned.

@LazyCatLee
Copy link

/server/utils.py 中 get_httpx_client() 方法中or host in os.environ.get("no_proxy", "").split(",") 代码中如下改能够解决该问题,我本地因为改过网络参数以及更新过依赖包出现该问题

for host in os.environ.get("no_proxy", "").split(","):
    # print(host)
    #TODO:  Local BUG 
    if (host:= host.strip() )!='::1':
        default_proxies.update({'all://' +host: None})

Copy link

dosubot bot commented Mar 7, 2024

The error TypeError: 'NoneType' object is not iterable you're encountering when trying to list running models in your dialogue_page function likely stems from the line:

running_models = list(api.list_running_models())

This error suggests that api.list_running_models() is returning None instead of an iterable object (like a list). This can happen if the underlying API call fails or if it's designed to return None under certain conditions (e.g., no models are running, or there's an issue with the connection or the server).

To fix this issue, you should ensure that api.list_running_models() always returns an iterable object, even in cases where no models are running or an error occurs. A simple approach is to modify the code to handle a None return value gracefully by defaulting to an empty list if None is encountered. You can achieve this with a minor adjustment:

running_models = list(api.list_running_models() or [])

This change uses the or operator to return an empty list ([]) if api.list_running_models() evaluates to None, ensuring that running_models is always an iterable object. This should resolve the TypeError you're facing.

However, it's also important to understand why api.list_running_models() might be returning None in the first place. This could be due to a variety of reasons, such as a problem with the backend server, a network issue, or a bug in the list_running_models() function itself. You might want to add some error handling or logging in the list_running_models() function to help diagnose the issue.

For example, you could modify the function to log an error message before returning None:

def list_running_models():
    # ... existing code ...
    if response.status_code != 200:
        logger.error(f"Failed to list running models: {response.content}")
        return None
    # ... existing code ...

This will log an error message whenever the function fails to list the running models, which could help you understand why it's returning None.

I hope this helps! If you have any further questions, feel free to ask.

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.

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

Copy link

github-actions bot commented Apr 6, 2024

这个问题已经被标记为 stale ,因为它已经超过 30 天没有任何活动。

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

No branches or pull requests

3 participants